Jelajahi Sumber

Merge topic 'use-generator-target'

638843a Remove the Location member from cmTarget.
90ef1cf Move GenerateTargetManifest to cmGeneratorTarget.
25f1df3 Split CreateGeneratorTargets into two methods.
Brad King 12 tahun lalu
induk
melakukan
8a6e82724c

+ 76 - 2
Source/cmGeneratorTarget.cxx

@@ -25,8 +25,6 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
   this->Makefile = this->Target->GetMakefile();
   this->LocalGenerator = this->Makefile->GetLocalGenerator();
   this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
-  this->ClassifySources();
-  this->LookupObjectLibraries();
 }
 
 //----------------------------------------------------------------------------
@@ -324,3 +322,79 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
 {
   return this->Target->GetIncludeDirectories(config);
 }
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GenerateTargetManifest(const char* config)
+{
+  if (this->Target->IsImported())
+    {
+    return;
+    }
+  cmMakefile* mf = this->Target->GetMakefile();
+  cmLocalGenerator* lg = mf->GetLocalGenerator();
+  cmGlobalGenerator* gg = lg->GetGlobalGenerator();
+
+  // Get the names.
+  std::string name;
+  std::string soName;
+  std::string realName;
+  std::string impName;
+  std::string pdbName;
+  if(this->GetType() == cmTarget::EXECUTABLE)
+    {
+    this->Target->GetExecutableNames(name, realName, impName, pdbName,
+                                     config);
+    }
+  else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
+          this->GetType() == cmTarget::SHARED_LIBRARY ||
+          this->GetType() == cmTarget::MODULE_LIBRARY)
+    {
+    this->Target->GetLibraryNames(name, soName, realName, impName, pdbName,
+                                  config);
+    }
+  else
+    {
+    return;
+    }
+
+  // Get the directory.
+  std::string dir = this->Target->GetDirectory(config, false);
+
+  // Add each name.
+  std::string f;
+  if(!name.empty())
+    {
+    f = dir;
+    f += "/";
+    f += name;
+    gg->AddToManifest(config? config:"", f);
+    }
+  if(!soName.empty())
+    {
+    f = dir;
+    f += "/";
+    f += soName;
+    gg->AddToManifest(config? config:"", f);
+    }
+  if(!realName.empty())
+    {
+    f = dir;
+    f += "/";
+    f += realName;
+    gg->AddToManifest(config? config:"", f);
+    }
+  if(!pdbName.empty())
+    {
+    f = dir;
+    f += "/";
+    f += pdbName;
+    gg->AddToManifest(config? config:"", f);
+    }
+  if(!impName.empty())
+    {
+    f = this->Target->GetDirectory(config, true);
+    f += "/";
+    f += impName;
+    gg->AddToManifest(config? config:"", f);
+    }
+}

+ 4 - 1
Source/cmGeneratorTarget.h

@@ -74,10 +74,13 @@ public:
 
   bool IsSystemIncludeDirectory(const char *dir, const char *config);
 
-private:
+  /** Add the target output files to the global generator manifest.  */
+  void GenerateTargetManifest(const char* config);
+
   void ClassifySources();
   void LookupObjectLibraries();
 
+private:
   std::map<std::string, std::vector<std::string> > SystemIncludesCache;
 
   cmGeneratorTarget(cmGeneratorTarget const&);

+ 23 - 3
Source/cmGlobalGenerator.cxx

@@ -1128,6 +1128,9 @@ void cmGlobalGenerator::Generate()
     this->LocalGenerators[i]->AddHelperCommands();
     }
 
+  // Create per-target generator information.
+  this->CreateGeneratorTargets();
+
   // Trace the dependencies, after that no custom commands should be added
   // because their dependencies might not be handled correctly
   for (i = 0; i < this->LocalGenerators.size(); ++i)
@@ -1141,8 +1144,7 @@ void cmGlobalGenerator::Generate()
     this->LocalGenerators[i]->GenerateTargetManifest();
     }
 
-  // Create per-target generator information.
-  this->CreateGeneratorTargets();
+  this->ComputeGeneratorTargetObjects();
 
   this->ProcessEvaluationFiles();
 
@@ -1336,7 +1338,6 @@ void cmGlobalGenerator::CreateGeneratorTargets()
 
       cmGeneratorTarget* gt = new cmGeneratorTarget(t);
       this->GeneratorTargets[t] = gt;
-      this->ComputeTargetObjects(gt);
       generatorTargets[t] = gt;
       }
 
