[Cmake-commits] CMake branch, next, updated. v3.0.0-rc1-494-gd9cbfc2

Brad King brad.king at kitware.com
Tue Mar 4 14:55:54 EST 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  d9cbfc29bfc1e497265d96e65652fe44c61e10d0 (commit)
       via  1db938fd2b3f4be4defec9e45735ad2086ed9ed1 (commit)
       via  5e8e4d0f8819052d3a69eb3cb1a4bdbc674a956c (commit)
       via  b9aa5041989a415a360e61291142e760ae7eb9e1 (commit)
       via  971653b767f2e5e81085c525c94d5e596474aa88 (commit)
       via  0c0ef9e7b7016f8ce6310c30660151b15e062a93 (commit)
       via  02bebd60e9255b6e3eb4bbd6208b4c5cd8f5da40 (commit)
       via  c87517099abbef70b9718a3920954e9097f36bbe (commit)
      from  5c4a0297d894b5398baed893674780de22acfae2 (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=d9cbfc29bfc1e497265d96e65652fe44c61e10d0
commit d9cbfc29bfc1e497265d96e65652fe44c61e10d0
Merge: 5c4a029 1db938f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 14:55:52 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Mar 4 14:55:52 2014 -0500

    Merge topic 'link-libraries-response-files' into next
    
    1db938fd Windows: Use response files for link libs with GNU tools
    5e8e4d0f cmLocalGenerator: Add response file option to OutputLinkLibraries
    b9aa5041 cmLocalGenerator: Simplify GetIncludeFlags output formatting
    971653b7 cmLocalGenerator: Add format option to ConvertToLinkReference
    0c0ef9e7 cmLocalGenerator: Add format option to ConvertToIncludeReference
    02bebd60 cmLocalGenerator: Add format option to ConvertToOutputForExisting
    c8751709 Makefile: Factor out some duplicate link libraries generation


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1db938fd2b3f4be4defec9e45735ad2086ed9ed1
commit 1db938fd2b3f4be4defec9e45735ad2086ed9ed1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 13:20:27 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 14:11:25 2014 -0500

    Windows: Use response files for link libs with GNU tools
    
    Work around the command-line-length limit by using an @linklibs.rsp
    response file to pass the flags for link libraries.  This allows
    very long lists of libraries to be used in addition to the existing
    support for passing object files via response file.
    
    Inspired-by: Peter Keuschnigg <peter.keuschnigg at pmu.ac.at>

diff --git a/Help/release/dev/link-libraries-response-files.rst b/Help/release/dev/link-libraries-response-files.rst
new file mode 100644
index 0000000..624abf5
--- /dev/null
+++ b/Help/release/dev/link-libraries-response-files.rst
@@ -0,0 +1,9 @@
+link-libraries-response-files
+-----------------------------
+
+* The Makefile generators learned to use response files with
+  GNU tools on Windows to pass the list of link directories
+  and libraries when linking executables and shared libraries.
+  This matches the approach already used for passing include
+  directories to the compiler and object files to the linker
+  or archiver.  It allows very long lists of libraries.
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 696ce94..4bca752 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -325,7 +325,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
 
   // Collect up flags to link in needed libraries.
   std::string linkLibs;
-  this->CreateLinkLibs(linkLibs, relink, depends);
+  this->CreateLinkLibs(linkLibs, relink, useResponseFile, depends);
 
   // Construct object file lists that may be needed to expand the
   // rule.
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 2832515..4f053ab 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -546,7 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::string linkLibs;
   if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
     {
-    this->CreateLinkLibs(linkLibs, relink, depends);
+    this->CreateLinkLibs(linkLibs, relink, useResponseFile, depends);
     }
 
   // Construct object file lists that may be needed to expand the
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 0f2b6e3..facbcc6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1834,14 +1834,40 @@ cmMakefileTargetGenerator
 void
 cmMakefileTargetGenerator
 ::CreateLinkLibs(std::string& linkLibs, bool relink,
+                 bool useResponseFile,
                  std::vector<std::string>& makefile_depends)
 {
   std::string frameworkPath;
   std::string linkPath;
   this->LocalGenerator
     ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                          *this->GeneratorTarget, relink, false);
+                          *this->GeneratorTarget, relink,
+                          useResponseFile);
   linkLibs = frameworkPath + linkPath + linkLibs;
