665a689517
let cmake detect most recent library, as it should
74 lines
2.3 KiB
Plaintext
74 lines
2.3 KiB
Plaintext
$OpenBSD: patch-Source_cmFindLibraryCommand_cxx,v 1.4 2007/03/23 16:30:35 espie Exp $
|
|
--- Source/cmFindLibraryCommand.cxx.orig Wed Jan 10 18:59:12 2007
|
|
+++ Source/cmFindLibraryCommand.cxx Fri Mar 23 17:07:55 2007
|
|
@@ -139,11 +139,52 @@ void cmFindLibraryCommand::AddLib64Paths()
|
|
}
|
|
}
|
|
|
|
+std::string OpenBSD_find_library(const std::string& path, const std::string& prefix, const char *name)
|
|
+{
|
|
+ std::vector<std::string> result;
|
|
+
|
|
+ std::string stem = prefix + name + ".so.";
|
|
+ std::size_t len = stem.length();
|
|
+ std::string best;
|
|
+ int bestmajor = -1;
|
|
+ int bestminor = -1;
|
|
+ std::string globstring = "^" + prefix+".*\\.so\\.[0-9]+\\.[0-9]+$";
|
|
+
|
|
+ cmSystemTools::Glob(path.c_str(), globstring.c_str(), result);
|
|
+ for (std::vector<std::string>::iterator it = result.begin();
|
|
+ it != result.end(); ++it) {
|
|
+ if (it->substr(0, len) != stem) {
|
|
+ continue;
|
|
+ }
|
|
+ std::istringstream sc(it->substr(len, it->size()));
|
|
+ int major, minor;
|
|
+ sc >> major;
|
|
+ if (sc.get() != '.')
|
|
+ continue;
|
|
+ sc >> minor;
|
|
+
|
|
+ if (major < bestmajor)
|
|
+ continue;
|
|
+ if (major == bestmajor && minor < bestminor)
|
|
+ continue;
|
|
+ bestmajor = major;
|
|
+ bestminor = minor;
|
|
+ best = path + "/" + *it;
|
|
+ }
|
|
+ return best;
|
|
+}
|
|
+
|
|
std::string cmFindLibraryCommand::FindLibrary(const char* name)
|
|
{
|
|
bool supportFrameworks = false;
|
|
bool onlyFrameworks = false;
|
|
+ bool openbsdSharedLibs = false;
|
|
std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
|
|
+ std::string openbsd = this->Makefile->GetSafeDefinition("CMAKE_OPENBSD_SHARED_LIBS");
|
|
+ if (openbsd == "TRUE")
|
|
+ {
|
|
+ openbsdSharedLibs = true;
|
|
+ }
|
|
if(ff == "FIRST" || ff == "LAST")
|
|
{
|
|
supportFrameworks = true;
|
|
@@ -194,6 +235,16 @@ std::string cmFindLibraryCommand::FindLibrary(const ch
|
|
tryPath += *prefix;
|
|
tryPath += name;
|
|
tryPath += *suffix;
|
|
+ if (openbsdSharedLibs && *suffix == ".so")
|
|
+ {
|
|
+ std::string foundPath = OpenBSD_find_library(*p, *prefix, name);
|
|
+ if (foundPath != "")
|
|
+ {
|
|
+ tryPath = cmSystemTools::CollapseFullPath(foundPath.c_str());
|
|
+ cmSystemTools::ConvertToUnixSlashes(tryPath);
|
|
+ return tryPath;
|
|
+ }
|
|
+ }
|
|
if(cmSystemTools::FileExists(tryPath.c_str())
|
|
&& !cmSystemTools::FileIsDirectory(tryPath.c_str()))
|
|
{
|