|
@@ -1814,26 +1814,40 @@ void cmFindPackageCommand::PushFindPackageRootPathStack()
|
|
|
|
|
|
// Add root paths from <PackageName>_ROOT CMake and environment variables,
|
|
|
// subject to CMP0074.
|
|
|
+ std::string const rootVar = this->Name + "_ROOT";
|
|
|
+ cmValue rootDef = this->Makefile->GetDefinition(rootVar);
|
|
|
+ if (rootDef && rootDef.IsEmpty()) {
|
|
|
+ rootDef = nullptr;
|
|
|
+ }
|
|
|
+ cm::optional<std::string> rootEnv = cmSystemTools::GetEnvVar(rootVar);
|
|
|
+ if (rootEnv && rootEnv->empty()) {
|
|
|
+ rootEnv = cm::nullopt;
|
|
|
+ }
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0074)) {
|
|
|
case cmPolicies::WARN:
|
|
|
- this->Makefile->MaybeWarnCMP0074(this->Name);
|
|
|
+ this->Makefile->MaybeWarnCMP0074(rootVar, rootDef, rootEnv);
|
|
|
CM_FALLTHROUGH;
|
|
|
case cmPolicies::OLD:
|
|
|
- // OLD behavior is to ignore the <pkg>_ROOT variables.
|
|
|
- break;
|
|
|
+ // OLD behavior is to ignore the <PackageName>_ROOT variables.
|
|
|
+ return;
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
this->Makefile->IssueMessage(
|
|
|
MessageType::FATAL_ERROR,
|
|
|
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0074));
|
|
|
- break;
|
|
|
+ return;
|
|
|
case cmPolicies::NEW: {
|
|
|
- // NEW behavior is to honor the <pkg>_ROOT variables.
|
|
|
- std::string const rootVar = this->Name + "_ROOT";
|
|
|
- this->Makefile->GetDefExpandList(rootVar, rootPaths, false);
|
|
|
- cmSystemTools::GetPath(rootPaths, rootVar.c_str());
|
|
|
+ // NEW behavior is to honor the <PackageName>_ROOT variables.
|
|
|
} break;
|
|
|
}
|
|
|
+
|
|
|
+ if (rootDef) {
|
|
|
+ cmExpandList(*rootDef, rootPaths);
|
|
|
+ }
|
|
|
+ if (rootEnv) {
|
|
|
+ std::vector<std::string> p = cmSystemTools::SplitEnvPath(*rootEnv);
|
|
|
+ std::move(p.begin(), p.end(), std::back_inserter(rootPaths));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void cmFindPackageCommand::PopFindPackageRootPathStack()
|