+
+  if(useResponseFile)
+    {
+    // Lookup the response file reference flag.
+    std::string responseFlagVar = "CMAKE_";
+    responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
+    responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+    const char* responseFlag =
+      this->Makefile->GetDefinition(responseFlagVar.c_str());
+    if(!responseFlag)
+      {
+      responseFlag = "@";
+      }
+
+    // Create this response file.
+    std::string link_rsp =
+      this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
+
+    // Reference the response file.
+    linkLibs = responseFlag;
+    linkLibs += this->Convert(link_rsp.c_str(),
+                              cmLocalGenerator::NONE,
+                              cmLocalGenerator::SHELL);
+    }
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index d47708d..72dc6bc 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -165,6 +165,7 @@ protected:
 
   /** Create list of flags for link libraries. */
   void CreateLinkLibs(std::string& linkLibs, bool relink,
+                      bool useResponseFile,
                       std::vector<std::string>& makefile_depends);
 
   /** Create lists of object files for linking and cleaning.  */

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5e8e4d0f8819052d3a69eb3cb1a4bdbc674a956c
commit 5e8e4d0f8819052d3a69eb3cb1a4bdbc674a956c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 13:20:04 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 13:41:59 2014 -0500

    cmLocalGenerator: Add response file option to OutputLinkLibraries
    
    Response files require different path conversion to be threaded
    through construction of the link libraries flags.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index aa64e80..b86a956 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1671,7 +1671,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
           }
         }
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false);
+                                *target, false, false);
       }
       break;
     case cmTarget::EXECUTABLE:
@@ -1696,7 +1696,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         }
       this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false);
+                                *target, false, false);
       if(cmSystemTools::IsOn
          (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
         {
@@ -1793,8 +1793,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
                                            std::string& frameworkPath,
                                            std::string& linkPath,
                                            cmGeneratorTarget &tgt,
-                                           bool relink)
+                                           bool relink,
+                                           bool forResponseFile)
 {
+  OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
+  bool escapeAllowMakeVars = !forResponseFile;
   cmOStringStream fout;
   const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
   cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
@@ -1837,7 +1840,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
         fdi != fwDirs.end(); ++fdi)
       {
       frameworkPath += fwSearchFlag;
-      frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
+      frameworkPath += this->Convert(fdi->c_str(), NONE, shellFormat, false);
       frameworkPath += " ";
       }
     }
@@ -1847,7 +1850,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
   for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
       libDir != libDirs.end(); ++libDir)
     {
-    std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
+    std::string libpath = this->ConvertToOutputForExisting(libDir->c_str(),
+                                                           START_OUTPUT,
+                                                           shellFormat);
     linkPath += " " + libPathFlag;
     linkPath += libpath;
     linkPath += libPathTerminator;
@@ -1865,7 +1870,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
       }
     if(li->IsPath)
       {
-      linkLibs += this->ConvertToLinkReference(li->Value);
+      linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
       }
     else
       {
@@ -1890,7 +1895,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
         ri != runtimeDirs.end(); ++ri)
       {
       rpath += cli.GetRuntimeFlag();
-      rpath += this->Convert(ri->c_str(), NONE, SHELL, false);
+      rpath += this->Convert(ri->c_str(), NONE, shellFormat, false);
       rpath += " ";
       }
     fout << rpath;
@@ -1904,7 +1909,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
     if(!rpath.empty())
       {
       fout << cli.GetRuntimeFlag();
-      fout << this->EscapeForShell(rpath.c_str(), true);
+      fout << this->EscapeForShell(rpath.c_str(), escapeAllowMakeVars);
       fout << " ";
       }
     }
@@ -1914,7 +1919,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
   if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
     {
     fout << cli.GetRPathLinkFlag();
-    fout << this->EscapeForShell(rpath_link.c_str(), true);
+    fout << this->EscapeForShell(rpath_link.c_str(), escapeAllowMakeVars);
     fout << " ";
     }
 
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 2a76124..2e05804 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -372,7 +372,8 @@ protected:
                                    std::string& frameworkPath,
                                    std::string& linkPath,
                                    cmGeneratorTarget &,
