cmGlobalGenerator: Factor out helper to check target ordering

This commit is contained in:
Brad King 2023-03-24 15:14:46 -04:00
parent fae6e8c2cd
commit 846baa7c5b
2 changed files with 12 additions and 2 deletions

View File

@ -1719,8 +1719,7 @@ cmGlobalGenerator::GetLocalGeneratorTargetsInOrder(cmLocalGenerator* lg) const
cm::append(gts, lg->GetGeneratorTargets()); cm::append(gts, lg->GetGeneratorTargets());
std::sort(gts.begin(), gts.end(), std::sort(gts.begin(), gts.end(),
[this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) { [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
return this->TargetOrderIndex.at(l) < return this->TargetOrderIndexLess(l, r);
this->TargetOrderIndex.at(r);
}); });
return gts; return gts;
} }
@ -3060,6 +3059,12 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
return this->TargetDependencies[target]; return this->TargetDependencies[target];
} }
bool cmGlobalGenerator::TargetOrderIndexLess(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const
{
return this->TargetOrderIndex.at(l) < this->TargetOrderIndex.at(r);
}
bool cmGlobalGenerator::IsReservedTarget(std::string const& name) bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
{ {
// The following is a list of targets reserved // The following is a list of targets reserved

View File

@ -479,6 +479,11 @@ public:
TargetDependSet const& GetTargetDirectDepends( TargetDependSet const& GetTargetDirectDepends(
const cmGeneratorTarget* target); const cmGeneratorTarget* target);
// Return true if target 'l' occurs before 'r' in a global ordering
// of targets that respects inter-target dependencies.
bool TargetOrderIndexLess(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap() const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap()
const const
{ {