Features: Test the CXX compiler only if it has features.
If using different C and CXX compilers, we might not have a feature-full CXX compiler at this point.
This commit is contained in:
parent
598a316154
commit
7565ab2cd1
@ -77,36 +77,38 @@ foreach(lang CXX C)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_executable(CompileFeatures main.cpp)
|
if (CMAKE_CXX_COMPILE_FEATURES)
|
||||||
set_property(TARGET CompileFeatures
|
add_executable(CompileFeatures main.cpp)
|
||||||
PROPERTY COMPILE_FEATURES "cxx_auto_type"
|
set_property(TARGET CompileFeatures
|
||||||
)
|
PROPERTY COMPILE_FEATURES "cxx_auto_type"
|
||||||
set_property(TARGET CompileFeatures
|
)
|
||||||
PROPERTY CXX_STANDARD_REQUIRED TRUE
|
set_property(TARGET CompileFeatures
|
||||||
)
|
PROPERTY CXX_STANDARD_REQUIRED TRUE
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(GenexCompileFeatures main.cpp)
|
add_executable(GenexCompileFeatures main.cpp)
|
||||||
set_property(TARGET GenexCompileFeatures
|
set_property(TARGET GenexCompileFeatures
|
||||||
PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
|
PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(iface INTERFACE)
|
add_library(iface INTERFACE)
|
||||||
set_property(TARGET iface
|
set_property(TARGET iface
|
||||||
PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
|
PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
|
||||||
)
|
)
|
||||||
add_executable(IfaceCompileFeatures main.cpp)
|
add_executable(IfaceCompileFeatures main.cpp)
|
||||||
target_link_libraries(IfaceCompileFeatures iface)
|
target_link_libraries(IfaceCompileFeatures iface)
|
||||||
|
|
||||||
add_executable(CompileFeaturesGenex genex_test.cpp)
|
add_executable(CompileFeaturesGenex genex_test.cpp)
|
||||||
set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
|
set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
|
||||||
target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
||||||
|
|
||||||
add_executable(CompileFeaturesGenex2 genex_test.cpp)
|
add_executable(CompileFeaturesGenex2 genex_test.cpp)
|
||||||
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr)
|
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr)
|
||||||
target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
||||||
|
|
||||||
add_library(noexcept_iface INTERFACE)
|
add_library(noexcept_iface INTERFACE)
|
||||||
target_compile_features(noexcept_iface INTERFACE cxx_noexcept)
|
target_compile_features(noexcept_iface INTERFACE cxx_noexcept)
|
||||||
add_executable(CompileFeaturesGenex3 genex_test.cpp)
|
add_executable(CompileFeaturesGenex3 genex_test.cpp)
|
||||||
target_link_libraries(CompileFeaturesGenex3 PRIVATE noexcept_iface)
|
target_link_libraries(CompileFeaturesGenex3 PRIVATE noexcept_iface)
|
||||||
target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
|
||||||
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user