Răsfoiți Sursa

cmTarget: Add GetUtilityItems to get target ordering dependencies

Add a method like GetUtilities but that provides the target names
already looked up and resolved to cmTarget pointers internally.  Update
call site in cmComputeTargetDepends::AddTargetDepend to use the
already-found target instead of looking it up again.
Brad King 11 ani în urmă
părinte
comite
097be4139d
3 a modificat fișierele cu 25 adăugiri și 4 ștergeri
  1. 3 4
      Source/cmComputeTargetDepends.cxx
  2. 21 0
      Source/cmTarget.cxx
  3. 1 0
      Source/cmTarget.h

+ 3 - 4
Source/cmComputeTargetDepends.cxx

@@ -421,12 +421,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
   if(dependee->IsImported())
     {
     // Skip imported targets but follow their utility dependencies.
-    std::set<std::string> const& utils = dependee->GetUtilities();
-    for(std::set<std::string>::const_iterator i = utils.begin();
+    std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
+    for(std::set<cmLinkItem>::const_iterator i = utils.begin();
         i != utils.end(); ++i)
       {
-      if(cmTarget const* transitive_dependee =
-         dependee->GetMakefile()->FindTargetToUse(*i))
+      if(cmTarget const* transitive_dependee = i->Target)
         {
         this->AddTargetDepend(depender_index, transitive_dependee, false);
         }

+ 21 - 0
Source/cmTarget.cxx

@@ -95,11 +95,13 @@ public:
     : Backtrace(NULL)
     {
     this->PolicyWarnedCMP0022 = false;
+    this->UtilityItemsDone = false;
     }
   cmTargetInternals(cmTargetInternals const&)
     : Backtrace(NULL)
     {
     this->PolicyWarnedCMP0022 = false;
+    this->UtilityItemsDone = false;
     }
   ~cmTargetInternals();
 
@@ -151,6 +153,9 @@ public:
                                                           SourceFilesMapType;
   SourceFilesMapType SourceFilesMap;
 
+  std::set<cmLinkItem> UtilityItems;
+  bool UtilityItemsDone;
+
   struct TargetPropertyEntry {
     TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
       const std::string &targetName = std::string())
@@ -470,6 +475,22 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
   return &i->second;
 }
 
+//----------------------------------------------------------------------------
+std::set<cmLinkItem> const& cmTarget::GetUtilityItems() const
+{
+  if(!this->Internal->UtilityItemsDone)
+    {
+    this->Internal->UtilityItemsDone = true;
+    for(std::set<std::string>::const_iterator i = this->Utilities.begin();
+        i != this->Utilities.end(); ++i)
+      {
+      this->Internal->UtilityItems.insert(
+        cmLinkItem(*i, this->Makefile->FindTargetToUse(*i)));
+      }
+    }
+  return this->Internal->UtilityItems;
+}
+
 //----------------------------------------------------------------------------
 void cmTarget::FinishConfigure()
 {

+ 1 - 0
Source/cmTarget.h

@@ -227,6 +227,7 @@ public:
   void AddUtility(const std::string& u, cmMakefile *makefile = 0);
   ///! Get the utilities used by this target
   std::set<std::string>const& GetUtilities() const { return this->Utilities; }
+  std::set<cmLinkItem>const& GetUtilityItems() const;
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   /** Finalize the target at the end of the Configure step.  */