no_matching_cxx_feature.cmake 783 B

123456789101112131415161718192021222324252627
  1. enable_language(CXX)
  2. if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;"
  3. AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" )
  4. # Simulate passing the test.
  5. message(SEND_ERROR
  6. "The compiler feature \"gnu_cxx_dummy\" is not known to CXX compiler\n\"GNU\"\nversion 4.8.1."
  7. )
  8. return()
  9. endif()
  10. if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;")
  11. set(feature msvc_cxx_sealed)
  12. if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;")
  13. # If a compiler supports both extensions, remove one of them.
  14. list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed)
  15. endif()
  16. else()
  17. set(feature gnu_cxx_typeof)
  18. endif()
  19. add_executable(main empty.cpp)
  20. target_compile_features(main
  21. PRIVATE
  22. ${feature}
  23. )