diff options
author | Brad King <brad.king@kitware.com> | 2018-03-22 12:32:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-03-22 12:32:54 (GMT) |
commit | a7ac0224250850e0e0f6ed3eff1bbbbabcd5d740 (patch) | |
tree | ab5d6823c58cfa32eb0d913377f8fbddb0c7835f | |
parent | 9b3d3952a8a0371504d120ed73444bfc52ae7f79 (diff) | |
parent | 3f479a3ca30543a0d61ebf28d4934c401ffdaa55 (diff) | |
download | CMake-a7ac0224250850e0e0f6ed3eff1bbbbabcd5d740.zip CMake-a7ac0224250850e0e0f6ed3eff1bbbbabcd5d740.tar.gz CMake-a7ac0224250850e0e0f6ed3eff1bbbbabcd5d740.tar.bz2 |
Merge topic 'find-package_root-revise'
3f479a3ca3 find_package: Improve CMP0074 warning messages
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1880
-rw-r--r-- | Source/cmMakefile.cxx | 14 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt | 8 |
2 files changed, 16 insertions, 6 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()); diff --git a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt index c762d92..27fbb86 100644 --- a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt +++ b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt @@ -7,9 +7,13 @@ CMake Warning \(dev\) at CMP0074-common.cmake:[0-9]+ \(find_package\): Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - CMake variable Foo_ROOT is set. + CMake variable Foo_ROOT is set to: - Environment variable Foo_ROOT is set. + .*/Tests/RunCMake/find_package/PackageRoot/foo/cmake_root + + Environment variable Foo_ROOT is set to: + + .*/Tests/RunCMake/find_package/PackageRoot/foo/env_root For compatibility, CMake is ignoring the variable. Call Stack \(most recent call first\): |