[cmake-commits] king committed cmComputeLinkInformation.cxx 1.12 1.13 cmComputeLinkInformation.h 1.8 1.9 cmFindLibraryCommand.cxx 1.54 1.55 cmFindLibraryCommand.h 1.26 1.27

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jan 31 07:50:42 EST 2008


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

Modified Files:
	cmComputeLinkInformation.cxx cmComputeLinkInformation.h 
	cmFindLibraryCommand.cxx cmFindLibraryCommand.h 
Log Message:
BUG: Move decision to switch library paths found in implicit link directories to use -l options from cmFindLibraryCommand to cmComputeLinkInformation.  Existing projects may depend on find_library returning a full path.  This slightly weakens cmComputeLinkInformation but is necessary for compatibility.


Index: cmFindLibraryCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmFindLibraryCommand.h	23 Jan 2008 21:21:49 -0000	1.26
+++ cmFindLibraryCommand.h	31 Jan 2008 12:50:40 -0000	1.27
@@ -69,7 +69,6 @@
   void AddArchitecturePaths(const char* suffix);
   void AddLib64Paths();
   std::string FindLibrary(const char* name);
-  std::string FixForImplicitLocations(std::string const& lib);
 };
 
 

Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmComputeLinkInformation.cxx	29 Jan 2008 20:47:18 -0000	1.12
+++ cmComputeLinkInformation.cxx	31 Jan 2008 12:50:40 -0000	1.13
@@ -234,6 +234,21 @@
   // Setup framework support.
   this->ComputeFrameworkInfo();
 
