[Cmake-commits] [cmake-commits] king committed cmFindLibraryCommand.cxx 1.61 1.62 cmake.cxx 1.395 1.396
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Sep 22 11:08:19 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv29333/Source
Modified Files:
cmFindLibraryCommand.cxx cmake.cxx
Log Message:
ENH: Teach find_library to find OpenBSD-style libs
OpenBSD shared libraries use a ".so.<major>.<minor>" extension and do
not have a symlink with just a ".so" extension. Its "ld" is capable of
finding the library with the best version. This change adds support for
finding such libraries. See issue #3470.
Index: cmFindLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.cxx,v
retrieving revision 1.61
retrieving revision 1.62
diff -C 2 -d -r1.61 -r1.62
*** cmFindLibraryCommand.cxx 22 Sep 2008 14:59:52 -0000 1.61
--- cmFindLibraryCommand.cxx 22 Sep 2008 15:08:16 -0000 1.62
***************
*** 250,253 ****
--- 250,258 ----
size_type BestSuffix;
+ // Support for OpenBSD shared library naming: lib<name>.so.<major>.<minor>
+ bool OpenBSD;
+ unsigned int BestMajor;
+ unsigned int BestMinor;
+
// Current name under consideration.
cmsys::RegularExpression NameRegex;
***************
*** 291,294 ****
--- 296,304 ----
this->RegexFromList(this->SuffixRegexStr, this->Suffixes);
+ // Check whether to use OpenBSD-style library version comparisons.
+ this->OpenBSD =
+ this->Makefile->GetCMakeInstance()
+ ->GetPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
+
this->TryRawName = false;
***************
*** 296,299 ****
--- 306,311 ----
this->BestPrefix = this->Prefixes.size();
this->BestSuffix = this->Suffixes.size();
+ this->BestMajor = 0;
+ this->BestMinor = 0;
}
***************
*** 369,372 ****
--- 381,388 ----
this->RegexFromLiteral(regex, name);
regex += this->SuffixRegexStr;
+ if(this->OpenBSD)
+ {
+ regex += "(\\.[0-9]+\\.[0-9]+)?";
+ }
regex += "$";
this->NameRegex.compile(regex.c_str());
***************
*** 415,427 ****
// This is a matching file. Check if it is better than the
// best name found so far. Earlier prefixes are preferred,
! // followed by earlier suffixes.
size_type prefix = this->GetPrefixIndex(this->NameRegex.match(1));
size_type suffix = this->GetSuffixIndex(this->NameRegex.match(2));
if(this->BestPath.empty() || prefix < this->BestPrefix ||
! (prefix == this->BestPrefix && suffix < this->BestSuffix))
{
this->BestPath = this->TestPath;
this->BestPrefix = prefix;
this->BestSuffix = suffix;
}
}
--- 431,455 ----
// This is a matching file. Check if it is better than the
// best name found so far. Earlier prefixes are preferred,
! // followed by earlier suffixes. For OpenBSD, shared library
! // version extensions are compared.
size_type prefix = this->GetPrefixIndex(this->NameRegex.match(1));
size_type suffix = this->GetSuffixIndex(this->NameRegex.match(2));
+ unsigned int major = 0;
+ unsigned int minor = 0;
+ if(this->OpenBSD)
+ {
+ sscanf(this->NameRegex.match(3).c_str(), ".%u.%u", &major, &minor);
+ }
if(this->BestPath.empty() || prefix < this->BestPrefix ||
! (prefix == this->BestPrefix && suffix < this->BestSuffix) ||
! (prefix == this->BestPrefix && suffix == this->BestSuffix &&
! (major > this->BestMajor ||
! (major == this->BestMajor && minor > this->BestMinor))))
{
this->BestPath = this->TestPath;
this->BestPrefix = prefix;
this->BestSuffix = suffix;
+ this->BestMajor = major;
+ this->BestMinor = minor;
}
}
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.395
retrieving revision 1.396
diff -C 2 -d -r1.395 -r1.396
*** cmake.cxx 4 Sep 2008 21:34:24 -0000 1.395
--- cmake.cxx 22 Sep 2008 15:08:17 -0000 1.396
***************
*** 3328,3331 ****
--- 3328,3338 ----
"binaries.");
cm->DefineProperty
+ ("FIND_LIBRARY_USE_OPENBSD_VERSIONING", cmProperty::GLOBAL,
+ "Whether FIND_LIBRARY should find OpenBSD-style shared libraries.",
+ "This property is a boolean specifying whether the FIND_LIBRARY "
+ "command should find shared libraries with OpenBSD-style versioned "
+ "extension: \".so.<major>.<minor>\". "
+ "The property is set to true on OpenBSD and false on other platforms.");
+ cm->DefineProperty
("ENABLED_FEATURES", cmProperty::GLOBAL,
"List of features which are enabled during the CMake run.",
More information about the Cmake-commits
mailing list