[Cmake-commits] CMake branch, next, updated. v3.0.0-rc1-920-g1f88144

Stephen Kelly steveire at gmail.com
Wed Mar 12 14:12:00 EDT 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  1f8814428337d3a946fe84e5185067a4ac2a3ad2 (commit)
       via  04c4b89d5819a27612b3215b33cf6db86637e825 (commit)
       via  49b4e519fed38b70834ff7f2c83adead63db7d43 (commit)
       via  6af1f871c81fcb4596bc525a8c0e0f43dd53ffb4 (commit)
       via  37588a42021f60b4030f7e952eabd761789b80d6 (commit)
       via  b6cabed3a7dcb188ceb4baee32cc311e2a74743b (commit)
       via  8b6f55c9a9cb10333c448439ba083832a1e8e4fb (commit)
       via  44b32675bf3b223e21a23516b8c2c07961ad88d6 (commit)
      from  64dfd5d847b5ea00b58ff53d2fdb58cefe7ed8ce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f8814428337d3a946fe84e5185067a4ac2a3ad2
commit 1f8814428337d3a946fe84e5185067a4ac2a3ad2
Merge: 64dfd5d 04c4b89
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Mar 12 14:11:58 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Mar 12 14:11:58 2014 -0400

    Merge topic 'target-objects-refactor' into next
    
    04c4b89d cmGeneratorTarget: Compute target objects in LookupObjectLibraries.
    49b4e519 cmGeneratorTarget: Remove GetObjectName method.
    6af1f871 cmLocalGenerator: Add ComputeObjectFilename method.
    37588a42 cmLocalGenerator: Add ComputeObjectFilenames method.
    b6cabed3 cmGeneratorTarget: Move ExplicitTargetName to VS local generator
    8b6f55c9 cmLocalGenerator: Add GetDirectoryForObjects method.
    44b32675 cmLocalGenerator: Add GetObjectDirectory method.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04c4b89d5819a27612b3215b33cf6db86637e825
commit 04c4b89d5819a27612b3215b33cf6db86637e825
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 11 20:39:01 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:54 2014 +0100

    cmGeneratorTarget: Compute target objects in LookupObjectLibraries.
    
    Remove the old method from the generators which are now all
    functionally identical.
    
    Remove the supporting cmGeneratorTarget::AddObject method.
    
    In a follow-up, the LookupObjectLibraries may be replaced by a
    true generator expression evaluator for TARGET_OBJECTS. That
    will require generators to use cmGeneratorTarget::GetExternalObjects
    which is not currently the case for Xcode and VS generators.

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 8804fac..6a1f734 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -316,12 +316,6 @@ cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &data) const
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name)
-{
-    this->Objects[sf] = name;
-}
-
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& data) const
 {
   IMPLEMENT_VISIT(IDLSources);
@@ -529,6 +523,29 @@ void cmGeneratorTarget::LookupObjectLibraries()
       return;
       }
     }
+
+  // Compute full path to object file directory for this target.
+  std::string obj_dir;
+  this->LocalGenerator->GetObjectDirectory(this->Target, obj_dir);
+  this->ObjectDirectory = obj_dir;
+
+  std::string dir_max;
+  this->LocalGenerator->GetDirectoryForObjects(this->Target, dir_max);
+
+  std::vector<cmSourceFile*> objectSources;
+  this->GetObjectSources(objectSources);
+  std::vector<std::string> objects;
+  this->LocalGenerator->ComputeObjectFilenames(objectSources,
+                                                objects, dir_max);
+  assert(objects.size() == objectSources.size());
+  // Compute the name of each object file.
+  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
+  std::vector<std::string>::const_iterator objIt = objects.begin();
+  for( ; srcIt != objectSources.end(), objIt != objects.end();
+      ++srcIt, ++objIt)
+    {
+    this->Objects[*srcIt] = *objIt;
+    }
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index ceb38d5..5788abe 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -34,8 +34,6 @@ public:
 
   void GetObjectSources(std::vector<cmSourceFile*> &) const;
 
-  void AddObject(cmSourceFile *sf, std::string const&name);
-
   void GetResxSources(std::vector<cmSourceFile*>&) const;
   void GetIDLSources(std::vector<cmSourceFile*>&) const;
   void GetExternalObjects(std::vector<cmSourceFile*>&) const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b95ff81..d0b7b69 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1450,7 +1450,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
         }
       cmGeneratorTarget* gt = ti->second;
       gt->LookupObjectLibraries();
-      this->ComputeTargetObjects(gt);
       }
     }
 }
@@ -1514,12 +1513,6 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
   return ti->second;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const
-{
-  // Implemented in generator subclasses that need this.
-}
-
 void cmGlobalGenerator::CheckLocalGenerators()
 {
   std::map<std::string, std::string> notFoundMap;
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 91e71a8..762b536 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -441,7 +441,6 @@ private:
   void CreateGeneratorTargets(cmMakefile* mf);
   void CreateGeneratorTargets();
   void ComputeGeneratorTargetObjects();
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void ClearGeneratorMembers();
 
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 89d81de..6af4ef0 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -631,33 +631,6 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
   return cmSystemTools::GetCMakeGUICommand();
 }
 
-// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
-void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
-{
-  cmTarget* target = gt->Target;
-
-  // Compute full path to object file directory for this target.
-  std::string obj_dir;
-  gt->LocalGenerator->GetObjectDirectory(target, obj_dir);
-  gt->ObjectDirectory = obj_dir;
-
-  std::string dir_max;
-  gt->LocalGenerator->GetDirectoryForObjects(target, dir_max);
-
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  std::vector<std::string> objects;
-  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
-                                                objects, dir_max);
-  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
-  std::vector<std::string>::const_iterator objIt = objects.begin();
-  for( ; srcIt != objectSources.end(), objIt != objects.end();
-      ++srcIt, ++objIt)
-    {
-    gt->AddObject(*srcIt, *objIt);
-    }
-}
-
 //----------------------------------------------------------------------------
 // Private methods
 
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 7725cf3..787e3f4 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -310,9 +310,6 @@ protected:
 private:
   virtual std::string GetEditCacheCommand() const;
 
-  /// @see cmGlobalGenerator::ComputeTargetObjects
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
-
   void OpenBuildFileStream();
   void CloseBuildFileStream();
 
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index ea65669..ee08ec8 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -103,34 +103,6 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const
   return edit_cmd? edit_cmd : "";
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
-{
-  cmTarget* target = gt->Target;
-  // Compute full path to object file directory for this target.
-  std::string obj_dir;
-  gt->LocalGenerator->GetObjectDirectory(target, obj_dir);
-  gt->ObjectDirectory = obj_dir;
-
-  std::string dir_max;
-  gt->LocalGenerator->GetDirectoryForObjects(target, dir_max);
-
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  std::vector<std::string> objects;
-  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
-                                                objects, dir_max);
-  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
-  std::vector<std::string>::const_iterator objIt = objects.begin();
-  for( ; srcIt != objectSources.end(), objIt != objects.end();
-      ++srcIt, ++objIt)
-    {
-    gt->AddObject(*srcIt, *objIt);
-    }
-}
-
 void cmGlobalUnixMakefileGenerator3::Configure()
 {
   // Initialize CMAKE_EDIT_COMMAND cache entry.
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 8115176..b078651 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -198,7 +198,6 @@ protected:
 private:
   virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; }
   virtual std::string GetEditCacheCommand() const;
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 };
 
 #endif
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 3cee9e2..587024d 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -118,32 +118,6 @@ void cmGlobalVisualStudioGenerator::Generate()
 }
 
 //----------------------------------------------------------------------------
-void
-cmGlobalVisualStudioGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
-{
-  std::string dir_max;
-  gt->LocalGenerator->GetDirectoryForObjects(gt->Target, dir_max);
-
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  std::vector<std::string> objects;
-  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
-                                                objects, dir_max);
-  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
-  std::vector<std::string>::const_iterator objIt = objects.begin();
-  for( ; srcIt != objectSources.end(), objIt != objects.end();
-      ++srcIt, ++objIt)
-    {
-    gt->AddObject(*srcIt, *objIt);
-    }
-
-  std::string dir;
-  gt->LocalGenerator->GetObjectDirectory(gt->Target, dir);
-  gt->ObjectDirectory = dir;
-}
-
-//----------------------------------------------------------------------------
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
   const std::string& regKeyBase,
   std::string& nextAvailableSubKeyName);
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 7e8dcf8..e587f4f 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -116,7 +116,6 @@ private:
   virtual std::string GetVSMakeProgram() = 0;
   void PrintCompilerAdvice(std::ostream&, std::string const&,
                            const char*) const {}
-  void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void FollowLinkDepends(cmTarget const* target,
                          std::set<cmTarget const*>& linked);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 2eef69d..1923b05 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3946,26 +3946,3 @@ bool cmGlobalXCodeGenerator::IsMultiConfig()
   // Newer Xcode versions are multi config:
   return true;
 }
-
- //----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
-{
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  std::vector<std::string> objects;
-  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
-                                                objects, "");
-  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
-  std::vector<std::string>::const_iterator objIt = objects.begin();
-  for( ; srcIt != objectSources.end(), objIt != objects.end();
-      ++srcIt, ++objIt)
-    {
-    gt->AddObject(*srcIt, *objIt);
-    }
-
-  std::string dir;
-  gt->LocalGenerator->GetObjectDirectory(*gt->Target, dir);
-  gt->ObjectDirectory = dir;
-}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 655fb23..ee85117 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -226,7 +226,6 @@ protected:
 private:
   void PrintCompilerAdvice(std::ostream&, std::string const&,
                            const char*) const {}
-  void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void addObject(cmXCodeObject *obj);
   std::string PostBuildMakeTarget(std::string const& tName,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49b4e519fed38b70834ff7f2c83adead63db7d43
commit 49b4e519fed38b70834ff7f2c83adead63db7d43
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Mar 12 00:11:18 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:46 2014 +0100

    cmGeneratorTarget: Remove GetObjectName method.
    
    It is no longer used.

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 83ba343..8804fac 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -316,11 +316,6 @@ cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &data) const
 }
 
 //----------------------------------------------------------------------------
