From 16247cbfc35607b62f175820fb90dc69fca9e3cb Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 21 Jan 2008 18:30:36 -0500 Subject: [PATCH] ENH: Add support to find_library to transform /lib to /lib32 on some architectures. --- Source/cmFindLibraryCommand.cxx | 49 +++++++++++++++++++++++++++++++++ Source/cmFindLibraryCommand.h | 3 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 6f0b23af7..0c7f0cfbd 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -77,6 +77,16 @@ bool cmFindLibraryCommand::InitialPass(std::vector 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 const& argsIn) return true; } +//---------------------------------------------------------------------------- +void cmFindLibraryCommand::AddLib32Paths() +{ + std::vector path32; + bool found32 = false; + for(std::vector::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() { diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index 88bbb3247..a0f2338af 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -65,7 +65,8 @@ public: cmTypeMacro(cmFindLibraryCommand, cmFindBase); protected: - void AddLib64Paths();\ + void AddLib32Paths(); + void AddLib64Paths(); std::string FindLibrary(const char* name); };