mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
Add a test to verify meta-feature parity with granular features
This commit is contained in:
committed by
Brad King
parent
b0f46c48f6
commit
613ac56e50
@@ -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")
|
||||
|
||||
27
Tests/RunCMake/MetaCompileFeatures/C.cmake
Normal file
27
Tests/RunCMake/MetaCompileFeatures/C.cmake
Normal file
@@ -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)
|
||||
3
Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt
Normal file
3
Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
27
Tests/RunCMake/MetaCompileFeatures/CXX.cmake
Normal file
27
Tests/RunCMake/MetaCompileFeatures/CXX.cmake
Normal file
@@ -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)
|
||||
4
Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake
Normal file
4
Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(C)
|
||||
run_cmake(CXX)
|
||||
0
Tests/RunCMake/MetaCompileFeatures/a.c
Normal file
0
Tests/RunCMake/MetaCompileFeatures/a.c
Normal file
0
Tests/RunCMake/MetaCompileFeatures/a.cxx
Normal file
0
Tests/RunCMake/MetaCompileFeatures/a.cxx
Normal file
Reference in New Issue
Block a user