-const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
-{
-  return this->Objects[file];
-}
-
 void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name)
 {
     this->Objects[sf] = name;
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 8b6d7e5..ceb38d5 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -33,7 +33,6 @@ public:
   void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
 
   void GetObjectSources(std::vector<cmSourceFile*> &) const;
-  const std::string& GetObjectName(cmSourceFile const* file);
 
   void AddObject(cmSourceFile *sf, std::string const&name);
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6af1f871c81fcb4596bc525a8c0e0f43dd53ffb4
commit 6af1f871c81fcb4596bc525a8c0e0f43dd53ffb4
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Mar 12 00:04:38 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:46 2014 +0100

    cmLocalGenerator: Add ComputeObjectFilename method.
    
    The generators need to be able to get the ObjectName for a
    single source file.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index edbaf92..87cf0bb 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3107,6 +3107,21 @@ void cmLocalGenerator::ComputeObjectFilenames(
 }
 
 //----------------------------------------------------------------------------
+void cmLocalGenerator::ComputeObjectFilename(
+                            cmSourceFile* src,
+                            std::string& name,
+                            const std::string& dir)
+{
+  std::vector<cmSourceFile*> srcs;
+  srcs.push_back(src);
+  std::vector<std::string> names;
+
+  this->ComputeObjectFilenames(srcs, names, dir);
+  assert(names.size() == 1);
+  name = names.front();
+}
+
+//----------------------------------------------------------------------------
 void cmLocalGenerator::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
 {
   this->GetObjectDirectory(tgt, dir);
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 38e303a..db1df0d 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -378,6 +378,9 @@ public:
                               const std::vector<cmSourceFile*>& objectSources,
                               std::vector<std::string>& objectFiles,
                               const std::string& dir);
+  void ComputeObjectFilename(cmSourceFile* objectSource,
+                              std::string& objectFile,
+                              const std::string& dir);
 
 protected:
   ///! put all the libraries for a target on into the given stream
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index ce55068..78df95d 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -404,7 +404,13 @@ void cmLocalVisualStudio6Generator
     std::string objectNameDir;
     if(this->HasExplicitObjectName(*sf))
       {
-      objectNameDir = cmSystemTools::GetFilenamePath(gt->GetObjectName(*sf));
+      std::string dir_max;
+      this->GetDirectoryForObjects(&target, dir_max);
+
+      std::string objectName;
+      this->ComputeObjectFilename(const_cast<cmSourceFile*>(*sf),
+                                  objectName, dir_max);
+      objectNameDir = cmSystemTools::GetFilenamePath(objectName);
       }
 
     // Add per-source file flags.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 8819361..88085fa 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1484,7 +1484,11 @@ cmLocalVisualStudio7GeneratorFCInfo
   std::string objectName;
   if(lg->HasExplicitObjectName(&sf))
     {
-    objectName = gt->GetObjectName(&sf);
+    std::string dir_max;
+    lg->GetDirectoryForObjects(&target, dir_max);
+
+    lg->ComputeObjectFilename(const_cast<cmSourceFile*>(&sf),
+                              objectName, dir_max);
     }
 
   // Compute per-source, per-config information.
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 983fd99..1634269 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -431,9 +431,12 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
     return;
     }
 
-  // Get the full path name of the object file.
-  std::string const& objectName = this->GeneratorTarget
-                                      ->GetObjectName(&source);
+  std::string dir_max;
+  this->LocalGenerator->GetDirectoryForObjects(this->Target, dir_max);
+
+  std::string objectName;
+  this->LocalGenerator->ComputeObjectFilename(&source, objectName, dir_max);
+
   std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
   obj += "/";
   obj += objectName;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index d652018..e84065c 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -281,8 +281,11 @@ cmNinjaTargetGenerator
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
   if(!path.empty())
     path += "/";
-  std::string const& objectName = this->GeneratorTarget
-                                      ->GetObjectName(source);
+  std::string dir_max;
+  this->LocalGenerator->GetDirectoryForObjects(this->Target, dir_max);
+
+  std::string objectName;
+  this->LocalGenerator->ComputeObjectFilename(source, objectName, dir_max);
   path += this->LocalGenerator->GetTargetDirectory(*this->Target);
   path += "/";
   path += objectName;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5bb3b36..aefd310 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1096,7 +1096,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
   std::string objectName;
   if(this->LocalGenerator->HasExplicitObjectName(&sf))
     {
-    objectName = this->GeneratorTarget->GetObjectName(&sf);
+    std::string dir_max;
+    this->LocalGenerator->GetDirectoryForObjects(this->Target, dir_max);
+    this->LocalGenerator->ComputeObjectFilename(&sf, objectName, dir_max);
     }
   std::string flags;
   std::string defines;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=37588a42021f60b4030f7e952eabd761789b80d6
commit 37588a42021f60b4030f7e952eabd761789b80d6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 11 17:37:26 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:45 2014 +0100

    cmLocalGenerator: Add ComputeObjectFilenames method.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 36bdd4c..89d81de 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -646,15 +646,15 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
 
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
-  // Compute the name of each object file.
-  for(std::vector<cmSourceFile*>::iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
+  std::vector<std::string> objects;
+  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
+                                                objects, dir_max);
+  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
+  std::vector<std::string>::const_iterator objIt = objects.begin();
+  for( ; srcIt != objectSources.end(), objIt != objects.end();
+      ++srcIt, ++objIt)
     {
-    cmSourceFile* sf = *si;
-    std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max);
-    gt->AddObject(sf, objectName);
+    gt->AddObject(*srcIt, *objIt);
     }
 }
 
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 220ca47..ea65669 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -119,15 +119,15 @@ cmGlobalUnixMakefileGenerator3
 
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
-  // Compute the name of each object file.
-  for(std::vector<cmSourceFile*>::iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
+  std::vector<std::string> objects;
+  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
+                                                objects, dir_max);
+  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
+  std::vector<std::string>::const_iterator objIt = objects.begin();
+  for( ; srcIt != objectSources.end(), objIt != objects.end();
+      ++srcIt, ++objIt)
     {
-    cmSourceFile* sf = *si;
-    std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max);
-    gt->AddObject(sf, objectName);
+    gt->AddObject(*srcIt, *objIt);
     }
 }
 
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index d33620a..3cee9e2 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -122,44 +122,20 @@ void
 cmGlobalVisualStudioGenerator
 ::ComputeTargetObjects(cmGeneratorTarget* gt) const
 {
-  cmLocalVisualStudioGenerator* lg =
-    static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator);
-
   std::string dir_max;
   gt->LocalGenerator->GetDirectoryForObjects(gt->Target, dir_max);
 
