summaryrefslogtreecommitdiffstats
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-02-10 16:37:06 (GMT)
committerBrad King <brad.king@kitware.com>2008-02-10 16:37:06 (GMT)
commitfd2a6a8693b496f2dbff1ab50c6fb39eeb55de2e (patch)
tree580cb242d1df34a5d68e209fae783886c316a587 /Source/cmFindLibraryCommand.cxx
parent138d479c674c098d2591cb8a7673c16107c11545 (diff)
downloadCMake-fd2a6a8693b496f2dbff1ab50c6fb39eeb55de2e.zip
CMake-fd2a6a8693b496f2dbff1ab50c6fb39eeb55de2e.tar.gz
CMake-fd2a6a8693b496f2dbff1ab50c6fb39eeb55de2e.tar.bz2
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.
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx33
1 files 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<std::string> 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<std::string>::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<std::string>::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.