[cmake-commits] king committed cmGlobalUnixMakefileGenerator3.cxx 1.119 1.120 cmGlobalVisualStudio71Generator.cxx 1.43 1.44 cmGlobalVisualStudio8Generator.h 1.11 1.12 cmGlobalVisualStudioGenerator.cxx 1.8 1.9 cmGlobalVisualStudioGenerator.h 1.5 1.6 cmGlobalXCodeGenerator.cxx 1.171 1.172

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Dec 21 15:04:08 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv17462/Source

Modified Files:
	cmGlobalUnixMakefileGenerator3.cxx 
	cmGlobalVisualStudio71Generator.cxx 
	cmGlobalVisualStudio8Generator.h 
	cmGlobalVisualStudioGenerator.cxx 
	cmGlobalVisualStudioGenerator.h cmGlobalXCodeGenerator.cxx 
Log Message:
ENH: Make static library targets depend on targets to which they "link" for the purpose of build ordering.  This makes the build order consistent for static and shared library builds.  It is also useful when custom command inputs of one library are generated as custom commands outputs of another.  It may be useful in the future for Fortran module dependencies.  Implemented for Makefiles, Xcode, and VS 8 and above.  Added sample code to do it for VS 7.1 and below, but left it disabled with comments explaining why.  Likely it will never be needed on VS 7.1 or below anyway.


Index: cmGlobalVisualStudio8Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cmGlobalVisualStudio8Generator.h	16 Nov 2007 12:01:58 -0000	1.11
+++ cmGlobalVisualStudio8Generator.h	21 Dec 2007 20:04:06 -0000	1.12
@@ -59,8 +59,7 @@
 
 protected:
 
-  // Utility target fix is not needed for VS8.
-  virtual void FixUtilityDepends() {}
+  virtual bool VSLinksDependencies() const { return false; }
 
   static cmVS7FlagTable const* GetExtraFlagTableVS8();
   virtual void AddPlatformDefinitions(cmMakefile* mf);

Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- cmGlobalXCodeGenerator.cxx	18 Dec 2007 14:50:08 -0000	1.171
+++ cmGlobalXCodeGenerator.cxx	21 Dec 2007 20:04:06 -0000	1.172
@@ -2006,34 +2006,33 @@
     }
 
   // Add dependencies on other CMake targets.
-  if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY)
-    {
-    // Keep track of dependencies already listed.
-    std::set<cmStdString> emitted;
+  {
+  // Keep track of dependencies already listed.
+  std::set<cmStdString> emitted;
 
-    // A target should not depend on itself.
-    emitted.insert(cmtarget->GetName());
+  // A target should not depend on itself.
+  emitted.insert(cmtarget->GetName());
 
-    // Loop over all library dependencies.
-    const cmTarget::LinkLibraryVectorType& tlibs = 
-      cmtarget->GetLinkLibraries();
-    for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
-        lib != tlibs.end(); ++lib)
+  // Loop over all library dependencies.
+  const cmTarget::LinkLibraryVectorType& tlibs = 
+    cmtarget->GetLinkLibraries();
+  for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
+      lib != tlibs.end(); ++lib)
+    {
+    // Don't emit the same library twice for this target.
+    if(emitted.insert(lib->first).second)
       {
-      // Don't emit the same library twice for this target.
-      if(emitted.insert(lib->first).second)
+      // Add this dependency.
+      cmTarget* t = this->FindTarget(this->CurrentProject.c_str(),
+                                     lib->first.c_str(), false);
+      cmXCodeObject* dptarget = this->FindXCodeTarget(t);
+      if(dptarget)
         {
-        // Add this dependency.
-        cmTarget* t = this->FindTarget(this->CurrentProject.c_str(),
-                                       lib->first.c_str(), false);
-        cmXCodeObject* dptarget = this->FindXCodeTarget(t);
-        if(dptarget)
-          {
-          this->AddDependTarget(target, dptarget);
-          }
+        this->AddDependTarget(target, dptarget);
         }
       }
     }
+  }
   
   // write utility dependencies.
   for(std::set<cmStdString>::const_iterator i

Index: cmGlobalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.cxx,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- cmGlobalUnixMakefileGenerator3.cxx	21 Dec 2007 18:10:33 -0000	1.119
+++ cmGlobalUnixMakefileGenerator3.cxx	21 Dec 2007 20:04:06 -0000	1.120
@@ -903,24 +903,21 @@
 
   // A target should not depend on itself.
   emitted.insert(target.GetName());
-  
-  // Loop over all library dependencies but not for static libs
-  if (target.GetType() != cmTarget::STATIC_LIBRARY)
+
+  // Loop over all library dependencies.
+  const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
+  for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
+      lib != tlibs.end(); ++lib)
     {
-    const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
-    for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
-        lib != tlibs.end(); ++lib)
+    // Don't emit the same library twice for this target.
+    if(emitted.insert(lib->first).second)
       {
-      // Don't emit the same library twice for this target.
-      if(emitted.insert(lib->first).second)
-        {
-        // Add this dependency.
-        this->AppendAnyGlobalDepend(depends, lib->first.c_str(), 
-                                    emitted, target);
-        }
+      // Add this dependency.
+      this->AppendAnyGlobalDepend(depends, lib->first.c_str(),
+                                  emitted, target);
       }
     }
