diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2012-02-15 18:55:57 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2012-02-18 15:19:29 (GMT) |
commit | 70f362305f20cc1e915a8b0289751d4ed41b60ca (patch) | |
tree | 436325108f5c5beb3df96f7120283ef8ea160b78 /Source | |
parent | a8b57149351168425f4040c8b99167238cca041d (diff) | |
download | CMake-70f362305f20cc1e915a8b0289751d4ed41b60ca.zip CMake-70f362305f20cc1e915a8b0289751d4ed41b60ca.tar.gz CMake-70f362305f20cc1e915a8b0289751d4ed41b60ca.tar.bz2 |
Find_library(): allow searching for versioned shared objects
This did not work because find_library() did only treat the given name as
complete filename if is matched "PREFIX.*SUFFIX":
find_library(MYLIB libfoo.so.2)
Now it is also taken as a whole if the name matches "PREFIX.*SUFFIX\..*".
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFindLibraryCommand.cxx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 2fa2cca..a726849 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -354,13 +354,23 @@ void cmFindLibraryHelper::RegexFromList(std::string& out, //---------------------------------------------------------------------------- bool cmFindLibraryHelper::HasValidSuffix(std::string const& name) { - // Check if the given name ends in a valid library suffix. for(std::vector<std::string>::const_iterator si = this->Suffixes.begin(); si != this->Suffixes.end(); ++si) { - std::string const& suffix = *si; - if(name.length() > suffix.length() && - name.substr(name.size()-suffix.length()) == suffix) + std::string suffix = *si; + if(name.length() <= suffix.length()) + { + continue; + } + // Check if the given name ends in a valid library suffix. + if(name.substr(name.size()-suffix.length()) == suffix) + { + return true; + } + // Check if a valid library suffix is somewhere in the name, + // this may happen e.g. for versioned shared libraries: libfoo.so.2 + suffix += "."; + if(name.find(suffix) != name.npos) { return true; } |