summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2022-01-22 17:29:45 +0200
committerRaul Tambre <raul@tambre.ee>2022-01-23 23:10:28 +0200
commitee1396e29e98dbd3a4517ce364a534c80bc6fb4a (patch)
tree4733f62457243d208594a854e42ec0f5e1424943 /Tests
parentb2c25de8e0e2d53d3ff2ad37ed33d4b8a9bf8b1a (diff)
downloadcmake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.tar.gz
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')
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake12
-rw-r--r--Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake1
-rw-r--r--Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake18
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 0000000000..8074b9d3ca
--- /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 0000000000..3be0f10b29
--- /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 35b01e31c8..ad9619e9fe 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()