Commit ef077c8b authored by Brad King's avatar Brad King
Browse files

Merge branch 'fix-crash-trace-exp-uninit-vars' into release-3.11

Merge-request: !1944
parents 1c857427 aad360eb
...@@ -101,10 +101,11 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) ...@@ -101,10 +101,11 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
// not been "cleared"/initialized with a set(foo ) call // not been "cleared"/initialized with a set(foo ) call
if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) { if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
if (this->CheckSystemVars || if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(this->FileName, (this->FileName &&
this->Makefile->GetHomeDirectory()) || (cmSystemTools::IsSubDirectory(
cmSystemTools::IsSubDirectory( this->FileName, this->Makefile->GetHomeDirectory()) ||
this->FileName, this->Makefile->GetHomeOutputDirectory())) { cmSystemTools::IsSubDirectory(
this->FileName, this->Makefile->GetHomeOutputDirectory())))) {
std::ostringstream msg; std::ostringstream msg;
msg << "uninitialized variable \'" << var << "\'"; msg << "uninitialized variable \'" << var << "\'";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
......
...@@ -2679,10 +2679,11 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( ...@@ -2679,10 +2679,11 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (this->GetCMakeInstance()->GetWarnUninitialized() && if (this->GetCMakeInstance()->GetWarnUninitialized() &&
!this->VariableInitialized(lookup)) { !this->VariableInitialized(lookup)) {
if (this->CheckSystemVars || if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(filename, (filename &&
this->GetHomeDirectory()) || (cmSystemTools::IsSubDirectory(filename,
cmSystemTools::IsSubDirectory( this->GetHomeDirectory()) ||
filename, this->GetHomeOutputDirectory())) { cmSystemTools::IsSubDirectory(
filename, this->GetHomeOutputDirectory())))) {
std::ostringstream msg; std::ostringstream msg;
msg << "uninitialized variable \'" << lookup << "\'"; msg << "uninitialized variable \'" << lookup << "\'";
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
......
...@@ -294,6 +294,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand) ...@@ -294,6 +294,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand)
run_cmake(trace-expand) run_cmake(trace-expand)
unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
run_cmake(trace-expand-warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake) set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake)
run_cmake(trace-source) run_cmake(trace-source)
unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OPTIONS)
......
^.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.0 \)
.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(2\): project\(trace-expand-warn-uninitialized NONE \)
cmake_policy(SET CMP0053 OLD)
message(STATUS "'${uninitialized_variable}'")
cmake_policy(SET CMP0053 NEW)
message(STATUS "'${uninitialized_variable}'")
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