CMakeLists.txt 937 B

123456789101112131415161718192021222324252627282930313233343536
  1. cmake_minimum_required(VERSION 3.0)
  2. project(CompileFeatures)
  3. macro(run_test feature)
  4. if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature})
  5. add_library(test_${feature} OBJECT ${feature}.cpp)
  6. set_property(TARGET test_${feature}
  7. PROPERTY COMPILE_FEATURES "${feature}"
  8. )
  9. else()
  10. message("Not supported: ${feature}")
  11. endif()
  12. endmacro()
  13. foreach(feature ${CMAKE_CXX_KNOWN_FEATURES})
  14. run_test(${feature})
  15. endforeach()
  16. add_executable(CompileFeatures main.cpp)
  17. set_property(TARGET CompileFeatures
  18. PROPERTY COMPILE_FEATURES "cxx_auto_type"
  19. )
  20. add_executable(GenexCompileFeatures main.cpp)
  21. set_property(TARGET GenexCompileFeatures
  22. PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
  23. )
  24. add_library(iface INTERFACE)
  25. set_property(TARGET iface
  26. PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
  27. )
  28. add_executable(IfaceCompileFeatures main.cpp)
  29. target_link_libraries(IfaceCompileFeatures iface)