-  // Count the number of object files with each name.  Note that
-  // windows file names are not case sensitive.
-  std::map<std::string, int> counts;
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectNameLower = cmSystemTools::LowerCase(
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
-    objectNameLower += ".obj";
-    counts[objectNameLower] += 1;
-    }
-
-  // For all source files producing duplicate names we need unique
-  // object name computation.
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectName =
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
-    objectName += ".obj";
-    if(counts[cmSystemTools::LowerCase(objectName)] > 1)
-      {
-      lg->AddExplicitObjectName(sf);
-      objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max);
-      }
-    gt->AddObject(sf, objectName);
+  std::vector<std::string> objects;
+  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
+                                                objects, dir_max);
+  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
+  std::vector<std::string>::const_iterator objIt = objects.begin();
+  for( ; srcIt != objectSources.end(), objIt != objects.end();
+      ++srcIt, ++objIt)
+    {
+    gt->AddObject(*srcIt, *objIt);
     }
 
   std::string dir;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b97b133..2eef69d 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3952,30 +3952,17 @@ void
 cmGlobalXCodeGenerator
 ::ComputeTargetObjects(cmGeneratorTarget* gt) const
 {
-  // Count the number of object files with each name. Warn about duplicate
-  // names since Xcode names them uniquely automatically with a numeric suffix
-  // to avoid exact duplicate file names. Note that Mac file names are not
-  // typically case sensitive, hence the LowerCase.
-  std::map<std::string, int> counts;
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
-      si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectName =
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
-    objectName += ".o";
-
-    std::string objectNameLower = cmSystemTools::LowerCase(objectName);
-    counts[objectNameLower] += 1;
-    if (2 == counts[objectNameLower])
-      {
-      // TODO: emit warning about duplicate name?
-      }
-
-    gt->AddObject(sf, objectName);
+  std::vector<std::string> objects;
+  gt->LocalGenerator->ComputeObjectFilenames(objectSources,
+                                                objects, "");
+  std::vector<cmSourceFile*>::const_iterator srcIt = objectSources.begin();
+  std::vector<std::string>::const_iterator objIt = objects.begin();
+  for( ; srcIt != objectSources.end(), objIt != objects.end();
+      ++srcIt, ++objIt)
+    {
+    gt->AddObject(*srcIt, *objIt);
     }
 
   std::string dir;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0d52a31..edbaf92 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3098,6 +3098,15 @@ void cmLocalGenerator::ComputeObjectDirectory(cmTarget*, std::string&)
 }
 
 //----------------------------------------------------------------------------
+void cmLocalGenerator::ComputeObjectFilenames(
+                            const std::vector<cmSourceFile*>&,
+                            std::vector<std::string>&,
+                            const std::string&)
+{
+
+}
+
+//----------------------------------------------------------------------------
 void cmLocalGenerator::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
 {
   this->GetObjectDirectory(tgt, dir);
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 5a70bf7..38e303a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -374,6 +374,11 @@ public:
   void GetObjectDirectory(cmTarget* tgt, std::string& dir);
   virtual void GetDirectoryForObjects(cmTarget* tgt, std::string& dir);
 
+  virtual void ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*>& objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir);
+
 protected:
   ///! put all the libraries for a target on into the given stream
   virtual void OutputLinkLibraries(std::string& linkLibraries,
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index abb156c..3261900 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -277,6 +277,22 @@ void cmLocalNinjaGenerator::ComputeObjectDirectory(cmTarget* tgt,
   dir += "/";
 }
 
+//----------------------------------------------------------------------------
+void cmLocalNinjaGenerator::ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*> &objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir)
+{
+  // Compute the name of each object file.
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = objectSources.begin();
+      si != objectSources.end(); ++si)
+    {
+    cmSourceFile* sf = *si;
+    objectFiles.push_back(this->GetObjectFileNameWithoutTarget(*sf, dir));
+    }
+}
+
 void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 17365e7..fe8929a 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -100,6 +100,11 @@ public:
   virtual std::string ConvertToLinkReference(std::string const& lib,
                                              OutputFormat format = SHELL);
 
+  virtual void ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*>& objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir);
+
 private:
   virtual void ComputeObjectDirectory(cmTarget*, std::string&);
 
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 5d22392..b3c823e 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -182,6 +182,22 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectDirectory(cmTarget* tgt,
 }
 
 //----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*> &objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir)
