[cmake-commits] alex committed cmLocalGenerator.cxx 1.240 1.241 cmLocalGenerator.h 1.85 1.86

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Nov 26 17:57:41 EST 2007


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

Modified Files:
	cmLocalGenerator.cxx cmLocalGenerator.h 
Log Message:
STYLE: restructure OutputLinkLibraries() a bit, so that new there is a
function which returns the RPATH, so e.g. the install rpath can be queried
when the command for the build rpath is created. This is a first step for
supporting chrpath.

Alex


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -d -r1.240 -r1.241
--- cmLocalGenerator.cxx	22 Oct 2007 18:01:49 -0000	1.240
+++ cmLocalGenerator.cxx	26 Nov 2007 22:57:39 -0000	1.241
@@ -1476,15 +1476,15 @@
     }
 }
 
-/**
- * Output the linking rules on a command line.  For executables,
- * targetLibrary should be a NULL pointer.  For libraries, it should point
- * to the name of the library.  This will not link a library against itself.
- */
-void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
-                                           cmTarget& tgt,
-                                           bool relink)
+bool cmLocalGenerator::GetLinkerArgs(std::string& rpath, 
+                                     std::string& linkLibs,
+                                     cmTarget& tgt,
+                                     bool relink)
 {
+  rpath = "";
+  // collect all the flags needed for linking libraries
+  linkLibs = "";
+
   // Try to emit each search path once
   std::set<cmStdString> emitted;
   // Embed runtime search paths if possible and if required.
@@ -1494,13 +1494,13 @@
 
   const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
   const char* linkLanguage = 
-    tgt.GetLinkerLanguage(this->GetGlobalGenerator());
+      tgt.GetLinkerLanguage(this->GetGlobalGenerator());
   if(!linkLanguage)
     {
     cmSystemTools::
       Error("CMake can not determine linker language for target:",
             tgt.GetName());
-    return;
+    return false;
     }
   std::string runTimeFlagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
   runTimeFlagVar += linkLanguage;
@@ -1535,8 +1535,6 @@
     this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
   std::string libLinkFlag = 
     this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
-  // collect all the flags needed for linking libraries
-  std::string linkLibs;
   
   // Flags to link an executable to shared libraries.
   std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
@@ -1635,29 +1633,60 @@
     linkLibs += " ";
     }
 
-  fout << linkLibs;
-
   if(!runtimeDirs.empty())
     {
     // For the runtime search directories, do a "-Wl,-rpath,a:b:c" or
     // a "-R a -R b -R c" type link line
-    fout << runtimeFlag;
+    rpath += runtimeFlag;
     std::vector<std::string>::iterator itr = runtimeDirs.begin();
-    fout << *itr;
+    rpath += *itr;
     ++itr;
     for( ; itr != runtimeDirs.end(); ++itr )
       {
       if(runtimeConcatenate)
         {
-        fout << runtimeSep << *itr;
+        rpath += runtimeSep;
+        rpath += *itr;
         }
       else
         {
-        fout << " " << runtimeFlag << *itr;
+        rpath += " ";
+        rpath += runtimeFlag;
+        rpath += *itr;
         }
       }
-    fout << " ";
     }
+  return true;
+}
+
+/**
+ * Output the linking rules on a command line.  For executables,
+ * targetLibrary should be a NULL pointer.  For libraries, it should point
+ * to the name of the library.  This will not link a library against itself.
+ */
+void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
+                                           cmTarget& tgt,
+                                           bool relink)
+{
+  std::string rpath;
+  std::string linkLibs;
+  if (!this->GetLinkerArgs(rpath, linkLibs, tgt, relink))
+    {
+    return;
+    }
+
+  const char* linkLanguage = 
+    tgt.GetLinkerLanguage(this->GetGlobalGenerator());
+  if(!linkLanguage)
+    {
+    cmSystemTools::
+      Error("CMake can not determine linker language for target:",
+            tgt.GetName());
+    return;
+    }
+
+  fout << linkLibs;
+  fout << rpath << " ";
 
   // Add standard libraries for this language.
   std::string standardLibsVar = "CMAKE_";

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cmLocalGenerator.h	1 Aug 2007 19:25:40 -0000	1.85
+++ cmLocalGenerator.h	26 Nov 2007 22:57:39 -0000	1.86
@@ -257,6 +257,10 @@
   
   ///! put all the libraries for a target on into the given stream
   virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink);
+  
+  ///! Determine the arguments for the linker call
+  bool GetLinkerArgs(std::string& rpath, std::string& linkLibs,
+                     cmTarget& tgt, bool relink);
 
   // Expand rule variables in CMake of the type found in language rules
   void ExpandRuleVariables(std::string& string,



More information about the Cmake-commits mailing list