+  // Get the implicit link directories for this platform.
+  if(const char* implicitLinks =
+     (this->Makefile->GetDefinition
+      ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES")))
+    {
+    std::vector<std::string> implicitLinkVec;
+    cmSystemTools::ExpandListArgument(implicitLinks, implicitLinkVec);
+    for(std::vector<std::string>::const_iterator
+          i = implicitLinkVec.begin();
+        i != implicitLinkVec.end(); ++i)
+      {
+      this->ImplicitLinkDirs.insert(*i);
+      }
+    }
+
   // Initial state.
   this->RuntimeSearchPathComputed = false;
   this->HaveUserFlagItem = false;
@@ -689,6 +704,12 @@
 //----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddFullItem(std::string const& item)
 {
+  // Check for the implicit link directory special case.
+  if(this->CheckImplicitDirItem(item))
+    {
+    return;
+    }
+
   // This is called to handle a link item that is a full path.
   // If the target is not a static library make sure the link type is
   // shared.  This is because dynamic-mode linking can handle both
@@ -728,6 +749,37 @@
 }
 
 //----------------------------------------------------------------------------
+bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
+{
+  // We only switch to a pathless item if the link type may be
+  // enforced.  Fortunately only platforms that support link types
+  // seem to have magic per-architecture implicit link directories.
+  if(!this->LinkTypeEnabled)
+    {
+    return false;
+    }
+
+  // Check if this item is in an implicit link directory.
+  std::string dir = cmSystemTools::GetFilenamePath(item);
+  if(this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end())
+    {
+    // Only libraries in implicit link directories are converted to
+    // pathless items.
+    return false;
+    }
+
+  // Many system linkers support multiple architectures by
+  // automatically selecting the implicit linker search path for the
+  // current architecture.  If the library appears in an implicit link
+  // directory then just report the file name without the directory
+  // portion.  This will allow the system linker to locate the proper
+  // library for the architecture at link time.
+  std::string file = cmSystemTools::GetFilenameName(item);
+  this->AddUserItem(file);
+  return true;
+}
+
+//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddUserItem(std::string const& item)
 {
   // This is called to handle a link item that does not match a CMake
@@ -907,20 +959,8 @@
 void cmComputeLinkInformation::ComputeLinkerSearchDirectories()
 {
   // Some search paths should never be emitted.
+  this->DirectoriesEmmitted = this->ImplicitLinkDirs;
   this->DirectoriesEmmitted.insert("");
-  if(const char* implicitLinks =
-     (this->Makefile->GetDefinition
-      ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES")))
-    {
-    std::vector<std::string> implicitLinkVec;
-    cmSystemTools::ExpandListArgument(implicitLinks, implicitLinkVec);
-    for(std::vector<std::string>::const_iterator
-          i = implicitLinkVec.begin();
-        i != implicitLinkVec.end(); ++i)
-      {
-      this->DirectoriesEmmitted.insert(*i);
-      }
-    }
 
   // Check if we need to include the runtime search path at link time.
   std::string var = "CMAKE_SHARED_LIBRARY_LINK_";

Index: cmFindLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.cxx,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- cmFindLibraryCommand.cxx	24 Jan 2008 12:37:15 -0000	1.54
+++ cmFindLibraryCommand.cxx	31 Jan 2008 12:50:40 -0000	1.55
@@ -52,17 +52,6 @@
     "When a full path to a framework is used as a library, "
     "CMake will use a -framework A, and a -F<fullPath> to "
     "link the framework to the target. ";
-  this->GenericDocumentation +=
-    "\n"
-    "Some platforms define implicit library directories such as "
-    "/lib and /usr/lib that are automatically searched by the linker.  "
-    "If this command finds a library in one of these directories "
-    "it will report only the name of the library file and not the path.  "
-    "When the name is used to link the library CMake will generate a "
-    "link line that asks the linker to search for it.  This allows "
-    "the system linker to automatically adjust the implicit directory "
-    "set based on the current architecture."
-    ;
 }
 
 // cmFindLibraryCommand
@@ -86,26 +75,6 @@
                                          this->VariableDocumentation.c_str(),
                                          cmCacheManager::FILEPATH);
       }
-
-    // If the existing value was loaded from a cache written by CMake
-    // 2.4 or below then force the implicit link directory fix on the
-    // value.
-    if(this->Makefile->NeedCacheCompatibility(2, 4))
-      {
-      if(const char* v =
-         this->Makefile->GetDefinition(this->VariableName.c_str()))
-        {
-        std::string nv = this->FixForImplicitLocations(v);
-        if(nv != v)
-          {
-          this->Makefile
-            ->AddCacheDefinition(this->VariableName.c_str(),
-                                 nv.c_str(),
-                                 this->VariableDocumentation.c_str(),
-                                 cmCacheManager::FILEPATH);
-          }
-        }
-      }
     return true;
     }
 
@@ -134,7 +103,6 @@
     library = this->FindLibrary(i->c_str());
     if(library != "")
       {
-      library = this->FixForImplicitLocations(library);
       this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
                                          library.c_str(),
                                          this->VariableDocumentation.c_str(),
@@ -320,43 +288,3 @@
   // Couldn't find the library.
   return "";
 }
-
-//----------------------------------------------------------------------------
-std::string
-cmFindLibraryCommand::FixForImplicitLocations(std::string const& lib)
-{
-  // Get implicit link directories for the platform.
-  const char* implicitLinks =
-     (this->Makefile->GetDefinition
-      ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"));
-  if(!implicitLinks)
-    {
-    // There are no implicit link directories.  No fix is needed.
-    return lib;
-    }
-  std::vector<std::string> implicitLinkVec;
-  cmSystemTools::ExpandListArgument(implicitLinks, implicitLinkVec);
-
-  // Get the path containing the library.
-  std::string libDir = cmSystemTools::GetFilenamePath(lib);
-
-  // Many system linkers support multiple architectures by
-  // automatically selecting the implicit linker search path for the
-  // current architecture.  If the library appears in an implicit link
-  // directory then just report the file name without the directory
-  // portion.  This will allow the system linker to locate the proper
-  // library for the architecture at link time.
-  for(std::vector<std::string>::const_iterator i = implicitLinkVec.begin();
-      i != implicitLinkVec.end(); ++i)
-    {
-    if(*i == libDir)
-      {
-      // The library appears in an implicit link directory.  Report
-      // only the file name.
-      return cmSystemTools::GetFilenameName(lib);
-      }
-    }
-
-  // No implicit link directory matched.  No fix is needed.
-  return lib;
-}

Index: cmComputeLinkInformation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmComputeLinkInformation.h	29 Jan 2008 20:47:18 -0000	1.8
+++ cmComputeLinkInformation.h	31 Jan 2008 12:50:40 -0000	1.9
@@ -117,6 +117,7 @@
   // Handling of link items that are not targets or full file paths.
   void AddTargetItem(std::string const& item, cmTarget* target);
   void AddFullItem(std::string const& item);
+  bool CheckImplicitDirItem(std::string const& item);
   void AddUserItem(std::string const& item);
   void AddDirectoryItem(std::string const& item);
   void AddFrameworkItem(std::string const& item);
@@ -132,6 +133,7 @@
   void ComputeLinkerSearchDirectories();
   void AddLinkerSearchDirectories(std::vector<std::string> const& dirs);
   std::set<cmStdString> DirectoriesEmmitted;
+  std::set<cmStdString> ImplicitLinkDirs;
 
   // Linker search path compatibility mode.
   std::vector<std::string> OldLinkDirs;



More information about the Cmake-commits mailing list