diff options
author | Brad King <brad.king@kitware.com> | 2015-01-11 17:00:22 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-01-11 17:00:22 (GMT) |
commit | 1c0d6a7cb5c51fef3ee8804ed298da95e2c1ca1a (patch) | |
tree | 5bd4ce690ac0fa03fa0b1a16afdda6bb120ba43b /Tests | |
parent | cb5fc7b993866e7398922d34a1b1807ad061d4b0 (diff) | |
parent | a15675efc3d96906d4e803def2e83fd3bd1cf812 (diff) | |
download | CMake-1c0d6a7cb5c51fef3ee8804ed298da95e2c1ca1a.zip CMake-1c0d6a7cb5c51fef3ee8804ed298da95e2c1ca1a.tar.gz CMake-1c0d6a7cb5c51fef3ee8804ed298da95e2c1ca1a.tar.bz2 |
Merge topic 'refactor-CompileFeatures-test'
a15675ef Features: Quote all compiler names when comparing with COMPILER_ID
07d1f6fc Features: Properly evaluate if the compiler supports cxx_final.
6296192d Features: Add a comment explaining part of test.
c13656e7 Features: Test nullptr as a side-effect activation of static_assert.
3e34e833 Features: Test feature propagation with more-common features.
b3e86f4e Features: Test an expectation of whether OVERRIDE_CONTROL is expected
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CompileFeatures/CMakeLists.txt | 33 | ||||
-rw-r--r-- | Tests/CompileFeatures/genex_test.cpp | 13 | ||||
-rw-r--r-- | Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake | 4 |
4 files changed, 45 insertions, 19 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index ff5d745..b164f06 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(CompileFeatures) @@ -31,13 +31,15 @@ foreach(feature ${cxx_features}) run_test(${feature} CXX) endforeach() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + # The cxx_alignof feature happens to work (for *this* testcase) with + # GNU 4.7, but it is first documented as available with GNU 4.8. list(REMOVE_ITEM CXX_non_features cxx_alignof ) endif() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) # GNU prior to 4.9 does not set any preprocessor define to distinguish # c++1y from c++11, so CMake does not support c++1y features before GNU 4.9. @@ -120,17 +122,28 @@ if (CMAKE_CXX_COMPILE_FEATURES) add_executable(IfaceCompileFeatures main.cpp) target_link_libraries(IfaceCompileFeatures iface) + add_definitions(-DEXPECT_OVERRIDE_CONTROL=1) + add_executable(CompileFeaturesGenex genex_test.cpp) 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> + HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + ) add_executable(CompileFeaturesGenex2 genex_test.cpp) - target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr) - target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>) + target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) + target_compile_definitions(CompileFeaturesGenex2 PRIVATE + HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> + HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + ) - add_library(noexcept_iface INTERFACE) - target_compile_features(noexcept_iface INTERFACE cxx_noexcept) + add_library(static_assert_iface INTERFACE) + target_compile_features(static_assert_iface INTERFACE cxx_static_assert) add_executable(CompileFeaturesGenex3 genex_test.cpp) - target_link_libraries(CompileFeaturesGenex3 PRIVATE noexcept_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>) + target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) + target_compile_definitions(CompileFeaturesGenex3 PRIVATE + HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> + HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + ) endif() diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index ca38883..f667cc4 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -1,6 +1,8 @@ #if !HAVE_OVERRIDE_CONTROL +#if EXPECT_OVERRIDE_CONTROL #error "Expect override control feature" +#endif #else struct A @@ -15,6 +17,17 @@ struct B final : A #endif +#if !HAVE_NULLPTR +#error "Expect nullptr feature" +#else + +const char* getString() +{ + return nullptr; +} + +#endif + int main() { diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 5b2f1de..401de95 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.1.0) project(WriteCompilerDetectionHeader) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -56,17 +56,17 @@ macro(set_defines target true_defs false_defs) ) endmacro() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU - OR CMAKE_CXX_COMPILER_ID STREQUAL Clang - OR CMAKE_CXX_COMPILER_ID STREQUAL AppleClang) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # False for C++98 mode. list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) endif() -if (CMAKE_C_COMPILER_ID STREQUAL GNU - OR CMAKE_C_COMPILER_ID STREQUAL Clang - OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" + OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") add_executable(C_undefined c_undefined.c) set_property(TARGET C_undefined PROPERTY CXX_STANDARD 90) target_compile_options(C_undefined PRIVATE -Werror=undef) diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake index c6707c1..4de8e88 100644 --- a/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake +++ b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake @@ -7,11 +7,11 @@ else() set(expected_result 0) endif() -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file${HAVE_FINAL}.cpp" +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file${expected_result}.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp" ) -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp") +add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${expected_result}.cpp") if (HAVE_FINAL) target_compile_features(empty PRIVATE cxx_final) endif() |