[Cmake-commits] [cmake-commits] king committed cmGlobalVisualStudio7Generator.h 1.55 1.56 cmGlobalVisualStudio8Generator.cxx 1.41 1.42 cmGlobalVisualStudio8Generator.h 1.18 1.19 cmGlobalVisualStudioGenerator.h 1.14 1.15 cmLocalVisualStudio7Generator.cxx 1.256 1.257 cmVisualStudio10TargetGenerator.cxx 1.19 1.20

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Oct 20 16:38:39 EDT 2009


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

Modified Files:
	cmGlobalVisualStudio7Generator.h 
	cmGlobalVisualStudio8Generator.cxx 
	cmGlobalVisualStudio8Generator.h 
	cmGlobalVisualStudioGenerator.h 
	cmLocalVisualStudio7Generator.cxx 
	cmVisualStudio10TargetGenerator.cxx 
Log Message:
Do not link library dependencies in VS solutions

In VS 8 and greater this commit implements

  add_dependencies(myexe mylib) # depend without linking

by adding the

  LinkLibraryDependencies="false"

option to project files.  Previously the above code would cause myexe to
link to mylib in VS 8 and greater.  This option prevents dependencies
specified only in the solution from being linked.  We already specify
the real link library dependencies in the project files, and any project
depending on this to link would not have worked in Makefile generators.

We were already avoiding this problem in VS 7.1 and below by inserting
intermediate mylib_UTILITY targets.  It was more important for those
versions because if a static library depended on another library the
librarian would copy the dependees into the depender!  This is no longer
the case with VS 8 and above so we do not need that workaround.

See issue #9732.


Index: cmVisualStudio10TargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudio10TargetGenerator.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmVisualStudio10TargetGenerator.cxx	29 Sep 2009 20:39:07 -0000	1.19
--- cmVisualStudio10TargetGenerator.cxx	20 Oct 2009 20:38:37 -0000	1.20
***************
*** 1135,1138 ****
--- 1135,1145 ----
    
    this->WriteString("</Link>\n", 2);
+   if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target))
+     {
+     this->WriteString("<ProjectReference>\n", 2);
+     this->WriteString(
+       "  <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
+     this->WriteString("</ProjectReference>\n", 2);
+     }
  }
  

Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.256
retrieving revision 1.257
diff -C 2 -d -r1.256 -r1.257
*** cmLocalVisualStudio7Generator.cxx	19 Oct 2009 19:21:01 -0000	1.256
--- cmLocalVisualStudio7Generator.cxx	20 Oct 2009 20:38:37 -0000	1.257
***************
*** 847,850 ****
--- 847,852 ----
                                                      bool isDebug)
  {
+   cmGlobalVisualStudio7Generator* gg =
+     static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
    std::string temp;
    std::string extraLinkOptions;
***************
*** 950,953 ****
--- 952,959 ----
      fout << "\t\t\t<Tool\n"
           << "\t\t\t\tName=\"" << tool << "\"\n";
+     if(!gg->NeedLinkLibraryDependencies(target))
+       {
+       fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
+       }
      linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
      // Use the NOINHERIT macro to avoid getting VS project default
***************
*** 1022,1025 ****
--- 1028,1035 ----
      fout << "\t\t\t<Tool\n"
           << "\t\t\t\tName=\"" << tool << "\"\n";
+     if(!gg->NeedLinkLibraryDependencies(target))
+       {
+       fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
+       }
      linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
      // Use the NOINHERIT macro to avoid getting VS project default

Index: cmGlobalVisualStudio8Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** cmGlobalVisualStudio8Generator.h	19 Oct 2009 14:47:34 -0000	1.18
--- cmGlobalVisualStudio8Generator.h	20 Oct 2009 20:38:37 -0000	1.19
***************
*** 59,62 ****
--- 59,66 ----
    virtual std::string GetUserMacrosRegKeyBase();
  
+   /** Return true if the target project file should have the option
+       LinkLibraryDependencies and link to .sln dependencies. */
+   virtual bool NeedLinkLibraryDependencies(cmTarget& target);
+ 
  protected:
    virtual const char* GetIDEVersion() { return "8.0"; }

Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmGlobalVisualStudio8Generator.cxx	19 Oct 2009 14:47:34 -0000	1.41
--- cmGlobalVisualStudio8Generator.cxx	20 Oct 2009 20:38:37 -0000	1.42
***************
*** 282,285 ****
--- 282,308 ----
  
  //----------------------------------------------------------------------------
+ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
+   cmTarget& target)
+ {
+   // Look for utility dependencies that magically link.
+   for(std::set<cmStdString>::const_iterator ui =
+         target.GetUtilities().begin();
+       ui != target.GetUtilities().end(); ++ui)
+     {
+     if(cmTarget* depTarget = this->FindTarget(0, ui->c_str()))
+       {
+       if(depTarget->GetProperty("EXTERNAL_MSPROJECT"))
+         {
+         // This utility dependency names an external .vcproj target.
+         // We use LinkLibraryDependencies="true" to link to it without
+         // predicting the .lib file location or name.
+         return true;
+         }
+       }
+     }
+   return false;
+ }
+ 
+ //----------------------------------------------------------------------------
  static cmVS7FlagTable cmVS8ExtraFlagTable[] =
  { 

Index: cmGlobalVisualStudioGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmGlobalVisualStudioGenerator.h	1 Oct 2009 14:27:02 -0000	1.14
--- cmGlobalVisualStudioGenerator.h	20 Oct 2009 20:38:37 -0000	1.15
***************
*** 89,96 ****
                               TargetDependSet& originalTargets,
                               cmLocalGenerator* root, GeneratorVector const&);
  private:
    void FixUtilityDependsForTarget(cmTarget& target);
    void CreateUtilityDependTarget(cmTarget& target);
-   bool CheckTargetLinks(cmTarget& target, const char* name);
  };
  
--- 89,97 ----
                               TargetDependSet& originalTargets,
                               cmLocalGenerator* root, GeneratorVector const&);
+ 
+   bool CheckTargetLinks(cmTarget& target, const char* name);
  private:
    void FixUtilityDependsForTarget(cmTarget& target);
    void CreateUtilityDependTarget(cmTarget& target);
  };
  

Index: cmGlobalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -C 2 -d -r1.55 -r1.56
*** cmGlobalVisualStudio7Generator.h	19 Oct 2009 14:47:34 -0000	1.55
--- cmGlobalVisualStudio7Generator.h	20 Oct 2009 20:38:37 -0000	1.56
***************
*** 93,96 ****
--- 93,100 ----
    virtual const char* GetCMakeCFGInitDirectory()  { return "$(OutDir)"; }
  
+   /** Return true if the target project file should have the option
+       LinkLibraryDependencies and link to .sln dependencies. */
+   virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; }
+ 
  protected:
    virtual const char* GetIDEVersion() { return "7.0"; }



More information about the Cmake-commits mailing list