[cmake-commits] king committed cmComputeLinkDepends.cxx 1.10 1.11 cmComputeLinkDepends.h 1.4 1.5

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Feb 13 15:29:57 EST 2008


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

Modified Files:
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h 
Log Message:
BUG: Update cmComputeLinkDepends to support leading/trailing whitespace stripping off link items for compatibility.


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cmComputeLinkDepends.h	7 Feb 2008 21:14:05 -0000	1.4
+++ cmComputeLinkDepends.h	13 Feb 2008 20:29:55 -0000	1.5
@@ -78,6 +78,7 @@
                             LinkLibraryVectorType const& libs);
   void AddLinkEntries(int depender_index,
                       std::vector<std::string> const& libs);
+  std::string CleanItemName(std::string const& item);
 
   // One entry for each unique item.
   std::vector<LinkEntry> EntryList;

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmComputeLinkDepends.cxx	11 Feb 2008 15:31:38 -0000	1.10
+++ cmComputeLinkDepends.cxx	13 Feb 2008 20:29:55 -0000	1.11
@@ -510,13 +510,14 @@
     {
     // Skip entries that will resolve to the target getting linked or
     // are empty.
-    if(*li == this->Target->GetName() || li->empty())
+    std::string item = this->CleanItemName(*li);
+    if(item == this->Target->GetName() || item.empty())
       {
       continue;
       }
 
     // Add a link entry for this item.
-    int dependee_index = this->AddLinkEntry(*li);
+    int dependee_index = this->AddLinkEntry(item);
 
     // The depender must come before the dependee.
     if(depender_index >= 0)
@@ -551,6 +552,38 @@
 }
 
 //----------------------------------------------------------------------------
+std::string cmComputeLinkDepends::CleanItemName(std::string const& item)
+{
+  // Strip whitespace off the library names because we used to do this
+  // in case variables were expanded at generate time.  We no longer
+  // do the expansion but users link to libraries like " ${VAR} ".
+  std::string lib = item;
+  std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
+  if(pos != lib.npos)
+    {
+    lib = lib.substr(pos, lib.npos);
+    }
+  pos = lib.find_last_not_of(" \t\r\n");
+  if(pos != lib.npos)
+    {
+    lib = lib.substr(0, pos+1);
+    }
+  if(lib != item && !this->Makefile->NeedBackwardsCompatibility(2,4))
+    {
+    cmOStringStream e;
+    e << "Target \"" << this->Target->GetName() << "\" links to item \""
+      << item << "\" which has leading or trailing whitespace.  "
+      << "CMake is stripping off the whitespace but this may not be "
+      << "supported in the future.  "
+      << "Update the CMakeLists.txt files to avoid adding the whitespace.  "
+      << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.4 or lower to disable this "
+      << "warning.";
+    cmSystemTools::Message(e.str().c_str());
+    }
+  return lib;
+}
+
+//----------------------------------------------------------------------------
 void cmComputeLinkDepends::InferDependencies()
 {
   // The inferred dependency sets for each item list the possible



More information about the Cmake-commits mailing list