From fd2a6a8693b496f2dbff1ab50c6fb39eeb55de2e Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 10 Feb 2008 11:37:06 -0500 Subject: BUG: Fix recent find_library change to look for user-specified name first to do so only if the name matches a valid library extension. --- Source/cmFindLibraryCommand.cxx | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index b221160..9ee669d 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -234,6 +234,24 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name) std::vector suffixes; cmSystemTools::ExpandListArgument(prefixes_list, prefixes, true); cmSystemTools::ExpandListArgument(suffixes_list, suffixes, true); + + // If the original library name provided by the user matches one of + // the suffixes, try it first. + bool tryOrig = false; + { + std::string nm = name; + for(std::vector::const_iterator si = suffixes.begin(); + !tryOrig && si != suffixes.end(); ++si) + { + std::string const& suffix = *si; + if(nm.length() > suffix.length() && + nm.substr(nm.size()-suffix.length()) == suffix) + { + tryOrig = true; + } + } + } + // Add a trailing slash to all paths to aid the search process. for(std::vector::iterator i = this->SearchPaths.begin(); i != this->SearchPaths.end(); ++i) @@ -264,13 +282,16 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name) if(!onlyFrameworks) { // Try the original library name as specified by the user. - tryPath = *p; - tryPath += name; - if(cmSystemTools::FileExists(tryPath.c_str(), true)) + if(tryOrig) { - tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); - cmSystemTools::ConvertToUnixSlashes(tryPath); - return tryPath; + tryPath = *p; + tryPath += name; + if(cmSystemTools::FileExists(tryPath.c_str(), true)) + { + tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); + cmSystemTools::ConvertToUnixSlashes(tryPath); + return tryPath; + } } // Try various library naming conventions. -- cgit v0.12