+{
+  // Compute the name of each object file.
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = objectSources.begin();
+      si != objectSources.end(); ++si)
+    {
+    cmSourceFile* sf = *si;
+    objectFiles.push_back(this->GetObjectFileNameWithoutTarget(*sf, dir));
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::
 GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
 {
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 85ce69a..e2f8058 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -242,6 +242,11 @@ public:
   // Eclipse generator.
   void GetIndividualFileTargets(std::vector<std::string>& targets);
 
+  virtual void ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*>& objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir);
+
 private:
   virtual void ComputeObjectDirectory(cmTarget*, std::string&);
 
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 339e85c..88d793e 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -51,6 +51,45 @@ void cmLocalVisualStudioGenerator::ComputeObjectDirectory(cmTarget* tgt,
 }
 
 //----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*> &objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir)
+{
+  // Count the number of object files with each name.  Note that
+  // windows file names are not case sensitive.
+  std::map<std::string, int> counts;
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = objectSources.begin();
+      si != objectSources.end(); ++si)
+    {
+    cmSourceFile* sf = *si;
+    std::string objectNameLower = cmSystemTools::LowerCase(
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
+    objectNameLower += ".obj";
+    counts[objectNameLower] += 1;
+    }
+
+  // For all source files producing duplicate names we need unique
+  // object name computation.
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = objectSources.begin();
+      si != objectSources.end(); ++si)
+    {
+    cmSourceFile* sf = *si;
+    std::string objectName =
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+    objectName += ".obj";
+    if(counts[cmSystemTools::LowerCase(objectName)] > 1)
+      {
+      this->ExplicitObjectName.insert(sf);
+      objectName = this->GetObjectFileNameWithoutTarget(*sf, dir);
+      }
+    objectFiles.push_back(objectName);
+    }
+}
+
+//----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCustomCommand>
 cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
                                                    const std::string& config,
@@ -107,13 +146,6 @@ bool cmLocalVisualStudioGenerator
 
 //----------------------------------------------------------------------------
 void cmLocalVisualStudioGenerator
-::AddExplicitObjectName(cmSourceFile* sf)
-{
-  this->ExplicitObjectName.insert(sf);
-}
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudioGenerator
 ::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
 {
   dir = this->ComputeLongestObjectDirectory(*tgt);
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index f98b669..ba39bf4 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -64,7 +64,11 @@ public:
   void GetDirectoryForObjects(cmTarget* tgt, std::string& dir);
 
   bool HasExplicitObjectName(cmSourceFile const* file) const;
-  void AddExplicitObjectName(cmSourceFile* sf);
+
+  virtual void ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*>& objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir);
 
 protected:
   virtual const char* ReportErrorLabel() const;
@@ -78,6 +82,8 @@ protected:
   VSVersion Version;
 private:
   virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
+
+  std::set<cmSourceFile const*> ExplicitObjectName;
 };
 
 #endif
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index c32469e..05aed0c 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -100,3 +100,33 @@ void cmLocalXCodeGenerator::ComputeObjectDirectory(cmTarget* tgt,
 #endif
     }
 }
+
+//----------------------------------------------------------------------------
+void cmLocalXCodeGenerator::ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*> &objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string&)
+{
+  // Count the number of object files with each name. Warn about duplicate
+  // names since Xcode names them uniquely automatically with a numeric suffix
+  // to avoid exact duplicate file names. Note that Mac file names are not
+  // typically case sensitive, hence the LowerCase.
+  std::map<std::string, int> counts;
+  for(std::vector<cmSourceFile*>::const_iterator
+      si = objectSources.begin();
+      si != objectSources.end(); ++si)
+    {
+    cmSourceFile* sf = *si;
+    std::string objectName =
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+    objectName += ".o";
+
+    std::string objectNameLower = cmSystemTools::LowerCase(objectName);
+    counts[objectNameLower] += 1;
+    if (2 == counts[objectNameLower])
+      {
+      // TODO: emit warning about duplicate name?
+      }
+    objectFiles.push_back(objectName);
+    }
+}
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 8526d18..5cd8654 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -33,6 +33,10 @@ public:
   virtual void Generate();
   virtual void GenerateInstallRules();
   void GetDirectoryForObjects(cmTarget*,std::string&);
+  virtual void ComputeObjectFilenames(
+                              const std::vector<cmSourceFile*>& objectSources,
+                              std::vector<std::string>& objectFiles,
+                              const std::string& dir);
 private:
   virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b6cabed3a7dcb188ceb4baee32cc311e2a74743b
