diff options
author | Raul Tambre <raul@tambre.ee> | 2022-01-22 15:29:45 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2022-01-23 21:10:28 (GMT) |
commit | ee1396e29e98dbd3a4517ce364a534c80bc6fb4a (patch) | |
tree | 4733f62457243d208594a854e42ec0f5e1424943 /Tests | |
parent | b2c25de8e0e2d53d3ff2ad37ed33d4b8a9bf8b1a (diff) | |
download | CMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.zip CMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.tar.gz CMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.tar.bz2 |
CMP0128: Add flag in OLD mode even when standard matches the default
Commit 4a0485be (cmStandardLevelResolver: Avoid unnecessary flags, fix unset
level logic, 2021-04-29) unintentionally changed the behavior by modifying the
code to match a pre-existing comment. The resulting behavior change however
matches the intentions of CMP0128, so we simply need to guard it.
Fixes #23122.
Diffstat (limited to 'Tests')
3 files changed, 31 insertions, 0 deletions
diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake new file mode 100644 index 0000000..8074b9d --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-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.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake new file mode 100644 index 0000000..3be0f10 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake @@ -0,0 +1 @@ +set(CMAKE_@lang@_STANDARD @standard_default@) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 35b01e3..ad9619e 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -70,6 +70,23 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() +function(test_cmp0128_old_same_standard) + if(extensions_default) + set(flag_ext "_EXT") + endif() + + set(flag "${${lang}${${lang}_STANDARD_DEFAULT}${flag_ext}_FLAG}") + + if(NOT flag) + return() + endif() + + mangle_flags(flag) + + set(name CMP0128OldSameStandard) + test_build(--verbose) +endfunction() + function(test_cmp0128_new_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") @@ -148,6 +165,7 @@ function(test_lang lang ext) test_cmp0128_new_extensions_opposite() test_cmp0128_new_no_unnecessary_flag() + test_cmp0128_old_same_standard() test_cmp0128_warn_match() test_cmp0128_warn_unset() endfunction() |