-                                   bool relink);
+                                   bool relink,
+                                   bool forResponseFile);
 
   // Expand rule variables in CMake of the type found in language rules
   void ExpandRuleVariables(std::string& string,
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e5b163b..0f2b6e3 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1840,7 +1840,7 @@ cmMakefileTargetGenerator
   std::string linkPath;
   this->LocalGenerator
     ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                          *this->GeneratorTarget, relink);
+                          *this->GeneratorTarget, relink, false);
   linkLibs = frameworkPath + linkPath + linkLibs;
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9aa5041989a415a360e61291142e760ae7eb9e1
commit b9aa5041989a415a360e61291142e760ae7eb9e1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 13:12:54 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 13:12:54 2014 -0500

    cmLocalGenerator: Simplify GetIncludeFlags output formatting
    
    Use the output format argument to ConvertToIncludeReference.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1372c2a..aa64e80 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1295,6 +1295,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
     return "";
     }
 
+  OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
   cmOStringStream includeFlags;
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
@@ -1354,10 +1355,9 @@ std::string cmLocalGenerator::GetIncludeFlags(
       frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
       if(emitted.insert(frameworkDir).second)
         {
-        OutputFormat format = forResponseFile? RESPONSE : SHELL;
         includeFlags
           << fwSearchFlag << this->Convert(frameworkDir.c_str(),
-                                           START_OUTPUT, format, true)
+                                           START_OUTPUT, shellFormat, true)
           << " ";
         }
       continue;
@@ -1376,16 +1376,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
         }
       flagUsed = true;
       }
-    std::string includePath;
-    if(forResponseFile)
-      {
-      includePath = this->Convert(i->c_str(), START_OUTPUT,
-                                  RESPONSE, true);
-      }
-    else
-      {
-      includePath = this->ConvertToIncludeReference(*i);
-      }
+    std::string includePath =
+      this->ConvertToIncludeReference(*i, shellFormat);
     if(quotePaths && includePath.size() && includePath[0] != '\"')
       {
       includeFlags << "\"";

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=971653b767f2e5e81085c525c94d5e596474aa88
commit 971653b767f2e5e81085c525c94d5e596474aa88
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 13:06:29 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 13:12:47 2014 -0500

    cmLocalGenerator: Add format option to ConvertToLinkReference
    
    Replace the hard-coded SHELL output format with an optional argument.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 2090cc6..1372c2a 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1759,7 +1759,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
     }
 }
 
-std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
+std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
+                                                     OutputFormat format)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   // Work-ardound command line parsing limitations in MSVC 6.0 and
@@ -1781,14 +1782,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
         sp += lib.substr(pos);
 
         // Convert to an output path.
-        return this->Convert(sp.c_str(), NONE, SHELL);
+        return this->Convert(sp.c_str(), NONE, format);
         }
       }
     }
 #endif
 
   // Normal behavior.
-  return this->Convert(lib.c_str(), START_OUTPUT, SHELL);
+  return this->Convert(lib.c_str(), START_OUTPUT, format);
 }
 
 /**
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 986f405..2a76124 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -415,7 +415,8 @@ protected:
   std::string FindRelativePathTopBinary();
   void SetupPathConversions();
 
-  virtual std::string ConvertToLinkReference(std::string const& lib);
+  virtual std::string ConvertToLinkReference(std::string const& lib,
+                                             OutputFormat format = SHELL);
 
   /** Check whether the native build system supports the given
       definition.  Issues a warning.  */
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c989cfb..862823f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -143,9 +143,10 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
 // Virtual protected methods.
 
 std::string
-cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib)
+cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib,
+                                              OutputFormat format)
 {
-  return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL);
+  return this->Convert(lib.c_str(), HOME_OUTPUT, format);
 }
 
 std::string
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index b3d3b6b..8b26806 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -97,7 +97,8 @@ public:
   void AppendCustomCommandDeps(const cmCustomCommand *cc,
                                cmNinjaDeps &ninjaDeps);
 