commit b6cabed3a7dcb188ceb4baee32cc311e2a74743b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 11 18:04:51 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:45 2014 +0100

    cmGeneratorTarget: Move ExplicitTargetName to VS local generator

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index db88749..83ba343 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -327,20 +327,6 @@ void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name)
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf)
-{
-  this->ExplicitObjectName.insert(sf);
-}
-
-//----------------------------------------------------------------------------
-bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
-{
-  std::set<cmSourceFile const*>::const_iterator it
-                                        = this->ExplicitObjectName.find(file);
-  return it != this->ExplicitObjectName.end();
-}
-
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& data) const
 {
   IMPLEMENT_VISIT(IDLSources);
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 81a447f..8b6d7e5 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -36,8 +36,6 @@ public:
   const std::string& GetObjectName(cmSourceFile const* file);
 
   void AddObject(cmSourceFile *sf, std::string const&name);
-  bool HasExplicitObjectName(cmSourceFile const* file) const;
-  void AddExplicitObjectName(cmSourceFile* sf);
 
   void GetResxSources(std::vector<cmSourceFile*>&) const;
   void GetIDLSources(std::vector<cmSourceFile*>&) const;
@@ -125,7 +123,6 @@ private:
   SourceEntriesType SourceEntries;
 
   std::map<cmSourceFile const*, std::string> Objects;
-  std::set<cmSourceFile const*> ExplicitObjectName;
   mutable std::vector<cmSourceFile*> ObjectSources;
   std::vector<cmTarget*> ObjectLibraries;
   mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 6c280f1..d33620a 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -156,7 +156,7 @@ cmGlobalVisualStudioGenerator
     objectName += ".obj";
     if(counts[cmSystemTools::LowerCase(objectName)] > 1)
       {
-      gt->AddExplicitObjectName(sf);
+      lg->AddExplicitObjectName(sf);
       objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max);
       }
     gt->AddObject(sf, objectName);
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index f1fd994..ce55068 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -402,7 +402,7 @@ void cmLocalVisualStudio6Generator
     std::string compileFlags;
     std::vector<std::string> depends;
     std::string objectNameDir;
-    if(gt->HasExplicitObjectName(*sf))
+    if(this->HasExplicitObjectName(*sf))
       {
       objectNameDir = cmSystemTools::GetFilenamePath(gt->GetObjectName(*sf));
       }
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 4491140..8819361 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1482,7 +1482,7 @@ cmLocalVisualStudio7GeneratorFCInfo
   cmGeneratorTarget* gt =
     lg->GetGlobalGenerator()->GetGeneratorTarget(&target);
   std::string objectName;
-  if(gt->HasExplicitObjectName(&sf))
+  if(lg->HasExplicitObjectName(&sf))
     {
     objectName = gt->GetObjectName(&sf);
     }
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index aa66145..339e85c 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -97,6 +97,22 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
 }
 
 //----------------------------------------------------------------------------
+bool cmLocalVisualStudioGenerator
+::HasExplicitObjectName(cmSourceFile const* file) const
+{
+  std::set<cmSourceFile const*>::const_iterator it
+                                        = this->ExplicitObjectName.find(file);
+  return it != this->ExplicitObjectName.end();
+}
+
+//----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator
+::AddExplicitObjectName(cmSourceFile* sf)
+{
+  this->ExplicitObjectName.insert(sf);
+}
+
+//----------------------------------------------------------------------------
 void cmLocalVisualStudioGenerator
 ::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
 {
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 168fc02..f98b669 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -63,6 +63,9 @@ public:
 
   void GetDirectoryForObjects(cmTarget* tgt, std::string& dir);
 
+  bool HasExplicitObjectName(cmSourceFile const* file) const;
+  void AddExplicitObjectName(cmSourceFile* sf);
+
 protected:
   virtual const char* ReportErrorLabel() const;
   virtual bool CustomCommandUseLocal() const { return false; }
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 90155b4..5bb3b36 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1094,7 +1094,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
   cmSourceFile& sf = *source;
 
   std::string objectName;
-  if(this->GeneratorTarget->HasExplicitObjectName(&sf))
+  if(this->LocalGenerator->HasExplicitObjectName(&sf))
     {
     objectName = this->GeneratorTarget->GetObjectName(&sf);
     }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b6f55c9a9cb10333c448439ba083832a1e8e4fb
commit 8b6f55c9a9cb10333c448439ba083832a1e8e4fb
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 11 17:51:10 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:42 2014 +0100

    cmLocalGenerator: Add GetDirectoryForObjects method.
    
    The Makefile and Ninja generators use GetObjectDirectory for this,
    but Visual Studio uses a separate calculation, and Xcode does not
    need it at all. Add an empty implementation for Xcode because this
    will allow the object filenames to be computed in generic code
    in a follow-up commit.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 60f7989..36bdd4c 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -637,9 +637,12 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
   cmTarget* target = gt->Target;
 
   // Compute full path to object file directory for this target.
+  std::string obj_dir;
+  gt->LocalGenerator->GetObjectDirectory(target, obj_dir);
+  gt->ObjectDirectory = obj_dir;
+
   std::string dir_max;
-  gt->LocalGenerator->GetObjectDirectory(target, dir_max);
-  gt->ObjectDirectory = dir_max;
+  gt->LocalGenerator->GetDirectoryForObjects(target, dir_max);
 
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index c0a7676..220ca47 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -110,9 +110,12 @@ cmGlobalUnixMakefileGenerator3
 {
   cmTarget* target = gt->Target;
   // Compute full path to object file directory for this target.
+  std::string obj_dir;
+  gt->LocalGenerator->GetObjectDirectory(target, obj_dir);
+  gt->ObjectDirectory = obj_dir;
+
   std::string dir_max;
-  gt->LocalGenerator->GetObjectDirectory(target, dir_max);
-  gt->ObjectDirectory = dir_max;
+  gt->LocalGenerator->GetDirectoryForObjects(target, dir_max);
 
   std::vector<cmSourceFile*> objectSources;
   gt->GetObjectSources(objectSources);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 8f13d27..6c280f1 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -124,7 +124,9 @@ cmGlobalVisualStudioGenerator
 {
   cmLocalVisualStudioGenerator* lg =
     static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator);
-  std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target);
+
+  std::string dir_max;
+  gt->LocalGenerator->GetDirectoryForObjects(gt->Target, dir_max);
 
   // Count the number of object files with each name.  Note that
   // windows file names are not case sensitive.
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 3a81444..0d52a31 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3098,6 +3098,12 @@ void cmLocalGenerator::ComputeObjectDirectory(cmTarget*, std::string&)
 }
 
 //----------------------------------------------------------------------------
