CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. cmake_minimum_required(VERSION 3.10)
  2. project(target_compile_features)
  3. set(CMAKE_VERBOSE_MAKEFILE ON)
  4. if (c_restrict IN_LIST CMAKE_C_COMPILE_FEATURES)
  5. add_executable(c_target_compile_features_specific main.c)
  6. target_compile_features(c_target_compile_features_specific
  7. PRIVATE c_restrict
  8. )
  9. add_library(c_lib_restrict_specific lib_restrict.c)
  10. target_compile_features(c_lib_restrict_specific
  11. PUBLIC c_restrict
  12. )
  13. add_executable(c_restrict_user_specific restrict_user.c)
  14. target_link_libraries(c_restrict_user_specific c_lib_restrict_specific)
  15. endif()
  16. if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES AND
  17. NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
  18. add_executable(c_target_compile_features_meta main.c)
  19. target_compile_features(c_target_compile_features_meta
  20. PRIVATE c_std_99
  21. )
  22. add_library(c_lib_restrict_meta lib_restrict.c)
  23. target_compile_features(c_lib_restrict_meta
  24. PUBLIC c_std_99
  25. )
  26. add_executable(c_restrict_user_meta restrict_user.c)
  27. target_link_libraries(c_restrict_user_meta c_lib_restrict_meta)
  28. endif()
  29. if (cxx_auto_type IN_LIST CMAKE_CXX_COMPILE_FEATURES)
  30. add_executable(cxx_target_compile_features_specific main.cpp)
  31. target_compile_features(cxx_target_compile_features_specific
  32. PRIVATE cxx_auto_type
  33. )
  34. add_library(cxx_lib_auto_type_specific lib_auto_type.cpp)
  35. target_compile_features(cxx_lib_auto_type_specific
  36. PUBLIC cxx_auto_type
  37. )
  38. add_executable(cxx_lib_user_specific lib_user.cpp)
  39. target_link_libraries(cxx_lib_user_specific cxx_lib_auto_type_specific)
  40. endif()
  41. if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
  42. add_executable(cxx_target_compile_features_meta main.cpp)
  43. target_compile_features(cxx_target_compile_features_meta
  44. PRIVATE cxx_std_11
  45. )
  46. add_library(cxx_lib_auto_type_meta lib_auto_type.cpp)
  47. target_compile_features(cxx_lib_auto_type_meta
  48. PUBLIC cxx_std_11
  49. )
  50. add_executable(cxx_lib_user_meta lib_user.cpp)
  51. target_link_libraries(cxx_lib_user_meta cxx_lib_auto_type_meta)
  52. endif()