summaryrefslogtreecommitdiffstats
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-21 23:30:36 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-21 23:30:36 (GMT)
commit16247cbfc35607b62f175820fb90dc69fca9e3cb (patch)
treed0a37733727762c68decc247d0fd96a3b95de64c /Source/cmFindLibraryCommand.cxx
parenta28b197b11f4b647c67a6914c731077972449343 (diff)
downloadCMake-16247cbfc35607b62f175820fb90dc69fca9e3cb.zip
CMake-16247cbfc35607b62f175820fb90dc69fca9e3cb.tar.gz
CMake-16247cbfc35607b62f175820fb90dc69fca9e3cb.tar.bz2
ENH: Add support to find_library to transform /lib to /lib32 on some architectures.
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 6f0b23a..0c7f0cf 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -77,6 +77,16 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
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 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
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()
{