+void cmLocalGenerator::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
+{
+  this->GetObjectDirectory(tgt, dir);
+}
+
+//----------------------------------------------------------------------------
 std::string
 cmLocalGenerator
 ::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index c28c134..5a70bf7 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -372,6 +372,7 @@ public:
                       cmGeneratorTarget* target);
 
   void GetObjectDirectory(cmTarget* tgt, std::string& dir);
+  virtual void GetDirectoryForObjects(cmTarget* tgt, std::string& dir);
 
 protected:
   ///! put all the libraries for a target on into the given stream
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 9b8645b..aa66145 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -97,6 +97,13 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
 }
 
 //----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator
+::GetDirectoryForObjects(cmTarget* tgt, std::string& dir)
+{
+  dir = this->ComputeLongestObjectDirectory(*tgt);
+}
+
+//----------------------------------------------------------------------------
 std::string
 cmLocalVisualStudioGenerator
 ::ConstructScript(cmCustomCommand const& cc,
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 040a119..168fc02 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -61,6 +61,8 @@ public:
 
   virtual void AddCMakeListsRules() = 0;
 
+  void GetDirectoryForObjects(cmTarget* tgt, std::string& dir);
+
 protected:
   virtual const char* ReportErrorLabel() const;
   virtual bool CustomCommandUseLocal() const { return false; }
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 75990bd..c32469e 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -73,6 +73,12 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
 }
 
 //----------------------------------------------------------------------------
+void cmLocalXCodeGenerator::GetDirectoryForObjects(cmTarget*,
+                                                   std::string&)
+{
+}
+
+//----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::ComputeObjectDirectory(cmTarget* tgt,
                                                    std::string& dir)
 {
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 01e7601..8526d18 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -32,6 +32,7 @@ public:
                                 const std::string& rawFlag);
   virtual void Generate();
   virtual void GenerateInstallRules();
+  void GetDirectoryForObjects(cmTarget*,std::string&);
 private:
   virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44b32675bf3b223e21a23516b8c2c07961ad88d6
commit 44b32675bf3b223e21a23516b8c2c07961ad88d6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 11 17:07:33 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 12 19:10:07 2014 +0100

    cmLocalGenerator: Add GetObjectDirectory method.
    
    Use NVI to compute and cache the result from concrete generators.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 0a05f5a..60f7989 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -638,10 +638,7 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
 
   // 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->LocalGenerator->GetObjectDirectory(target, dir_max);
   gt->ObjectDirectory = dir_max;
 
   std::vector<cmSourceFile*> objectSources;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 0e03e89..c0a7676 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -111,10 +111,7 @@ cmGlobalUnixMakefileGenerator3
   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->LocalGenerator->GetObjectDirectory(target, dir_max);
   gt->ObjectDirectory = dir_max;
 
   std::vector<cmSourceFile*> objectSources;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 69c893c..8f13d27 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -160,20 +160,8 @@ cmGlobalVisualStudioGenerator
     gt->AddObject(sf, objectName);
     }
 
-  std::string dir = gt->Makefile->GetCurrentOutputDirectory();
-  dir += "/";
-  std::string tgtDir = lg->GetTargetDirectory(*gt->Target);
-  if(!tgtDir.empty())
-    {
-    dir += tgtDir;
-    dir += "/";
-    }
-  const char* cd = this->GetCMakeCFGIntDir();
-  if(cd && *cd)
-    {
-    dir += cd;
-    dir += "/";
-    }
+  std::string dir;
+  gt->LocalGenerator->GetObjectDirectory(gt->Target, dir);
   gt->ObjectDirectory = dir;
 }
 
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 30a2a1e..b97b133 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3978,21 +3978,7 @@ cmGlobalXCodeGenerator
     gt->AddObject(sf, objectName);
     }
 
-  const char* configName = this->GetCMakeCFGIntDir();
-  std::string dir = this->GetObjectsNormalDirectory(
-    "$(PROJECT_NAME)", configName, gt->Target);
-  if(this->XcodeVersion >= 21)
-    {
-    dir += "$(CURRENT_ARCH)/";
-    }
-  else
-    {
-#ifdef __ppc__
-    dir += "ppc/";
-#endif
-#ifdef __i386
-    dir += "i386/";
-#endif
-    }
+  std::string dir;
+  gt->LocalGenerator->GetObjectDirectory(*gt->Target, dir);
   gt->ObjectDirectory = dir;
 }
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 93315ba..655fb23 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -91,6 +91,14 @@ public:
 
   virtual bool SetGeneratorToolset(std::string const& ts);
   void AppendFlag(std::string& flags, std::string const& flag);
+
+  std::string GetObjectsNormalDirectory(
+    const std::string &projName,
+    const std::string &configName,
+    const cmTarget *t) const;
+
+  int GetXcodeVersion() const { return this->XcodeVersion; }
+
 private:
   cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
                                      cmSourceGroup* sg);
@@ -220,11 +228,6 @@ private:
                            const char*) const {}
   void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
