summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CMakeConfigurableFile.in1
-rw-r--r--Modules/Compiler/GNU-CXX-FeatureTests.cmake4
-rw-r--r--Source/cmMakefile.cxx1
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt38
-rw-r--r--Tests/CompileFeatures/feature_test.cpp10
-rw-r--r--Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/CompileFeatures/generate_feature_list.cmake2
7 files changed, 47 insertions, 15 deletions
diff --git a/Modules/CMakeConfigurableFile.in b/Modules/CMakeConfigurableFile.in
index 4cf74a1..df2c382 100644
--- a/Modules/CMakeConfigurableFile.in
+++ b/Modules/CMakeConfigurableFile.in
@@ -1,2 +1 @@
@CMAKE_CONFIGURABLE_FILE_CONTENT@
-
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
index 5edb69e..64ddc59 100644
--- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -3,11 +3,13 @@
set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
# Introduced in GCC 4.8.1
-set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
+set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
+# The alignof feature works with GNU 4.7 and -std=c++11, but it is documented
+# as available with GNU 4.8, so treat that as true.
set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 29d2fb0..90a7b0b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4978,6 +4978,7 @@ static const char * const CXX_FEATURES[] = {
0
FOR_EACH_CXX_FEATURE(FEATURE_STRING)
};
+#undef FEATURE_STRING
static const char * const CXX_STANDARDS[] = {
"98"
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 274c5ba..adf50d5 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -27,17 +27,37 @@ foreach(feature ${cxx_features})
run_test(${feature} CXX)
endforeach()
-if (CMAKE_CXX_COMPILE_FEATURES)
- include(CheckCXXSourceCompiles)
- foreach(feature ${CXX_non_features})
- check_cxx_source_compiles("#include \"${CMAKE_CURRENT_SOURCE_DIR}/${feature}.cpp\"\nint main() { return 0; }\n" ${feature}_works)
- if (${feature}_works)
- message(SEND_ERROR
- "Feature ${feature} expected not to work for ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}. Update the supported features or blacklist it.")
- endif()
- endforeach()
+if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+ AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+ list(REMOVE_ITEM CXX_non_features
+ cxx_alignof
+ )
endif()
+set(CXX_ext cpp)
+set(CXX_standard_flag 11)
+foreach(lang CXX)
+ if (CMAKE_${lang}_COMPILE_FEATURES)
+ foreach(feature ${${lang}_non_features})
+ message("Testing feature : ${feature}")
+ try_compile(${feature}_works
+ "${CMAKE_CURRENT_BINARY_DIR}/${feature}_test"
+ "${CMAKE_CURRENT_SOURCE_DIR}/feature_test.${${lang}_ext}"
+ COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.${${lang}_ext}"
+ CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD=${${lang}_standard_flag}"
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if (${feature}_works)
+ message(SEND_ERROR
+ "Feature ${feature} expected not to work for ${lang} ${CMAKE_${lang}_COMPILER_ID}-${CMAKE_${lang}_COMPILER_VERSION}.
+ Update the supported features or blacklist it.\n${OUTPUT}")
+ else()
+ message("Testing feature : ${feature} -- Fails, as expected.")
+ endif()
+ endforeach()
+ endif()
+endforeach()
+
add_executable(CompileFeatures main.cpp)
set_property(TARGET CompileFeatures
PROPERTY COMPILE_FEATURES "cxx_auto_type"
diff --git a/Tests/CompileFeatures/feature_test.cpp b/Tests/CompileFeatures/feature_test.cpp
new file mode 100644
index 0000000..4406c16
--- /dev/null
+++ b/Tests/CompileFeatures/feature_test.cpp
@@ -0,0 +1,10 @@
+
+#define STRINGIFY_IMPL(X) #X
+#define STRINGIFY(X) STRINGIFY_IMPL(X)
+
+#include STRINGIFY(TEST)
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
index f083751..bb4e0f9 100644
--- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -10,11 +10,11 @@ run_cmake(NotAFeature_OriginDebug_target_compile_features)
run_cmake(generate_feature_list)
file(READ
- "${RunCMake_BINARY_DIR}/generate_feature_list-build/features.txt"
- FEATURES
+ "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
+ CXX_FEATURES
)
-if (NOT FEATURES)
+if (NOT CXX_FEATURES)
run_cmake(NoSupportedCxxFeatures)
run_cmake(NoSupportedCxxFeaturesGenex)
endif()
diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
index 06c4f73..beb15fc 100644
--- a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
+++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
@@ -1,5 +1,5 @@
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/features.txt"
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt"
"${CMAKE_CXX_COMPILE_FEATURES}"
)