diff options
author | Brad King <brad.king@kitware.com> | 2018-03-21 11:44:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-21 11:51:20 (GMT) |
commit | 3f479a3ca30543a0d61ebf28d4934c401ffdaa55 (patch) | |
tree | 96e12d92a085756f525ebeea28d305b1e9b35e74 /Source | |
parent | 1c3bbda2f2920f416304086ece139ba1b50015ea (diff) | |
download | CMake-3f479a3ca30543a0d61ebf28d4934c401ffdaa55.zip CMake-3f479a3ca30543a0d61ebf28d4934c401ffdaa55.tar.gz CMake-3f479a3ca30543a0d61ebf28d4934c401ffdaa55.tar.bz2 |
find_package: Improve CMP0074 warning messages
Policy `CMP0074` was added by commit eb35d8884b (find_package: Use
PackageName_ROOT variables as search prefixes, 2018-03-15). Revise the
logic to avoid warning when a `PackageName_ROOT` variable is set to
empty since that won't change the search behavior. Also, when we do
warn include the variable value(s) for reference.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1191490..5850f94 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -162,16 +162,22 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) { // Warn if a <pkg>_ROOT variable we may use is set. std::string const varName = pkg + "_ROOT"; - bool const haveVar = this->GetDefinition(varName) != nullptr; - bool const haveEnv = cmSystemTools::HasEnv(varName); + const char* var = this->GetDefinition(varName); + std::string env; + cmSystemTools::GetEnv(varName, env); + + bool const haveVar = var && *var; + bool const haveEnv = !env.empty(); if ((haveVar || haveEnv) && this->WarnedCMP0074.insert(varName).second) { std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0074) << "\n"; if (haveVar) { - w << "CMake variable " << varName << " is set.\n"; + w << "CMake variable " << varName << " is set to:\n" + << " " << var << "\n"; } if (haveEnv) { - w << "Environment variable " << varName << " is set.\n"; + w << "Environment variable " << varName << " is set to:\n" + << " " << env << "\n"; } w << "For compatibility, CMake is ignoring the variable."; this->IssueMessage(cmake::AUTHOR_WARNING, w.str()); |