[cmake-developers] Finding versioned libraries
Rolf Eike Beer
eike at sf-mail.de
Wed Feb 15 07:58:22 EST 2012
Hi,
as I found out today this construct doesn't work:
find_library(MYLIB libfoo.so.2)
This is because find_library will only try to access the whole path if the
given name matches PREFIX.*SUFFIX, which is obviously not the case here. My
simple approach on fixing this would be to also allow PREFIX.*SUFFIX\..*:
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 2fa2cca..da7650a 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -358,9 +358,17 @@ bool cmFindLibraryHelper::HasValidSuffix(std::string const& name)
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;
+ }
+ if(name.substr(name.size()-suffix.length()) == suffix)
+ {
+ return true;
+ }
+ suffix += ".";
+ if(name.find(suffix) != name.npos)
{
return true;
}
Any objections?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120215/1d8448fa/attachment.pgp>
More information about the cmake-developers
mailing list