summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-02-21 21:00:24 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-23 14:15:14 (GMT)
commitdf9c4b18720c6c8263c13641bc0a6452138d6fba (patch)
tree4301ddaee071056517ef6a0964d34e2627738987 /Source/cmMakefile.cxx
parent4da27a73bd10665e753194a4a14323c9069e9289 (diff)
downloadCMake-df9c4b18720c6c8263c13641bc0a6452138d6fba.zip
CMake-df9c4b18720c6c8263c13641bc0a6452138d6fba.tar.gz
CMake-df9c4b18720c6c8263c13641bc0a6452138d6fba.tar.bz2
find_package: Use <PACKAGENAME>_ROOT variables as search prefixes
Extend commit eb35d8884b (find_package: Use PackageName_ROOT variables as search prefixes, 2018-03-15, v3.12.0-rc1~349^2) to also check upper-case `<PACKAGENAME>_ROOT` variables. Add policy `CMP0144` to enable the behavior in a compatible way. Fixes: #24403
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index b640d64..2fc2974 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -228,6 +228,27 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& rootVar, cmValue rootDef,
}
}
+void cmMakefile::MaybeWarnCMP0144(std::string const& rootVAR, cmValue rootDEF,
+ cm::optional<std::string> const& rootENV)
+{
+ // Warn if a <PACKAGENAME>_ROOT variable we may use is set.
+ if ((rootDEF || rootENV) && this->WarnedCMP0144.insert(rootVAR).second) {
+ std::ostringstream w;
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0144) << "\n";
+ if (rootDEF) {
+ w << "CMake variable " << rootVAR << " is set to:\n"
+ << " " << *rootDEF << "\n";
+ }
+ if (rootENV) {
+ w << "Environment variable " << rootVAR << " is set to:\n"
+ << " " << *rootENV << "\n";
+ }
+ w << "For compatibility, find_package is ignoring the variable, but "
+ "code in a .cmake module might still use it.";
+ this->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ }
+}
+
cmBTStringRange cmMakefile::GetIncludeDirectoriesEntries() const
{
return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries();