diff options
author | Raul Tambre <raul@tambre.ee> | 2021-08-12 14:53:29 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2021-09-28 18:24:53 (GMT) |
commit | 29e2b8517126389b2c4b2f3479c4634a8260bea3 (patch) | |
tree | f33d4f995a58a643a117d0c068cbe105dea48230 | |
parent | fc3a1cbdd81f350b897c6cd06d75e8e228514773 (diff) | |
download | CMake-29e2b8517126389b2c4b2f3479c4634a8260bea3.zip CMake-29e2b8517126389b2c4b2f3479c4634a8260bea3.tar.gz CMake-29e2b8517126389b2c4b2f3479c4634a8260bea3.tar.bz2 |
Tests: Simplify RunCMake.CompileFeatures introspection
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/compiler_introspection.cmake | 20 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/generate_feature_list.cmake | 43 |
4 files changed, 24 insertions, 60 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index eb2c2d9..af6cbb5 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -310,7 +310,7 @@ add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) -add_RunCMake_test(CompileFeatures) +add_RunCMake_test(CompileFeatures -DCMake_NO_C_STANDARD=${CMake_NO_C_STANDARD} -DCMake_NO_CXX_STANDARD=${CMake_NO_CXX_STANDARD}) add_RunCMake_test(Policy) add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteBasicConfigVersionFile) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 5a70da2..934d8ca 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -9,17 +9,8 @@ run_cmake(NotAFeature_OriginDebugGenex) run_cmake(NotAFeature_OriginDebugTransitive) run_cmake(NotAFeature_OriginDebugCommand) -run_cmake(generate_feature_list) -file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/c_features.txt" - C_FEATURES -) -file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt" - CXX_FEATURES -) -include("${RunCMake_BINARY_DIR}/generate_feature_list-build/c_standard_default.cmake") -include("${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_standard_default.cmake") +run_cmake(compiler_introspection) +include("${RunCMake_BINARY_DIR}/compiler_introspection-build/info.cmake") if (NOT C_FEATURES) run_cmake(NoSupportedCFeatures) @@ -47,15 +38,11 @@ if(CXX_STANDARD_DEFAULT) run_cmake(NotAStandard) foreach(standard 98 11) - file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt" - CXX${standard}_FLAG - ) if (CXX${standard}_FLAG STREQUAL NOTFOUND) run_cmake(RequireCXX${standard}) run_cmake(RequireCXX${standard}Variable) endif() - if (CXX${standard}EXT_FLAG STREQUAL NOTFOUND) + if (CXX${standard}_EXT_FLAG STREQUAL NOTFOUND) run_cmake(RequireCXX${standard}Ext) run_cmake(RequireCXX${standard}ExtVariable) endif() diff --git a/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake new file mode 100644 index 0000000..c42324b --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake @@ -0,0 +1,20 @@ +enable_language(C CXX) + +macro(info lang) + string(APPEND info "\ +set(${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_DEFAULT}) +set(${lang}_EXTENSIONS_DEFAULT ${CMAKE_${lang}_EXTENSIONS_DEFAULT}) +set(${lang}_FEATURES ${CMAKE_${lang}_COMPILE_FEATURES}) +") + + foreach(standard ${ARGN}) + string(APPEND info "\ +set(${lang}${standard}_FLAG ${CMAKE_${lang}${standard}_STANDARD_COMPILE_OPTION}) +set(${lang}${standard}_EXT_FLAG ${CMAKE_${lang}${standard}_EXTENSION_COMPILE_OPTION}) +") + endforeach() +endmacro() + +info(C 90 99 11 17 23) +info(CXX 98 11 14 17 20 23) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake deleted file mode 100644 index 5c58052..0000000 --- a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake +++ /dev/null @@ -1,43 +0,0 @@ - -enable_language(C) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_features.txt" - "${CMAKE_C_COMPILE_FEATURES}" -) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt" - "${CMAKE_CXX_COMPILE_FEATURES}" -) - -if(DEFINED CMAKE_C_STANDARD_DEFAULT) - set(c_standard_default_code "set(C_STANDARD_DEFAULT \"${CMAKE_C_STANDARD_DEFAULT}\")\n") -else() - set(c_standard_default_code "unset(C_STANDARD_DEFAULT)\n") -endif() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_standard_default.cmake" "${c_standard_default_code}") - -if(DEFINED CMAKE_CXX_STANDARD_DEFAULT) - set(cxx_standard_default_code "set(CXX_STANDARD_DEFAULT \"${CMAKE_CXX_STANDARD_DEFAULT}\")\n") -else() - set(cxx_standard_default_code "unset(CXX_STANDARD_DEFAULT)\n") -endif() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_standard_default.cmake" "${cxx_standard_default_code}") - -foreach(standard 98 11) - set(CXX${standard}_FLAG NOTFOUND) - if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION) - set(CXX${standard}_FLAG ${CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION}) - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}_flag.txt" - "${CXX${standard}_FLAG}" - ) - set(CXX${standard}EXT_FLAG NOTFOUND) - if (DEFINED CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION) - set(CXX${standard}EXT_FLAG ${CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION}) - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}ext_flag.txt" - "${CXX${standard}EXT_FLAG}" - ) -endforeach() |