@@ -1353,6 +1354,25 @@ void cmGlobalGenerator::CreateGeneratorTargets()
     }
 }
 
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::ComputeGeneratorTargetObjects()
+{
+  // Construct per-target generator information.
+  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
+    {
+    cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
+    cmGeneratorTargetsType targets = mf->GetGeneratorTargets();
+    for(cmGeneratorTargetsType::iterator ti = targets.begin();
+        ti != targets.end(); ++ti)
+      {
+      cmGeneratorTarget* gt = ti->second;
+      gt->ClassifySources();
+      gt->LookupObjectLibraries();
+      this->ComputeTargetObjects(gt);
+      }
+    }
+}
+
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorTargets()
 {

+ 1 - 0
Source/cmGlobalGenerator.h

@@ -408,6 +408,7 @@ private:
   // Per-target generator information.
   cmGeneratorTargetsType GeneratorTargets;
   void CreateGeneratorTargets();
+  void ComputeGeneratorTargetObjects();
   void ClearGeneratorTargets();
   virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 

+ 4 - 3
Source/cmLocalGenerator.cxx

@@ -530,10 +530,11 @@ void cmLocalGenerator::GenerateTargetManifest()
   this->Makefile->GetConfigurations(configNames);
 
   // Add our targets to the manifest for each configuration.
-  cmTargets& targets = this->Makefile->GetTargets();
-  for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
+  cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
+  for(cmGeneratorTargetsType::iterator t = targets.begin();
+      t != targets.end(); ++t)
     {
-    cmTarget& target = t->second;
+    cmGeneratorTarget& target = *t->second;
     if(configNames.empty())
       {
       target.GenerateTargetManifest(0);

+ 19 - 82
Source/cmTarget.cxx

@@ -2725,27 +2725,34 @@ const char* cmTarget::GetLocation(const char* config)
 //----------------------------------------------------------------------------
 const char* cmTarget::ImportedGetLocation(const char* config)
 {
-  this->Location = this->ImportedGetFullPath(config, false);
-  return this->Location.c_str();
+  static std::string location;
+  location = this->ImportedGetFullPath(config, false);
+  return location.c_str();
 }
 
 //----------------------------------------------------------------------------
 const char* cmTarget::NormalGetLocation(const char* config)
 {
+  static std::string location;
   // Handle the configuration-specific case first.
   if(config)
     {
-    this->Location = this->GetFullPath(config, false);
-    return this->Location.c_str();
+    location = this->GetFullPath(config, false);
+    return location.c_str();
     }
 
   // Now handle the deprecated build-time configuration location.
-  this->Location = this->GetDirectory();
+  location = this->GetDirectory();
+  if(!location.empty())
+    {
+    location += "/";
+    }
   const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
   if(cfgid && strcmp(cfgid, ".") != 0)
     {
-    this->Location += "/";
-    this->Location += cfgid;
+    location += "/";
+    location += cfgid;
+    location += "/";
     }
 
   if(this->IsAppBundleOnApple())
@@ -2753,13 +2760,13 @@ const char* cmTarget::NormalGetLocation(const char* config)
     std::string macdir = this->BuildMacContentDirectory("", config, false);
     if(!macdir.empty())
       {
-      this->Location += "/";
-      this->Location += macdir;
+      location += "/";
+      location += macdir;
       }
     }
-  this->Location += "/";
-  this->Location += this->GetFullName(config, false);
-  return this->Location.c_str();
+  location += "/";
+  location += this->GetFullName(config, false);
+  return location.c_str();
 }
 
 //----------------------------------------------------------------------------
@@ -3916,76 +3923,6 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
   return false;
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::GenerateTargetManifest(const char* config)
-{
-  cmMakefile* mf = this->Makefile;
-  cmLocalGenerator* lg = mf->GetLocalGenerator();
-  cmGlobalGenerator* gg = lg->GetGlobalGenerator();
-
-  // Get the names.
-  std::string name;
-  std::string soName;
-  std::string realName;
-  std::string impName;
-  std::string pdbName;
-  if(this->GetType() == cmTarget::EXECUTABLE)
-    {
-    this->GetExecutableNames(name, realName, impName, pdbName, config);
-    }
-  else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
-          this->GetType() == cmTarget::SHARED_LIBRARY ||
-          this->GetType() == cmTarget::MODULE_LIBRARY)
-    {
-    this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
-    }
-  else
-    {
-    return;
-    }
-
-  // Get the directory.
-  std::string dir = this->GetDirectory(config, false);
-
-  // Add each name.
-  std::string f;
-  if(!name.empty())
-    {
-    f = dir;
-    f += "/";
-    f += name;
-    gg->AddToManifest(config? config:"", f);
-    }
-  if(!soName.empty())
-    {
-    f = dir;
-    f += "/";
-    f += soName;
-    gg->AddToManifest(config? config:"", f);
-    }
-  if(!realName.empty())
-    {
-    f = dir;
-    f += "/";
-    f += realName;
-    gg->AddToManifest(config? config:"", f);
-    }
-  if(!pdbName.empty())
-    {
-    f = this->GetPDBDirectory(config);
-    f += "/";
-    f += pdbName;
-    gg->AddToManifest(config? config:"", f);
-    }
-  if(!impName.empty())
-    {
-    f = this->GetDirectory(config, true);
-    f += "/";
-    f += impName;
-    gg->AddToManifest(config? config:"", f);
-    }
-}
-
 //----------------------------------------------------------------------------
 void cmTarget::SetPropertyDefault(const char* property,
                                   const char* default_value)

+ 0 - 4
Source/cmTarget.h

@@ -410,9 +410,6 @@ public:
   bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
                         const char* newExt = 0);
 
-  /** Add the target output files to the global generator manifest.  */
-  void GenerateTargetManifest(const char* config);
-
   /**
    * Compute whether this target must be relinked before installing.
    */
@@ -677,7 +674,6 @@ private:
   bool HaveInstallRule;
   std::string InstallPath;
   std::string RuntimeInstallPath;
-  std::string Location;
   std::string ExportMacro;
   std::set<cmStdString> Utilities;
   bool RecordDependencies;