Commit 53a5aec8 authored by Artur Ryt's avatar Artur Ryt Committed by Brad King

CMP0053: Fix double warning on uninitialized variables in -P mode

When `CMP0053` is not set to OLD or NEW then we compute both variants
in case we need to warn about a behavior change.  Do not allow both
code paths to produce an uninitialized variable warning.

Fixes: #18552
parent f92f9346
......@@ -2766,7 +2766,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
} else {
varresult = value;
}
} else if (!removeEmpty) {
} else if (!removeEmpty && !this->SuppressSideEffects) {
// check to see if we need to print a warning
// if strict mode is on and the variable has
// not been "cleared"/initialized with a set(foo ) call
......
......@@ -348,6 +348,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
run_cmake(trace-expand-warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --warn-uninitialized)
run_cmake(warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake)
run_cmake(trace-source)
unset(RunCMake_TEST_OPTIONS)
......
^CMake Warning \(dev\) at warn-uninitialized.cmake:1 \(set\):
uninitialized variable 'WARN_FROM_NORMAL_CMAKE_FILE'
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$
set(FOO "${WARN_FROM_NORMAL_CMAKE_FILE}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment