[cmake-commits] king committed cmFindLibraryCommand.cxx 1.48 1.49 cmFindLibraryCommand.h 1.22 1.23

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jan 21 18:30:38 EST 2008


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

Modified Files:
	cmFindLibraryCommand.cxx cmFindLibraryCommand.h 
Log Message:
ENH: Add support to find_library to transform /lib to /lib32 on some architectures.


Index: cmFindLibraryCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmFindLibraryCommand.h	10 Oct 2007 15:47:43 -0000	1.22
+++ cmFindLibraryCommand.h	21 Jan 2008 23:30:36 -0000	1.23
@@ -65,7 +65,8 @@
   cmTypeMacro(cmFindLibraryCommand, cmFindBase);
   
 protected:
-  void AddLib64Paths();\
+  void AddLib32Paths();
+  void AddLib64Paths();
   std::string FindLibrary(const char* name);
 };
 

Index: cmFindLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.cxx,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cmFindLibraryCommand.cxx	21 Jan 2008 00:29:12 -0000	1.48
+++ cmFindLibraryCommand.cxx	21 Jan 2008 23:30:36 -0000	1.49
@@ -77,6 +77,16 @@
     return true;
     }
 
+  if(const char* abi =
+     this->Makefile->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI"))
+    {
+    if(strncmp(abi, "ELF N32", 7) ==0)
+      {
+      // Convert /lib to /lib32 if the architecture requests it.
+      this->AddLib32Paths();
+      }
+    }
+
   if(this->Makefile->GetCMakeInstance()
      ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
     {
@@ -106,6 +116,45 @@
   return true;
 }
 
+//----------------------------------------------------------------------------
+void cmFindLibraryCommand::AddLib32Paths()
+{
+  std::vector<std::string> path32;
+  bool found32 = false;
+  for(std::vector<std::string>::iterator i = this->SearchPaths.begin();
+      i != this->SearchPaths.end(); ++i)
+    {
+    std::string s = *i;
+    std::string s2 = *i;
+    cmSystemTools::ReplaceString(s, "lib/", "lib32/");
+    // try to replace lib with lib32 and see if it is there,
+    // then prepend it to the path
+    if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str()))
+      {
+      path32.push_back(s);
+      found32 = true;
+      }
+    // now just add a 32 to the path name and if it is there,
+    // add it to the path
+    s2 += "32";
+    if(cmSystemTools::FileIsDirectory(s2.c_str()))
+      {
+      found32 = true;
+      path32.push_back(s2);
+      }
+    // now add the original unchanged path
+    if(cmSystemTools::FileIsDirectory(i->c_str()))
+      {
+      path32.push_back(*i);
+      }
+    }
+  // now replace the SearchPaths with the 32 bit converted path
+  // if any 32 bit paths were discovered
+  if(found32)
+    {
+    this->SearchPaths = path32;
+    }
+}
 
 void cmFindLibraryCommand::AddLib64Paths()
 {  



More information about the Cmake-commits mailing list