-  
+
   // Loop over all utility dependencies.
   const std::set<cmStdString>& tutils = target.GetUtilities();
   for(std::set<cmStdString>::const_iterator util = tutils.begin();
@@ -967,24 +964,6 @@
     std::string tgtName = lg3->GetRelativeTargetDirectory(*result);
     tgtName += "/all";
     depends.push_back(tgtName);
-    if(result->GetType() == cmTarget::STATIC_LIBRARY)
-      {
-      // Since the static library itself does not list dependencies we
-      // need to chain its dependencies here.
-      const cmTarget::LinkLibraryVectorType& tlibs 
-        = result->GetLinkLibraries();
-      for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
-          lib != tlibs.end(); ++lib)
-        {
-        // Don't emit the same library twice for this target.
-        if(emitted.insert(lib->first).second)
-          {
-          // Add this dependency.
-          this->AppendAnyGlobalDepend(depends, lib->first.c_str(),
-                                      emitted, *result);
-          }
-        }
-      }
     return;
     }
 }

Index: cmGlobalVisualStudio71Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio71Generator.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cmGlobalVisualStudio71Generator.cxx	22 Oct 2007 16:48:39 -0000	1.43
+++ cmGlobalVisualStudio71Generator.cxx	21 Dec 2007 20:04:06 -0000	1.44
@@ -317,8 +317,14 @@
                       const char* dspname,
                       const char*, cmTarget& target)
 {
-  // insert Begin Project Dependency  Project_Dep_Name project stuff here 
-  if (target.GetType() != cmTarget::STATIC_LIBRARY)
+  // Create inter-target dependencies in the solution file.  For VS
+  // 7.1 and below we cannot let static libraries depend directly on
+  // targets to which they "link" because the librarian tool will copy
+  // the targets into the static library.  See
+  // cmGlobalVisualStudioGenerator::FixUtilityDependsForTarget for a
+  // work-around.  VS 8 and above do not have this problem.
+  if (!this->VSLinksDependencies() ||
+      target.GetType() != cmTarget::STATIC_LIBRARY)
     {
     cmTarget::LinkLibraryVectorType::const_iterator j, jend;
     j = target.GetLinkLibraries().begin();

Index: cmGlobalVisualStudioGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmGlobalVisualStudioGenerator.h	19 Nov 2007 18:44:51 -0000	1.5
+++ cmGlobalVisualStudioGenerator.h	21 Dec 2007 20:04:06 -0000	1.6
@@ -60,9 +60,14 @@
 
 protected:
   virtual void CreateGUID(const char*) {}
-  virtual void FixUtilityDepends();
+  void FixUtilityDepends();
   const char* GetUtilityForTarget(cmTarget& target, const char*);
 
+  // Does this VS version link targets to each other if there are
+  // dependencies in the SLN file?  This was done for VS versions
+  // below 8.
+  virtual bool VSLinksDependencies() const { return true; }
+
 private:
   void FixUtilityDependsForTarget(cmTarget& target);
   void CreateUtilityDependTarget(cmTarget& target);

Index: cmGlobalVisualStudioGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmGlobalVisualStudioGenerator.cxx	20 Nov 2007 16:10:11 -0000	1.8
+++ cmGlobalVisualStudioGenerator.cxx	21 Dec 2007 20:04:06 -0000	1.9
@@ -197,6 +197,12 @@
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FixUtilityDepends()
 {
+  // Skip for VS versions 8 and above.
+  if(!this->VSLinksDependencies())
+    {
+    return;
+    }
+
   // For VS versions before 8:
   //
   // When a target that links contains a project-level dependency on a
@@ -232,6 +238,33 @@
     return;
     }
 
+#if 0
+  // This feature makes a mess in SLN files for VS 7.1 and below.  It
+  // creates an extra target for every target that is "linked" by a
+  // static library.  Without this feature static libraries do not
+  // wait until their "link" dependencies are built to build.  This is
+  // not a problem 99.9% of the time, and projects that do have the
+  // problem can enable this work-around by using add_dependencies.
+
+  // Static libraries cannot depend directly on the targets to which
+  // they link because VS will copy those targets into the library
+  // (for VS < 8).  To work around the problem we copy the
+  // dependencies to be utility dependencies so that the work-around
+  // below is used.
+  if(target.GetType() == cmTarget::STATIC_LIBRARY)
+    {
+    cmTarget::LinkLibraryVectorType const& libs = target.GetLinkLibraries();
+    for(cmTarget::LinkLibraryVectorType::const_iterator i = libs.begin();
+        i != libs.end(); ++i)
+      {
+      if(cmTarget* depTarget = this->FindTarget(0, i->first.c_str(), false))
+        {
+        target.AddUtility(depTarget->GetName());
+        }
+      }
+    }
+#endif
+
   // Look at each utility dependency.
   for(std::set<cmStdString>::const_iterator ui =
         target.GetUtilities().begin();



More information about the Cmake-commits mailing list