summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-07-20 13:28:49 -0400
committerBrad King <brad.king@kitware.com>2012-07-20 14:19:08 -0400
commit6ca2f82d0d8dbb1f0f79c5fe1a4e21de78a57c84 (patch)
tree30f29ecb9f32b59f6e1943c7c5cb9077113b96a4 /Source
parent1fe4b82a45bfe3e578267d84c70d6e55610e2ced (diff)
downloadcmake-6ca2f82d0d8dbb1f0f79c5fe1a4e21de78a57c84.tar.gz
find_library: Refactor lib->lib64 conversion
Previously methods AddArchitecturePaths and AddLib64Paths were almost identical. Replace the latter with a call to the former. Fix the AddArchitecturePaths implementation to add trailing slashes to all tested paths.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindLibraryCommand.cxx53
-rw-r--r--Source/cmFindLibraryCommand.h1
2 files changed, 5 insertions, 49 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 6cdbbf2dc5..688d8a7655 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -105,7 +105,10 @@ bool cmFindLibraryCommand
->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
{
// add special 64 bit paths if this is a 64 bit compile.
- this->AddLib64Paths();
+ if(this->Makefile->PlatformIs64Bit())
+ {
+ this->AddArchitecturePaths("64");
+ }
}
std::string library = this->FindLibrary();
@@ -149,6 +152,7 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
// Now look for lib<suffix>
s = *i;
s += suffix;
+ s += "/";
if(cmSystemTools::FileIsDirectory(s.c_str()))
{
found = true;
@@ -168,53 +172,6 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
}
}
-void cmFindLibraryCommand::AddLib64Paths()
-{
- std::string voidsize =
- this->Makefile->GetSafeDefinition("CMAKE_SIZEOF_VOID_P");
- int size = atoi(voidsize.c_str());
- if(size != 8)
- {
- return;
- }
- std::vector<std::string> path64;
- bool found64 = 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/", "lib64/");
- // try to replace lib with lib64 and see if it is there,
- // then prepend it to the path
- // Note that all paths have trailing slashes.
- if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str()))
- {
- path64.push_back(s);
- found64 = true;
- }
- // now just add a 64 to the path name and if it is there,
- // add it to the path
- s2 += "64/";
- if(cmSystemTools::FileIsDirectory(s2.c_str()))
- {
- found64 = true;
- path64.push_back(s2);
- }
- // now add the original unchanged path
- if(cmSystemTools::FileIsDirectory(i->c_str()))
- {
- path64.push_back(*i);
- }
- }
- // now replace the SearchPaths with the 64 bit converted path
- // if any 64 bit paths were discovered
- if(found64)
- {
- this->SearchPaths = path64;
- }
-}
-
//----------------------------------------------------------------------------
std::string cmFindLibraryCommand::FindLibrary()
{
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index b880be2664..f91583bf5d 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -62,7 +62,6 @@ public:
protected:
void AddArchitecturePaths(const char* suffix);
- void AddLib64Paths();
std::string FindLibrary();
virtual void GenerateDocumentation();
private: