浏览代码

cmGlobalGenerator: Extract a ComputeTargetObjectDirectory interface.

Make it public for future external calls.
Stephen Kelly 11 年之前
父节点
当前提交
cd43433de5

+ 6 - 0
Source/cmGlobalGenerator.cxx

@@ -1449,6 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
         continue;
         continue;
         }
         }
       cmGeneratorTarget* gt = ti->second;
       cmGeneratorTarget* gt = ti->second;
+      this->ComputeTargetObjectDirectory(gt);
       gt->LookupObjectLibraries();
       gt->LookupObjectLibraries();
       this->ComputeTargetObjects(gt);
       this->ComputeTargetObjects(gt);
       }
       }
@@ -1520,6 +1521,11 @@ void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const
   // Implemented in generator subclasses that need this.
   // Implemented in generator subclasses that need this.
 }
 }
 
 
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
+{
+}
+
 void cmGlobalGenerator::CheckLocalGenerators()
 void cmGlobalGenerator::CheckLocalGenerators()
 {
 {
   std::map<std::string, std::string> notFoundMap;
   std::map<std::string, std::string> notFoundMap;

+ 2 - 0
Source/cmGlobalGenerator.h

@@ -323,6 +323,8 @@ public:
   GetExportedTargetsFile(const std::string &filename) const;
   GetExportedTargetsFile(const std::string &filename) const;
   void AddCMP0042WarnTarget(const std::string& target);
   void AddCMP0042WarnTarget(const std::string& target);
 
 
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
 protected:
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
   // for a project collect all its targets by following depend

+ 16 - 11
Source/cmGlobalNinjaGenerator.cxx

@@ -634,16 +634,6 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
 // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
 // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
 void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
 void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
 {
 {
-  cmTarget* target = gt->Target;
-
-  // Compute full path to object file directory for this target.
-  std::string dir_max;
-  dir_max += gt->Makefile->GetCurrentOutputDirectory();
-  dir_max += "/";
-  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
-  dir_max += "/";
-  gt->ObjectDirectory = dir_max;
-
   std::vector<cmSourceFile*> objectSources;
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
   gt->GetObjectSources(objectSources);
   // Compute the name of each object file.
   // Compute the name of each object file.
@@ -653,11 +643,26 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
     {
     {
     cmSourceFile* sf = *si;
     cmSourceFile* sf = *si;
     std::string objectName = gt->LocalGenerator
     std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max);
+      ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
     gt->AddObject(sf, objectName);
     gt->AddObject(sf, objectName);
     }
     }
 }
 }
 
 
+//----------------------------------------------------------------------------
+void cmGlobalNinjaGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+{
+  cmTarget* target = gt->Target;
+
+  // Compute full path to object file directory for this target.
+  std::string dir_max;
+  dir_max += gt->Makefile->GetCurrentOutputDirectory();
+  dir_max += "/";
+  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
+  dir_max += "/";
+  gt->ObjectDirectory = dir_max;
+}
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 // Private methods
 // Private methods
 
 

+ 1 - 1
Source/cmGlobalNinjaGenerator.h

@@ -299,7 +299,7 @@ public:
 
 
   void AddTargetAlias(const std::string& alias, cmTarget* target);
   void AddTargetAlias(const std::string& alias, cmTarget* target);
 
 
-
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
 protected:
 
 
   /// Overloaded methods.
   /// Overloaded methods.

+ 17 - 10
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -108,15 +108,6 @@ void
 cmGlobalUnixMakefileGenerator3
 cmGlobalUnixMakefileGenerator3
 ::ComputeTargetObjects(cmGeneratorTarget* gt) const
 ::ComputeTargetObjects(cmGeneratorTarget* gt) const
 {
 {
-  cmTarget* target = gt->Target;
-  // Compute full path to object file directory for this target.
-  std::string dir_max;
-  dir_max += gt->Makefile->GetCurrentOutputDirectory();
-  dir_max += "/";
-  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
-  dir_max += "/";
-  gt->ObjectDirectory = dir_max;
-
   std::vector<cmSourceFile*> objectSources;
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
   gt->GetObjectSources(objectSources);
   // Compute the name of each object file.
   // Compute the name of each object file.
@@ -126,11 +117,27 @@ cmGlobalUnixMakefileGenerator3
     {
     {
     cmSourceFile* sf = *si;
     cmSourceFile* sf = *si;
     std::string objectName = gt->LocalGenerator
     std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max);
+      ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
     gt->AddObject(sf, objectName);
     gt->AddObject(sf, objectName);
     }
     }
 }
 }
 
 
+//----------------------------------------------------------------------------
+void
+cmGlobalUnixMakefileGenerator3
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+{
+  cmTarget* target = gt->Target;
+
+  // Compute full path to object file directory for this target.
+  std::string dir_max;
+  dir_max += gt->Makefile->GetCurrentOutputDirectory();
+  dir_max += "/";
+  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
+  dir_max += "/";
+  gt->ObjectDirectory = dir_max;
+}
+
 void cmGlobalUnixMakefileGenerator3::Configure()
 void cmGlobalUnixMakefileGenerator3::Configure()
 {
 {
   // Initialize CMAKE_EDIT_COMMAND cache entry.
   // Initialize CMAKE_EDIT_COMMAND cache entry.

+ 1 - 0
Source/cmGlobalUnixMakefileGenerator3.h

@@ -128,6 +128,7 @@ public:
   /** Does the make tool tolerate .NOTPARALLEL? */
   /** Does the make tool tolerate .NOTPARALLEL? */
   virtual bool AllowNotParallel() const { return true; }
   virtual bool AllowNotParallel() const { return true; }
 
 
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
 protected:
   void WriteMainMakefile2();
   void WriteMainMakefile2();
   void WriteMainCMakefile();
   void WriteMainCMakefile();

+ 6 - 1
Source/cmGlobalVisualStudioGenerator.cxx

@@ -159,10 +159,15 @@ cmGlobalVisualStudioGenerator
       }
       }
     gt->AddObject(sf, objectName);
     gt->AddObject(sf, objectName);
     }
     }
+}
 
 
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudioGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+{
   std::string dir = gt->Makefile->GetCurrentOutputDirectory();
   std::string dir = gt->Makefile->GetCurrentOutputDirectory();
   dir += "/";
   dir += "/";
-  std::string tgtDir = lg->GetTargetDirectory(*gt->Target);
+  std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target);
   if(!tgtDir.empty())
   if(!tgtDir.empty())
     {
     {
     dir += tgtDir;
     dir += tgtDir;

+ 1 - 0
Source/cmGlobalVisualStudioGenerator.h

@@ -88,6 +88,7 @@ public:
   virtual std::string ExpandCFGIntDir(const std::string& str,
   virtual std::string ExpandCFGIntDir(const std::string& str,
                                       const std::string& config) const;
                                       const std::string& config) const;
 
 
+  void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
 protected:
   // Does this VS version link targets to each other if there are
   // Does this VS version link targets to each other if there are
   // dependencies in the SLN file?  This was done for VS versions
   // dependencies in the SLN file?  This was done for VS versions

+ 5 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -3964,7 +3964,12 @@ cmGlobalXCodeGenerator
 
 
     gt->AddObject(sf, objectName);
     gt->AddObject(sf, objectName);
     }
     }
+}
 
 
+//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+{
   const char* configName = this->GetCMakeCFGIntDir();
   const char* configName = this->GetCMakeCFGIntDir();
   std::string dir = this->GetObjectsNormalDirectory(
   std::string dir = this->GetObjectsNormalDirectory(
     "$(PROJECT_NAME)", configName, gt->Target);
     "$(PROJECT_NAME)", configName, gt->Target);

+ 1 - 0
Source/cmGlobalXCodeGenerator.h

@@ -204,6 +204,7 @@ private:
                      std::vector<std::string> const& defines,
                      std::vector<std::string> const& defines,
                      bool dflag = false);
                      bool dflag = false);
 
 
+  void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
 protected:
   virtual const char* GetInstallTargetName() const { return "install"; }
   virtual const char* GetInstallTargetName() const { return "install"; }
   virtual const char* GetPackageTargetName() const { return "package"; }
   virtual const char* GetPackageTargetName() const { return "package"; }