-  virtual std::string ConvertToLinkReference(std::string const& lib);
+  virtual std::string ConvertToLinkReference(std::string const& lib,
+                                             OutputFormat format = SHELL);
 
 
 protected:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c0ef9e7b7016f8ce6310c30660151b15e062a93
commit 0c0ef9e7b7016f8ce6310c30660151b15e062a93
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 13:04:02 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 13:04:02 2014 -0500

    cmLocalGenerator: Add format option to ConvertToIncludeReference
    
    Replace the hard-coded SHELL output format with an optional argument.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 87685d5..2090cc6 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1277,9 +1277,10 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
+                                            OutputFormat format)
 {
-  return this->ConvertToOutputForExisting(path.c_str());
+  return this->ConvertToOutputForExisting(path.c_str(), START_OUTPUT, format);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9e47120..986f405 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -207,7 +207,8 @@ public:
                                          const char* local = 0,
                                          OutputFormat format = SHELL);
 
-  virtual std::string ConvertToIncludeReference(std::string const& path);
+  virtual std::string ConvertToIncludeReference(std::string const& path,
+                                                OutputFormat format = SHELL);
 
   /** Called from command-line hook to clear dependencies.  */
   virtual void ClearDependencies(cmMakefile* /* mf */,
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cd12c9d..c989cfb 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -149,9 +149,10 @@ cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib)
 }
 
 std::string
-cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path,
+                                                 OutputFormat format)
 {
-  return this->Convert(path.c_str(), HOME_OUTPUT, SHELL);
+  return this->Convert(path.c_str(), HOME_OUTPUT, format);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index ea854c6..b3d3b6b 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -101,7 +101,8 @@ public:
 
 
 protected:
-  virtual std::string ConvertToIncludeReference(std::string const& path);
+  virtual std::string ConvertToIncludeReference(std::string const& path,
+                                                OutputFormat format = SHELL);
 
 
 private:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=02bebd60e9255b6e3eb4bbd6208b4c5cd8f5da40
commit 02bebd60e9255b6e3eb4bbd6208b4c5cd8f5da40
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 12:57:44 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 12:58:57 2014 -0500

    cmLocalGenerator: Add format option to ConvertToOutputForExisting
    
    Replace the hard-coded SHELL output format with an optional argument.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4266dd0..87685d5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1228,7 +1228,8 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
-                                                   std::string const& result)
+                                                   std::string const& result,
+                                                   OutputFormat format)
 {
   // If this is a windows shell, the result has a space, and the path
   // already exists, we can use a short-path to reference it without a
@@ -1239,7 +1240,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
     std::string tmp;
     if(cmSystemTools::GetShortPath(remote, tmp))
       {
-      return this->Convert(tmp.c_str(), NONE, SHELL, true);
+      return this->Convert(tmp.c_str(), NONE, format, true);
       }
     }
 
@@ -1250,26 +1251,28 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::ConvertToOutputForExisting(const char* remote,
-                                             RelativeRoot local)
+                                             RelativeRoot local,
+                                             OutputFormat format)
 {
   // Perform standard conversion.
-  std::string result = this->Convert(remote, local, SHELL, true);
+  std::string result = this->Convert(remote, local, format, true);
 
   // Consider short-path.
-  return this->ConvertToOutputForExistingCommon(remote, result);
+  return this->ConvertToOutputForExistingCommon(remote, result, format);
 }
 
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
-                                             const char* local)
+                                             const char* local,
+                                             OutputFormat format)
 {
   // Perform standard conversion.
-  std::string result = this->Convert(remote, local, SHELL, true);
+  std::string result = this->Convert(remote, local, format, true);
 
   // Consider short-path.
   const char* remotePath = this->GetRelativeRootPath(remote);
-  return this->ConvertToOutputForExistingCommon(remotePath, result);
+  return this->ConvertToOutputForExistingCommon(remotePath, result, format);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 0f7fd25..9e47120 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -198,12 +198,14 @@ public:
 
   ///! for existing files convert to output path and short path if spaces
   std::string ConvertToOutputForExisting(const char* remote,
-                                         RelativeRoot local = START_OUTPUT);
+                                         RelativeRoot local = START_OUTPUT,
+                                         OutputFormat format = SHELL);
 
   /** For existing path identified by RelativeRoot convert to output
       path and short path if spaces.  */
   std::string ConvertToOutputForExisting(RelativeRoot remote,
-                                         const char* local = 0);
+                                         const char* local = 0,
+                                         OutputFormat format = SHELL);
 
   virtual std::string ConvertToIncludeReference(std::string const& path);
 
