summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-04-02 13:34:16 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-07 16:11:18 (GMT)
commitf97bf4370c283432c4e14fe54ed481d5d9b7ceef (patch)
tree6964c99045b0345b32e45ad1bb374fc75c2a6292 /Tests
parent03355d6b5b382020e7dafb28605e6d8d2f20de3c (diff)
downloadCMake-f97bf4370c283432c4e14fe54ed481d5d9b7ceef.zip
CMake-f97bf4370c283432c4e14fe54ed481d5d9b7ceef.tar.gz
CMake-f97bf4370c283432c4e14fe54ed481d5d9b7ceef.tar.bz2
Features: Add cxx_auto_type.
Record the availability of this feature for GNU 4.8 on (UNIX AND NOT APPLE) only. In the future, availability can be recorded for earlier GNU, for other platforms and for other compilers. Initially the affected configurations are as restricted as possible to allow for easy testing while extending the features vector in only one dimension. The error message when using the set_property API directly is not very good, but follow up commits will provide origin debugging of the property and a target_compile_features command which will provide a configure-time backtrace when possible.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt24
-rw-r--r--Tests/CompileFeatures/cxx_auto_type.cpp5
-rw-r--r--Tests/CompileFeatures/main.cpp6
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt2
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/empty.cpp7
-rw-r--r--Tests/SystemInformation/SystemInformation.in2
12 files changed, 61 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index aaa24c7..fc58f1e 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -197,6 +197,10 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(TarTest TarTest)
ADD_TEST_MACRO(SystemInformation SystemInformation)
ADD_TEST_MACRO(MathTest MathTest)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+ ADD_TEST_MACRO(CompileFeatures CompileFeatures)
+ endif()
# assume no resources building to test
set(TEST_RESOURCES FALSE)
# for windows and cygwin assume we have resources
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..471b560
--- /dev/null
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(CompileFeatures)
+
+macro(run_test feature)
+ if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature})
+ add_library(test_${feature} OBJECT ${feature}.cpp)
+ set_property(TARGET test_${feature}
+ PROPERTY COMPILE_FEATURES "${feature}"
+ )
+ else()
+ message("Not supported: ${feature}")
+ endif()
+endmacro()
+
+foreach(feature ${CMAKE_CXX_KNOWN_FEATURES})
+ run_test(${feature})
+endforeach()
+
+add_executable(CompileFeatures main.cpp)
+set_property(TARGET CompileFeatures
+ PROPERTY COMPILE_FEATURES "cxx_auto_type"
+)
diff --git a/Tests/CompileFeatures/cxx_auto_type.cpp b/Tests/CompileFeatures/cxx_auto_type.cpp
new file mode 100644
index 0000000..7dbf04f
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_auto_type.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+ auto x = 3.14;
+}
diff --git a/Tests/CompileFeatures/main.cpp b/Tests/CompileFeatures/main.cpp
new file mode 100644
index 0000000..3a8e0fc
--- /dev/null
+++ b/Tests/CompileFeatures/main.cpp
@@ -0,0 +1,6 @@
+
+int main(int,char**)
+{
+ auto value = 0;
+ return value;
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 851de42..dd769ac 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -53,6 +53,7 @@ add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetSources)
add_RunCMake_test(find_dependency)
+add_RunCMake_test(CompileFeatures)
if(NOT WIN32)
add_RunCMake_test(PositionIndependentCode)
set(SKIP_VISIBILITY 0)
diff --git a/Tests/RunCMake/CompileFeatures/CMakeLists.txt b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
new file mode 100644
index 0000000..35246c8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
@@ -0,0 +1,3 @@
+
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature")
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
new file mode 100644
index 0000000..3c999e6
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(NotAFeature)
diff --git a/Tests/RunCMake/CompileFeatures/empty.cpp b/Tests/RunCMake/CompileFeatures/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in
index 92b24e2..954a2fe 100644
--- a/Tests/SystemInformation/SystemInformation.in
+++ b/Tests/SystemInformation/SystemInformation.in
@@ -25,6 +25,8 @@ CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}"
CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}"
CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}"
CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}"
+CMAKE_CXX_COMPILE_FEATURES == "${CMAKE_CXX_COMPILE_FEATURES}"
+CMAKE_CXX11_COMPILE_FEATURES == "${CMAKE_CXX11_COMPILE_FEATURES}"
// C shared library flag
CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}"