CMakeLists.txt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cmake_minimum_required(VERSION 3.0)
  2. project(CompileFeatures)
  3. if (NOT CMAKE_CXX_COMPILE_FEATURES)
  4. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp"
  5. "int main(int,char**) { return 0; }\n"
  6. )
  7. add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
  8. return()
  9. endif()
  10. macro(run_test feature)
  11. if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature})
  12. add_library(test_${feature} OBJECT ${feature}.cpp)
  13. set_property(TARGET test_${feature}
  14. PROPERTY COMPILE_FEATURES "${feature}"
  15. )
  16. else()
  17. message("Not supported: ${feature}")
  18. endif()
  19. endmacro()
  20. foreach(feature ${CMAKE_CXX_KNOWN_FEATURES})
  21. run_test(${feature})
  22. endforeach()
  23. add_executable(CompileFeatures main.cpp)
  24. set_property(TARGET CompileFeatures
  25. PROPERTY COMPILE_FEATURES "cxx_auto_type"
  26. )
  27. add_executable(GenexCompileFeatures main.cpp)
  28. set_property(TARGET GenexCompileFeatures
  29. PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
  30. )
  31. add_library(iface INTERFACE)
  32. set_property(TARGET iface
  33. PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
  34. )
  35. add_executable(IfaceCompileFeatures main.cpp)
  36. target_link_libraries(IfaceCompileFeatures iface)