-  std::string GetObjectsNormalDirectory(
-    const std::string &projName,
-    const std::string &configName,
-    const cmTarget *t) const;
-
   void addObject(cmXCodeObject *obj);
   std::string PostBuildMakeTarget(std::string const& tName,
                                   std::string const& configName);
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index de8dd51..3a81444 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3080,6 +3080,24 @@ cmLocalGenerator
 }
 
 //----------------------------------------------------------------------------
+void cmLocalGenerator::GetObjectDirectory(cmTarget* tgt, std::string& dir)
+{
+  std::map<cmTarget*, std::string>::const_iterator it
+                                      = this->ObjectDirectoryCache.find(tgt);
+  if (it == this->ObjectDirectoryCache.end())
+    {
+    this->ComputeObjectDirectory(tgt, this->ObjectDirectoryCache[tgt]);
+    }
+  dir = this->ObjectDirectoryCache[tgt];
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::ComputeObjectDirectory(cmTarget*, std::string&)
+{
+
+}
+
+//----------------------------------------------------------------------------
 std::string
 cmLocalGenerator
 ::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 4d62833..c28c134 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -371,6 +371,8 @@ public:
                       std::string& linkPath,
                       cmGeneratorTarget* target);
 
+  void GetObjectDirectory(cmTarget* tgt, std::string& dir);
+
 protected:
   ///! put all the libraries for a target on into the given stream
   virtual void OutputLinkLibraries(std::string& linkLibraries,
@@ -475,6 +477,9 @@ protected:
   cmIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
 private:
+  std::map<cmTarget*, std::string> ObjectDirectoryCache;
+  virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
+
   std::string ConvertToOutputForExistingCommon(const std::string& remote,
                                                std::string const& result,
                                                OutputFormat format);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index acaacdd..abb156c 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -267,6 +267,16 @@ void cmLocalNinjaGenerator::SetConfigName()
     }
 }
 
+//----------------------------------------------------------------------------
+void cmLocalNinjaGenerator::ComputeObjectDirectory(cmTarget* tgt,
+                                                   std::string& dir)
+{
+  dir = this->GetMakefile()->GetCurrentOutputDirectory();
+  dir += "/";
+  dir += this->GetTargetDirectory(*tgt);
+  dir += "/";
+}
+
 void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 2d870fb..17365e7 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -100,6 +100,8 @@ public:
   virtual std::string ConvertToLinkReference(std::string const& lib,
                                              OutputFormat format = SHELL);
 
+private:
+  virtual void ComputeObjectDirectory(cmTarget*, std::string&);
 
 protected:
   virtual std::string ConvertToIncludeReference(std::string const& path,
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 27db03b..5d22392 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -172,6 +172,16 @@ void cmLocalUnixMakefileGenerator3::Generate()
 }
 
 //----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::ComputeObjectDirectory(cmTarget* tgt,
+                                                           std::string& dir)
+{
+  dir = this->GetMakefile()->GetCurrentOutputDirectory();
+  dir += "/";
+  dir += this->GetTargetDirectory(*tgt);
+  dir += "/";
+}
+
+//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::
 GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
 {
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 73b425e..85ce69a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -242,6 +242,9 @@ public:
   // Eclipse generator.
   void GetIndividualFileTargets(std::vector<std::string>& targets);
 
+private:
+  virtual void ComputeObjectDirectory(cmTarget*, std::string&);
+
 protected:
   void WriteLocalMakefile();
 
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 6e93d22..9b8645b 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -31,6 +31,26 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
 }
 
 //----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::ComputeObjectDirectory(cmTarget* tgt,
+                                                          std::string& dir)
+{
+  dir = this->GetMakefile()->GetCurrentOutputDirectory();
+  dir += "/";
+  std::string tgtDir = this->GetTargetDirectory(*tgt);
+  if(!tgtDir.empty())
+    {
+    dir += tgtDir;
+    dir += "/";
+    }
+  const char* cd = this->GetGlobalGenerator()->GetCMakeCFGIntDir();
+  if(cd && *cd)
+    {
+    dir += cd;
+    dir += "/";
+    }
+}
+
+//----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCustomCommand>
 cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
                                                    const std::string& config,
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 94a6293..040a119 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -71,6 +71,8 @@ protected:
                        bool isFortran);
 
   VSVersion Version;
+private:
+  virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
 };
 
 #endif
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 5857aef..75990bd 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -71,3 +71,26 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
     t->HasMacOSXRpathInstallNameDir("");
     }
 }
+
+//----------------------------------------------------------------------------
+void cmLocalXCodeGenerator::ComputeObjectDirectory(cmTarget* tgt,
+                                                   std::string& dir)
+{
+  cmGlobalXCodeGenerator* gg =
+    static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
+  const char* configName = gg->GetCMakeCFGIntDir();
+  dir = gg->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, tgt);
+  if(gg->GetXcodeVersion() >= 21)
+    {
+    dir += "$(CURRENT_ARCH)/";
+    }
+  else
+    {
+#ifdef __ppc__
+    dir += "ppc/";
+#endif
+#ifdef __i386
+    dir += "i386/";
+#endif
+    }
+}
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 3bfe3a3..01e7601 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -33,6 +33,7 @@ public:
   virtual void Generate();
   virtual void GenerateInstallRules();
 private:
+  virtual void ComputeObjectDirectory(cmTarget* tgt, std::string& dir);
 
 };
 

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list