Browse Source

cmGlobalGenerator: Factor out helper to check target ordering

Brad King 2 years ago
parent
commit
846baa7c5b
2 changed files with 12 additions and 2 deletions
  1. 7 2
      Source/cmGlobalGenerator.cxx
  2. 5 0
      Source/cmGlobalGenerator.h

+ 7 - 2
Source/cmGlobalGenerator.cxx

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

+ 5 - 0
Source/cmGlobalGenerator.h

@@ -479,6 +479,11 @@ public:
   TargetDependSet const& GetTargetDirectDepends(
     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
   {