From 6ca2f82d0d8dbb1f0f79c5fe1a4e21de78a57c84 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 20 Jul 2012 13:28:49 -0400 Subject: [PATCH] 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. --- Source/cmFindLibraryCommand.cxx | 53 ++++----------------------------- Source/cmFindLibraryCommand.h | 1 - 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 6cdbbf2dc..688d8a765 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 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 path64; - bool found64 = 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/", "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 b880be266..f91583bf5 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: