From b3e86f4e976562913bbe322bd2856a75a1542b27 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 3 Jan 2015 14:57:31 +0100 Subject: Features: Test an expectation of whether OVERRIDE_CONTROL is expected The tests below test the presence of both cxx_final and cxx_override, only one of which is supported by MSVC. The test is in part intended to verify that the COMPILE_FEATURES genex supports multiple arguments and allows users to define names for groups of features (Clang already calls cxx_final and cxx_override 'override control' as a group). Keep the test, and allow the expectation to be set as appropriate. --- Tests/CompileFeatures/CMakeLists.txt | 2 ++ Tests/CompileFeatures/genex_test.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index ff5d745..ae666c8 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -120,6 +120,8 @@ 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=$) diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index ca38883..46b1942 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 -- cgit v0.12 From 3e34e8331a72f227248a235595e3cfeabf65312e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 3 Jan 2015 15:04:39 +0100 Subject: Features: Test feature propagation with more-common features. The purpose of the feature listing in these tests is to make other features from the same feature set (eg "C++11 features") available. The compilers under test until now have supported these 'activation features', but MSVC does not. Use the cxx_static_assert feature instead to activate the feature set. --- Tests/CompileFeatures/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index ae666c8..aca1791 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -127,12 +127,12 @@ if (CMAKE_CXX_COMPILE_FEATURES) target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$) add_executable(CompileFeaturesGenex2 genex_test.cpp) - target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr) + target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$) - 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_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$) endif() -- cgit v0.12 From c13656e7173a517961349a5fe20ce0f727d37568 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 3 Jan 2015 15:09:53 +0100 Subject: Features: Test nullptr as a side-effect activation of static_assert. Because not all compilers under test support the existing 'activation features', add another test to ensure that compilers which support both static_assert and nullptr behave as expected in this test. --- Tests/CompileFeatures/CMakeLists.txt | 15 ++++++++++++--- Tests/CompileFeatures/genex_test.cpp | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index aca1791..832f68b 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -124,15 +124,24 @@ if (CMAKE_CXX_COMPILE_FEATURES) add_executable(CompileFeaturesGenex genex_test.cpp) set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11) - target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$) + target_compile_definitions(CompileFeaturesGenex PRIVATE + HAVE_OVERRIDE_CONTROL=$ + HAVE_NULLPTR=$ + ) add_executable(CompileFeaturesGenex2 genex_test.cpp) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) - target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$) + target_compile_definitions(CompileFeaturesGenex2 PRIVATE + HAVE_OVERRIDE_CONTROL=$ + HAVE_NULLPTR=$ + ) 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 static_assert_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$) + target_compile_definitions(CompileFeaturesGenex3 PRIVATE + HAVE_OVERRIDE_CONTROL=$ + HAVE_NULLPTR=$ + ) endif() diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 46b1942..f667cc4 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -17,6 +17,17 @@ struct B final : A #endif +#if !HAVE_NULLPTR +#error "Expect nullptr feature" +#else + +const char* getString() +{ + return nullptr; +} + +#endif + int main() { -- cgit v0.12 From 6296192defaaaa4c18b1821614c20b95ad94f806 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 3 Jan 2015 15:18:39 +0100 Subject: Features: Add a comment explaining part of test. --- Tests/CompileFeatures/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 832f68b..834ac7c 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -33,6 +33,8 @@ endforeach() 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 ) -- cgit v0.12 From 07d1f6fca1d6ea21dea64b32639c44d5eecf98a6 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 31 Dec 2014 10:25:33 -0500 Subject: Features: Properly evaluate if the compiler supports cxx_final. Previously we expanded HAVE_FINAL to determine what the copied_file number would be, but when we don't have cxx_final than HAVE_FINAL is not defined. What we really want is to use expected_result. --- Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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() -- cgit v0.12 From a15675efc3d96906d4e803def2e83fd3bd1cf812 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 6 Jan 2015 13:31:30 -0500 Subject: Features: Quote all compiler names when comparing with COMPILER_ID In preparation of adding MSVC support we need to quote all compiler names, as MSVC is also a CMake variable. --- Tests/CompileFeatures/CMakeLists.txt | 6 +++--- Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 834ac7c..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,7 +31,7 @@ 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. @@ -39,7 +39,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL GNU 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. 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) -- cgit v0.12