[Cmake-commits] CMake branch, master, updated. v3.13.2-816-g5b7eb38
Kitware Robot
kwrobot at kitware.com
Mon Jan 7 15:43:04 EST 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via 5b7eb38e8e4711433ba83b22a6a74efd1c6e2de1 (commit)
via cbf0c0fce4dfe23912f7cc012c6f0234a5fd694b (commit)
via 1d32a35c10b384e8eb0dd2ce68c7bd11424409ac (commit)
via 67ac4ed1dc5ad049ab443ce76a3f93b207703cec (commit)
via 5257af363442aa4168776b70db1fc58d218a20c8 (commit)
from 6f904d01009bf26d129b2a2f0335e99bf30732ac (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b7eb38e8e4711433ba83b22a6a74efd1c6e2de1
commit 5b7eb38e8e4711433ba83b22a6a74efd1c6e2de1
Merge: 6f904d0 cbf0c0f
Author: Craig Scott <craig.scott at crascit.com>
AuthorDate: Mon Jan 7 20:33:41 2019 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Jan 7 15:33:52 2019 -0500
Merge topic 'fix-warn-uninitialized-in-configure'
cbf0c0fce4 cmake: Enable --warn-uninitialized inside string(CONFIGURE) and configure_file
1d32a35c10 cmCommandArgumentParserHelper: use cmMakefile::MaybeWarnUninitialized
67ac4ed1dc cmMakefile: Move uninitialized vars logic into MaybeWarnUninitialized()
5257af3634 cmMakefile: move common logic to IsProjectFile function
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !2676
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cbf0c0fce4dfe23912f7cc012c6f0234a5fd694b
commit cbf0c0fce4dfe23912f7cc012c6f0234a5fd694b
Author: Artur Ryt <artur.ryt at gmail.com>
AuthorDate: Thu Dec 13 20:45:17 2018 +0100
Commit: Craig Scott <craig.scott at crascit.com>
CommitDate: Sun Dec 30 08:31:09 2018 +1100
cmake: Enable --warn-uninitialized inside string(CONFIGURE) and configure_file
Fixes: #18489
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index f94dc24..ca29967 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -92,9 +92,11 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
return this->AddString(ostr.str());
}
const char* value = this->Makefile->GetDefinition(var);
- if (!value && !this->RemoveEmpty) {
+ if (!value) {
this->Makefile->MaybeWarnUninitialized(var, this->FileName);
- return nullptr;
+ if (!this->RemoveEmpty) {
+ return nullptr;
+ }
}
if (this->EscapeQuotes && value) {
return this->AddString(cmSystemTools::EscapeQuotes(value));
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 256202c..68a5101 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2522,9 +2522,9 @@ const std::string& cmMakefile::ExpandVariablesInString(
// Suppress variable watches to avoid calling hooks twice. Suppress new
// dereferences since the OLD behavior is still what is actually used.
this->SuppressSideEffects = true;
- newError = ExpandVariablesInStringNew(
- newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename,
- line, removeEmpty, replaceAt);
+ newError = ExpandVariablesInStringNew(newErrorstr, newResult,
+ escapeQuotes, noEscapes, atOnly,
+ filename, line, replaceAt);
this->SuppressSideEffects = false;
CM_FALLTHROUGH;
}
@@ -2537,9 +2537,9 @@ const std::string& cmMakefile::ExpandVariablesInString(
case cmPolicies::REQUIRED_ALWAYS:
// Messaging here would be *very* verbose.
case cmPolicies::NEW:
- mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
- noEscapes, atOnly, filename, line,
- removeEmpty, replaceAt);
+ mtype =
+ ExpandVariablesInStringNew(errorstr, source, escapeQuotes, noEscapes,
+ atOnly, filename, line, replaceAt);
break;
}
@@ -2726,7 +2726,7 @@ bool cmMakefile::IsProjectFile(const char* filename) const
cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
std::string& errorstr, std::string& source, bool escapeQuotes,
bool noEscapes, bool atOnly, const char* filename, long line,
- bool removeEmpty, bool replaceAt) const
+ bool replaceAt) const
{
// This method replaces ${VAR} and @VAR@ where VAR is looked up
// with GetDefinition(), if not found in the map, nothing is expanded.
@@ -2783,7 +2783,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
} else {
varresult = value;
}
- } else if (!removeEmpty && !this->SuppressSideEffects) {
+ } else if (!this->SuppressSideEffects) {
this->MaybeWarnUninitialized(lookup, filename);
}
result.replace(var.loc, result.size() - var.loc, varresult);
@@ -2896,7 +2896,12 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (filename && variable == lineVar) {
varresult = std::to_string(line);
} else {
- varresult = this->GetSafeDefinition(variable);
+ const std::string* def = this->GetDef(variable);
+ if (def) {
+ varresult = *def;
+ } else if (!this->SuppressSideEffects) {
+ this->MaybeWarnUninitialized(variable, filename);
+ }
}
if (escapeQuotes) {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 1a2a0e7..1607735 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -990,7 +990,7 @@ private:
cmake::MessageType ExpandVariablesInStringNew(
std::string& errorstr, std::string& source, bool escapeQuotes,
bool noEscapes, bool atOnly, const char* filename, long line,
- bool removeEmpty, bool replaceAt) const;
+ bool replaceAt) const;
/**
* Old version of GetSourceFileWithOutput(const std::string&) kept for
* backward-compatibility. It implements a linear search and support
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index a37b7f1..4cd34de 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -350,7 +350,7 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
run_cmake(trace-expand-warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
-set(RunCMake_TEST_OPTIONS --warn-uninitialized)
+set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized)
run_cmake(warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
index a13402a..41ba098 100644
--- a/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
+++ b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
@@ -1,5 +1,53 @@
-^CMake Warning \(dev\) at warn-uninitialized.cmake:1 \(set\):
- uninitialized variable 'WARN_FROM_NORMAL_CMAKE_FILE'
+^CMake Warning \(dev\) at warn-uninitialized.cmake:3 \(set\):
+ uninitialized variable 'OLD_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:4 \(set\):
+ uninitialized variable 'OLD_WARN_FROM_NORMAL_CMAKE_FILE_IN_ATS'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:5 \(string\):
+ uninitialized variable 'OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:7 \(configure_file\):
+ uninitialized variable 'OLD_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:8 \(string\):
+ uninitialized variable 'OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:13 \(set\):
+ uninitialized variable 'NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:14 \(string\):
+ uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:16 \(configure_file\):
+ uninitialized variable 'NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:17 \(string\):
+ uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized.cmake b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake
index f1a75c9..ff65c16 100644
--- a/Tests/RunCMake/CommandLine/warn-uninitialized.cmake
+++ b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake
@@ -1 +1,18 @@
-set(FOO "${WARN_FROM_NORMAL_CMAKE_FILE}")
+cmake_policy(PUSH)
+cmake_policy(SET CMP0053 OLD)
+set(FOO "${OLD_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES}")
+set(FOO "@OLD_WARN_FROM_NORMAL_CMAKE_FILE_IN_ATS@")
+string(CONFIGURE "\${OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES}" OUT1)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file1.in "\@OLD_WARN_FROM_CONFIGURE_FILE_INSIDE_AT\@")
+configure_file(${CMAKE_CURRENT_BINARY_DIR}/file1.in file1.out)
+string(CONFIGURE "\@OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_AT\@" OUT2)
+cmake_policy(POP)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0053 NEW)
+set(FOO "${NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES}")
+string(CONFIGURE "\${NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES}" OUT3)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file2.in "\@NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT\@")
+configure_file(${CMAKE_CURRENT_BINARY_DIR}/file2.in file2.out)
+string(CONFIGURE "@NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT@" OUT4)
+cmake_policy(POP)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d32a35c10b384e8eb0dd2ce68c7bd11424409ac
commit 1d32a35c10b384e8eb0dd2ce68c7bd11424409ac
Author: Artur Ryt <artur.ryt at gmail.com>
AuthorDate: Thu Dec 13 20:45:15 2018 +0100
Commit: Craig Scott <craig.scott at crascit.com>
CommitDate: Sun Dec 30 08:31:09 2018 +1100
cmCommandArgumentParserHelper: use cmMakefile::MaybeWarnUninitialized
It removes logic duplication and need to have cached
WarnUninitialized and CheckSystemVars
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 2b4ceaa..f94dc24 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -6,7 +6,6 @@
#include "cmMakefile.h"
#include "cmState.h"
#include "cmSystemTools.h"
-#include "cmake.h"
#include <iostream>
#include <sstream>
@@ -16,8 +15,6 @@ int cmCommandArgument_yyparse(yyscan_t yyscanner);
//
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
- this->WarnUninitialized = false;
- this->CheckSystemVars = false;
this->FileLine = -1;
this->FileName = nullptr;
this->RemoveEmpty = true;
@@ -96,21 +93,7 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
}
const char* value = this->Makefile->GetDefinition(var);
if (!value && !this->RemoveEmpty) {
- // 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
- if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
- if (this->CheckSystemVars ||
- (this->FileName &&
- (cmSystemTools::IsSubDirectory(
- this->FileName, this->Makefile->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(
- this->FileName, this->Makefile->GetHomeOutputDirectory())))) {
- std::ostringstream msg;
- msg << "uninitialized variable \'" << var << "\'";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
- }
- }
+ this->Makefile->MaybeWarnUninitialized(var, this->FileName);
return nullptr;
}
if (this->EscapeQuotes && value) {
@@ -286,8 +269,6 @@ void cmCommandArgumentParserHelper::Error(const char* str)
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
{
this->Makefile = mf;
- this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized();
- this->CheckSystemVars = mf->GetCMakeInstance()->GetCheckSystemVars();
}
void cmCommandArgumentParserHelper::SetResult(const char* value)
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 098c000..4dc238e 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -75,8 +75,6 @@ private:
long FileLine;
int CurrentLine;
int Verbose;
- bool WarnUninitialized;
- bool CheckSystemVars;
bool EscapeQuotes;
bool NoEscapeMode;
bool ReplaceAtSyntax;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67ac4ed1dc5ad049ab443ce76a3f93b207703cec
commit 67ac4ed1dc5ad049ab443ce76a3f93b207703cec
Author: Artur Ryt <artur.ryt at gmail.com>
AuthorDate: Thu Dec 13 20:45:11 2018 +0100
Commit: Artur Ryt <artur.ryt at gmail.com>
CommitDate: Fri Dec 28 15:16:37 2018 +0100
cmMakefile: Move uninitialized vars logic into MaybeWarnUninitialized()
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index bbbe300..256202c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1837,6 +1837,23 @@ bool cmMakefile::VariableInitialized(const std::string& var) const
return this->StateSnapshot.IsInitialized(var);
}
+void cmMakefile::MaybeWarnUninitialized(std::string const& variable,
+ const char* sourceFilename) const
+{
+ // 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
+ if (this->GetCMakeInstance()->GetWarnUninitialized() &&
+ !this->VariableInitialized(variable)) {
+ if (this->CheckSystemVars ||
+ (sourceFilename && this->IsProjectFile(sourceFilename))) {
+ std::ostringstream msg;
+ msg << "uninitialized variable \'" << variable << "\'";
+ this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
+ }
+ }
+}
+
void cmMakefile::LogUnused(const char* reason, const std::string& name) const
{
if (this->WarnUnused) {
@@ -2767,18 +2784,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
varresult = value;
}
} 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
- if (this->GetCMakeInstance()->GetWarnUninitialized() &&
- !this->VariableInitialized(lookup)) {
- if (this->CheckSystemVars ||
- (filename && this->IsProjectFile(filename))) {
- std::ostringstream msg;
- msg << "uninitialized variable \'" << lookup << "\'";
- this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
- }
- }
+ this->MaybeWarnUninitialized(lookup, filename);
}
result.replace(var.loc, result.size() - var.loc, varresult);
// Start looking from here on out.
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index be1e6a1..1a2a0e7 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -866,6 +866,8 @@ public:
std::deque<std::vector<std::string>> FindPackageRootPathStack;
void MaybeWarnCMP0074(std::string const& pkg);
+ void MaybeWarnUninitialized(std::string const& variable,
+ const char* sourceFilename) const;
bool IsProjectFile(const char* filename) const;
protected:
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5257af363442aa4168776b70db1fc58d218a20c8
commit 5257af363442aa4168776b70db1fc58d218a20c8
Author: Artur Ryt <artur.ryt at gmail.com>
AuthorDate: Thu Dec 13 20:44:58 2018 +0100
Commit: Artur Ryt <artur.ryt at gmail.com>
CommitDate: Fri Dec 28 15:16:37 2018 +0100
cmMakefile: move common logic to IsProjectFile function
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d7c4f22..bbbe300 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1848,11 +1848,7 @@ void cmMakefile::LogUnused(const char* reason, const std::string& name) const
path += "/CMakeLists.txt";
}
- if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) ||
- (cmSystemTools::IsSubDirectory(path, this->GetHomeOutputDirectory()) &&
- !cmSystemTools::IsSubDirectory(path,
- cmake::GetCMakeFilesDirectory()))) {
+ if (this->CheckSystemVars || this->IsProjectFile(path.c_str())) {
std::ostringstream msg;
msg << "unused variable (" << reason << ") \'" << name << "\'";
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
@@ -2702,6 +2698,14 @@ struct t_lookup
size_t loc = 0;
};
+bool cmMakefile::IsProjectFile(const char* filename) const
+{
+ return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) ||
+ (cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) &&
+ !cmSystemTools::IsSubDirectory(filename,
+ cmake::GetCMakeFilesDirectory()));
+}
+
cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
std::string& errorstr, std::string& source, bool escapeQuotes,
bool noEscapes, bool atOnly, const char* filename, long line,
@@ -2769,11 +2773,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (this->GetCMakeInstance()->GetWarnUninitialized() &&
!this->VariableInitialized(lookup)) {
if (this->CheckSystemVars ||
- (filename &&
- (cmSystemTools::IsSubDirectory(filename,
- this->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(
- filename, this->GetHomeOutputDirectory())))) {
+ (filename && this->IsProjectFile(filename))) {
std::ostringstream msg;
msg << "uninitialized variable \'" << lookup << "\'";
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index aa94054..be1e6a1 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -866,6 +866,7 @@ public:
std::deque<std::vector<std::string>> FindPackageRootPathStack;
void MaybeWarnCMP0074(std::string const& pkg);
+ bool IsProjectFile(const char* filename) const;
protected:
// add link libraries and directories to the target
-----------------------------------------------------------------------
Summary of changes:
Source/cmCommandArgumentParserHelper.cxx | 25 ++------
Source/cmCommandArgumentParserHelper.h | 2 -
Source/cmMakefile.cxx | 71 +++++++++++++---------
Source/cmMakefile.h | 5 +-
Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 2 +-
.../CommandLine/warn-uninitialized-stderr.txt | 52 +++++++++++++++-
.../RunCMake/CommandLine/warn-uninitialized.cmake | 19 +++++-
7 files changed, 118 insertions(+), 58 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list