cmake/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake

28 lines
783 B
CMake
Raw Normal View History

2017-07-20 19:35:53 +02:00
enable_language(CXX)
2015-04-27 22:25:09 +02:00
if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;"
AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" )
# Simulate passing the test.
message(SEND_ERROR
"The compiler feature \"gnu_cxx_dummy\" is not known to CXX compiler\n\"GNU\"\nversion 4.8.1."
)
return()
endif()
if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;")
set(feature msvc_cxx_sealed)
if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;")
# If a compiler supports both extensions, remove one of them.
list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed)
endif()
else()
set(feature gnu_cxx_typeof)
endif()
add_executable(main empty.cpp)
target_compile_features(main
PRIVATE
${feature}
)