summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-02-21 20:56:26 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-02-21 20:56:26 (GMT)
commit8a665fa3631a5590a8ae62aecaad0ea3d4dfa778 (patch)
tree18dc98fd46338a8bb6b21ff4c1984579a2b0463b /Source
parent751e4928404f3b2c9ca0011c10a84650481a8090 (diff)
parent70f362305f20cc1e915a8b0289751d4ed41b60ca (diff)
downloadCMake-8a665fa3631a5590a8ae62aecaad0ea3d4dfa778.zip
CMake-8a665fa3631a5590a8ae62aecaad0ea3d4dfa778.tar.gz
CMake-8a665fa3631a5590a8ae62aecaad0ea3d4dfa778.tar.bz2
Merge topic 'findlibrary-versioned-libraries'
70f3623 Find_library(): allow searching for versioned shared objects
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindLibraryCommand.cxx18
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;
}