diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-03-05 20:25:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-09 12:44:56 (GMT) |
commit | 613ac56e508be666e2b6fcf42a6502055bf0764c (patch) | |
tree | e36e4f5a273e633f605991a5a9469bcbe108917e | |
parent | b0f46c48f6e3efc0481d7c573f67cc76dfa5b2fd (diff) | |
download | CMake-613ac56e508be666e2b6fcf42a6502055bf0764c.zip CMake-613ac56e508be666e2b6fcf42a6502055bf0764c.tar.gz CMake-613ac56e508be666e2b6fcf42a6502055bf0764c.tar.bz2 |
Add a test to verify meta-feature parity with granular features
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/C.cmake | 27 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/CXX.cmake | 27 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/a.c | 0 | ||||
-rw-r--r-- | Tests/RunCMake/MetaCompileFeatures/a.cxx | 0 |
7 files changed, 64 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index afa8df7..68411d6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -192,6 +192,9 @@ add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + add_RunCMake_test(MetaCompileFeatures) +endif() add_RunCMake_test(ObjectLibrary) add_RunCMake_test(ParseImplicitIncludeInfo) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") diff --git a/Tests/RunCMake/MetaCompileFeatures/C.cmake b/Tests/RunCMake/MetaCompileFeatures/C.cmake new file mode 100644 index 0000000..3bb6181 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/C.cmake @@ -0,0 +1,27 @@ + +enable_language(C) + +function(check_language_feature_flags lang level) + if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION) + #this property is an internal implementation detail of CMake + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(LENGTH known_features len) + if(len LESS 1) + message(FATAL_ERROR "unable to find known features of ${lang}${level}") + endif() + + string(TOLOWER ${lang} lang_lower) + set(known_name ${lang_lower}${level}_known_features) + set(meta_name ${lang_lower}${level}_meta_feature) + + add_library(${known_name} STATIC a.c) + target_compile_features(${known_name} PUBLIC ${known_features}) + add_library(${meta_name} STATIC a.c) + target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level}) + endif() +endfunction() + + +check_language_feature_flags(C 90) +check_language_feature_flags(C 99) +check_language_feature_flags(C 11) diff --git a/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MetaCompileFeatures/CXX.cmake b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake new file mode 100644 index 0000000..ef3b9d4 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake @@ -0,0 +1,27 @@ + +enable_language(CXX) + +function(check_language_feature_flags lang level) + if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION) + #this property is an internal implementation detail of CMake + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(LENGTH known_features len) + if(len LESS 1) + message(FATAL_ERROR "unable to find known features of ${lang}${level}") + endif() + + string(TOLOWER ${lang} lang_lower) + set(known_name ${lang_lower}${level}_known_features) + set(meta_name ${lang_lower}${level}_meta_feature) + + add_library(${known_name} STATIC a.cxx) + target_compile_features(${known_name} PUBLIC ${known_features}) + add_library(${meta_name} STATIC a.cxx) + target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level}) + endif() +endfunction() + + +check_language_feature_flags(CXX 98) +check_language_feature_flags(CXX 11) +check_language_feature_flags(CXX 14) diff --git a/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake new file mode 100644 index 0000000..009cde4 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(C) +run_cmake(CXX) diff --git a/Tests/RunCMake/MetaCompileFeatures/a.c b/Tests/RunCMake/MetaCompileFeatures/a.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/a.c diff --git a/Tests/RunCMake/MetaCompileFeatures/a.cxx b/Tests/RunCMake/MetaCompileFeatures/a.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/a.cxx |