diff options
author | Raul Tambre <raul@tambre.ee> | 2021-11-09 18:34:06 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2021-11-11 19:55:04 (GMT) |
commit | e47dfce75d74de26ac6ee25625a44989312e29c1 (patch) | |
tree | b0e802226f6ac38f6f0e3992719f6807355e6577 /Tests | |
parent | 2ad300ebd73c6aca7189a9f8ea8d8ad61e9c3223 (diff) | |
download | CMake-e47dfce75d74de26ac6ee25625a44989312e29c1.zip CMake-e47dfce75d74de26ac6ee25625a44989312e29c1.tar.gz CMake-e47dfce75d74de26ac6ee25625a44989312e29c1.tar.bz2 |
CMP0128: Enable/disable extensions if standard same as default
This was intended to be part of the initial MR (!6177), but accidentally went
missing when debugging nightly failures on less common systems. Noticed during
!6711 review as the comment about this behaviour didn't match the code.
Documentation for CMP0128 is updated to remove a false case and note the two
cases related to this.
Fixes #22224.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake (renamed from Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake (renamed from Tests/RunCMake/CompileFeatures/UnsetStandard.cmake) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 16 |
5 files changed, 32 insertions, 5 deletions
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake new file mode 100644 index 0000000..4e85397 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake @@ -0,0 +1,12 @@ +foreach(flag @flags@) + string(FIND "${actual_stdout}" "${flag}" position) + + if(NOT position EQUAL -1) + set(found TRUE) + break() + endif() +endforeach() + +if(NOT found) + set(RunCMake_TEST_FAILED "No compile flags from \"@flags@\" found for LANG_STANDARD=default and @lang@_EXTENSIONS=@extensions_opposite@.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake new file mode 100644 index 0000000..32578d1 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake @@ -0,0 +1,9 @@ +enable_language(@lang@) + +# Make sure the compile command is not hidden. +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") + +set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) +set(CMAKE_@lang@_STANDARD @standard_default@) +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake index abe293c..abe293c 100644 --- a/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake index 99bb3f0..99bb3f0 100644 --- a/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 3bfd211..ebd981b 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -36,7 +36,7 @@ endif() configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY) -macro(test_build) +function(test_build) set(test ${name}-${lang}) configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY) @@ -52,7 +52,7 @@ macro(test_build) run_cmake(${test}) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(${test}-build ${CMAKE_COMMAND} --build . ${ARGN}) -endmacro() +endfunction() # Mangle flags such as they're in verbose build output. macro(mangle_flags variable) @@ -68,7 +68,7 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() -function(test_unset_standard) +function(test_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") endif() @@ -81,9 +81,15 @@ function(test_unset_standard) mangle_flags(flag) - set(name UnsetStandard) + # Make sure we enable/disable extensions when: + # 1. LANG_STANDARD is unset. + set(name ExtensionsStandardUnset) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) + + # 2. LANG_STANDARD matches CMAKE_LANG_STANDARD_DEFAULT. + set(name ExtensionsStandardDefault) + test_build(--verbose) endfunction() function(test_no_unnecessary_flag) @@ -138,7 +144,7 @@ function(test_lang lang ext) set(extensions_opposite ON) endif() - test_unset_standard() + test_extensions_opposite() test_no_unnecessary_flag() test_cmp0128_warn_match() test_cmp0128_warn_unset() |