Merge topic 'find_package-fix-nested-calls' into release-4.0

37823b366f find_package: Restore component requirements in nested calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10576
This commit is contained in:
Brad King
2025-04-02 14:23:10 +00:00
committed by Kitware Robot
6 changed files with 22 additions and 3 deletions
+9 -3
View File
@@ -911,10 +911,16 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->VersionExact = this->Makefile->IsOn(exact);
}
if (this->Components.empty()) {
std::string const components_var = this->Name + "_FIND_COMPONENTS";
this->Components = this->Makefile->GetSafeDefinition(components_var);
std::string const componentsVar = this->Name + "_FIND_COMPONENTS";
this->Components = this->Makefile->GetSafeDefinition(componentsVar);
for (auto const& component : cmList{ this->Components }) {
this->RequiredComponents.insert(component);
std::string const crVar =
cmStrCat(this->Name, "_FIND_REQUIRED_"_s, component);
if (this->Makefile->GetDefinition(crVar).IsOn()) {
this->RequiredComponents.insert(component);
} else {
this->OptionalComponents.insert(component);
}
}
}
}