openbsd-ports/devel/cmake/patches/patch-Source_cmTarget_cxx
dcoppa 8db1eb592e CMake now creates shared libraries without soname.
Tested in a bulk build by landry@
Feedback by nigel@ and landry@
OK landry@
2012-10-08 07:23:09 +00:00

89 lines
2.9 KiB
Plaintext

$OpenBSD: patch-Source_cmTarget_cxx,v 1.14 2012/10/08 07:23:09 dcoppa Exp $
--- Source/cmTarget.cxx.orig Thu Aug 9 20:15:19 2012
+++ Source/cmTarget.cxx Mon Aug 27 15:07:12 2012
@@ -3022,12 +3022,16 @@ std::string cmTarget::GetPDBName(const char* config)
//----------------------------------------------------------------------------
bool cmTarget::HasSOName(const char* config)
{
+#if !defined(__OpenBSD__)
// soname is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
return ((this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY) &&
!this->GetPropertyAsBool("NO_SONAME") &&
this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
+#else
+ return false;
+#endif
}
//----------------------------------------------------------------------------
@@ -3380,9 +3384,43 @@ void cmTarget::GetLibraryNames(std::string& name,
// The library name.
name = prefix+base+suffix;
+#if defined(__OpenBSD__)
+ // Override shared library version using LIBxxx_VERSION
+ // environment variable. Needed for OpenBSD ports system.
+ if(this->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->GetType() == cmTarget::MODULE_LIBRARY)
+ {
+ std::string env_name = "LIB" + base + "_VERSION";
+ char *env_vers_cstr = getenv(env_name.c_str());
+
+ if (env_vers_cstr && strlen(env_vers_cstr) > 0) {
+ // This means an override is present.
+ std::string env_vers = std::string(env_vers_cstr);
+
+ size_t first = env_vers.find_first_of(".");
+ size_t last = env_vers.find_first_of(".");
+
+ if ((first != last) || (first == std::string::npos)) {
+ std::string msg = "Bad ";
+ msg += env_name;
+ msg += " specification: ";
+ msg += env_vers;
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ msg.c_str());
+ } else {
+ version = env_vers_cstr;
+ }
+ }
+ }
+
// The library's soname.
this->ComputeVersionedName(soName, prefix, base, suffix,
+ name, version);
+#else
+ // The library's soname.
+ this->ComputeVersionedName(soName, prefix, base, suffix,
name, soversion);
+#endif
// The library's real name on disk.
this->ComputeVersionedName(realName, prefix, base, suffix,
@@ -3415,7 +3453,23 @@ void cmTarget::ComputeVersionedName(std::string& vName
if(version)
{
vName += ".";
+#if defined(__OpenBSD__)
+ // OpenBSD-style versioning for shared libraries.
+ // Convert libname.so.X.X.X to libname.so.X.X
+ int j = 0;
+ for (int i = 0; i < (int)strlen(version); i++)
+ {
+ if (version[i] == '.')
+ {
+ j++;
+ if (j == 2)
+ break;
+ }
+ vName += version[i];
+ }
+#else
vName += version;
+#endif
}
vName += this->IsApple? suffix : std::string();
}