@@ -465,7 +467,8 @@ protected:
   bool BackwardsCompatibilityFinal;
 private:
   std::string ConvertToOutputForExistingCommon(const char* remote,
-                                               std::string const& result);
+                                               std::string const& result,
+                                               OutputFormat format);
 
   void AddSharedFlags(std::string& flags, const char* lang, bool shared);
   bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c87517099abbef70b9718a3920954e9097f36bbe
commit c87517099abbef70b9718a3920954e9097f36bbe
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 4 11:20:27 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 4 11:20:27 2014 -0500

    Makefile: Factor out some duplicate link libraries generation
    
    The generators for executable and library targets duplicate the logic to
    call the OutputLinkLibraries helper on the local generator.  Factor it
    out into a cmMakefileTargetGenerator::CreateLinkLibs method to avoid
    dpulication.

diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 03fdda2..696ce94 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -325,12 +325,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
 
   // Collect up flags to link in needed libraries.
   std::string linkLibs;
-  std::string frameworkPath;
-  std::string linkPath;
-  this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                            *this->GeneratorTarget,
-                                            relink);
-  linkLibs = frameworkPath + linkPath + linkLibs;
+  this->CreateLinkLibs(linkLibs, relink, depends);
+
   // Construct object file lists that may be needed to expand the
   // rule.
   std::string buildObjs;
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 807aca8..2832515 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -546,12 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::string linkLibs;
   if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
     {
-    std::string frameworkPath;
-    std::string linkPath;
-    this->LocalGenerator
-      ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                            *this->GeneratorTarget, relink);
-    linkLibs = frameworkPath + linkPath + linkLibs;
+    this->CreateLinkLibs(linkLibs, relink, depends);
     }
 
   // Construct object file lists that may be needed to expand the
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e8a9fd1..e5b163b 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1833,6 +1833,20 @@ cmMakefileTargetGenerator
 //----------------------------------------------------------------------------
 void
 cmMakefileTargetGenerator
+::CreateLinkLibs(std::string& linkLibs, bool relink,
+                 std::vector<std::string>& makefile_depends)
+{
+  std::string frameworkPath;
+  std::string linkPath;
+  this->LocalGenerator
+    ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+                          *this->GeneratorTarget, relink);
+  linkLibs = frameworkPath + linkPath + linkLibs;
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
 ::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
                     bool useResponseFile, std::string& buildObjs,
                     std::vector<std::string>& makefile_depends)
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4f8fafa..d47708d 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -163,6 +163,10 @@ protected:
                                  std::string const& options,
                                  std::vector<std::string>& makefile_depends);
 
+  /** Create list of flags for link libraries. */
+  void CreateLinkLibs(std::string& linkLibs, bool relink,
+                      std::vector<std::string>& makefile_depends);
+
   /** Create lists of object files for linking and cleaning.  */
   void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
                          bool useResponseFile, std::string& buildObjs,

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

Summary of changes:
 Help/release/dev/link-libraries-response-files.rst |    9 +++
 Source/cmLocalGenerator.cxx                        |   70 ++++++++++----------
 Source/cmLocalGenerator.h                          |   18 +++--
 Source/cmLocalNinjaGenerator.cxx                   |   10 +--
 Source/cmLocalNinjaGenerator.h                     |    6 +-
 Source/cmMakefileExecutableTargetGenerator.cxx     |    8 +--
 Source/cmMakefileLibraryTargetGenerator.cxx        |    7 +-
 Source/cmMakefileTargetGenerator.cxx               |   40 +++++++++++
 Source/cmMakefileTargetGenerator.h                 |    5 ++
 9 files changed, 115 insertions(+), 58 deletions(-)
 create mode 100644 Help/release/dev/link-libraries-response-files.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list