On Wed Mar 09, 2022 at 04:25:15PM +0000, Stuart Henderson wrote:
> On 2022/03/09 11:15, Rafael Sadowski wrote:
> > With the results from Stuart's bulk build and Klemens analyses, I end up
> > with a new diff.
> >
> > - Handle target names like libXXX with PREFIX set to "".
> > With this, all reported errors are happy. Afterwards, we can delete
> > all patches. For example, I can remove all x11/kde-application cmake
> > hackish patches.
> > - Use cmSystemTools::GetEnv instead getenv(3)
> > - More shorter C++ code
>
> Makes sense.
>
> > Thank you to all. A final bulk build would be advisable, wouldn't it?
>
> Definitely needed. I can't run one right now though.
>
Before Stuart says that net/bro is still broken. I think all cmake ports
should be ok with the latest patch but not net/bro. Bro calls cmake
separately and therefore has no access to the environment variables.
I would like to solve this via an option MODCMAKE_USE_SAHRED_LIBS.(Other
name proposals?) This way we can also deactivate in the future if we
have to.
We can also add the SHARED_LIBS-loop inside the
if-MODCMAKE_USE_SAHRED_LIBS-block?
Diff without port-modules(5).
diff --git a/devel/cmake/Makefile b/devel/cmake/Makefile
index 013bf49411c..204bde44ce2 100644
--- a/devel/cmake/Makefile
+++ b/devel/cmake/Makefile
@@ -8,7 +8,7 @@ VER = 3.20.3
EPOCH = 0
DISTNAME = cmake-${VER}
CATEGORIES = devel
-REVISION = 4
+REVISION = 5
HOMEPAGE = https://www.cmake.org/
diff --git a/devel/cmake/cmake.port.mk b/devel/cmake/cmake.port.mk
index 418d6341cae..6011c719b04 100644
--- a/devel/cmake/cmake.port.mk
+++ b/devel/cmake/cmake.port.mk
@@ -7,6 +7,14 @@ CONFIGURE_ENV +=LIB${_n}_VERSION=${_v}
MAKE_ENV +=LIB${_n}_VERSION=${_v}
.endfor
+# Enable the override of shared library version using LIBxxx_VERSION, putting
+# them under ports control. See cmGeneratorTarget.cxx
+MODCMAKE_USE_SAHRED_LIBS ?= Yes
+.if ${MODCMAKE_USE_SAHRED_LIBS:L} == "yes"
+CONFIGURE_ENV += MODCMAKE_USE_SAHRED_LIBS=yes
+MAKE_ENV += MODCMAKE_USE_SAHRED_LIBS=yes
+.endif
+
USE_NINJA ?= Yes
.if ${USE_NINJA:L} == "yes"
diff --git a/devel/cmake/patches/patch-Source_cmGeneratorTarget_cxx
b/devel/cmake/patches/patch-Source_cmGeneratorTarget_cxx
index 14a878c0d42..c4d6ffb2d55 100644
--- a/devel/cmake/patches/patch-Source_cmGeneratorTarget_cxx
+++ b/devel/cmake/patches/patch-Source_cmGeneratorTarget_cxx
@@ -1,57 +1,54 @@
-$OpenBSD: patch-Source_cmGeneratorTarget_cxx,v 1.16 2021/05/09 14:46:15
rsadowski Exp $
-
Index: Source/cmGeneratorTarget.cxx
--- Source/cmGeneratorTarget.cxx.orig
+++ Source/cmGeneratorTarget.cxx
-@@ -4810,9 +4810,14 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibrary
- // Check for library version properties.
- cmProp version = this->GetProperty("VERSION");
- cmProp soversion = this->GetProperty("SOVERSION");
-+#if defined(__OpenBSD__)
-+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
-+ this->GetType() != cmStateEnums::MODULE_LIBRARY) {
-+#else
- if (!this->HasSOName(config) ||
- this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
- this->IsFrameworkOnApple()) {
-+#endif
- // Versioning is supported only for shared libraries and modules,
- // and then only when the platform supports an soname flag.
- version = nullptr;
-@@ -4836,6 +4841,36 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibrary
-
+@@ -4837,6 +4837,50 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibrary
// The library name.
targetNames.Output = prefix + targetNames.Base + suffix;
-+
+
+#if defined(__OpenBSD__)
+ // Override shared library version using LIBxxx_VERSION
+ // environment variable. Needed for OpenBSD ports system.
-+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
-+ this->GetType() == cmStateEnums::MODULE_LIBRARY) {
++ const auto isUseSahredLibs = [&]() -> bool {
++ std::string use_slibs;
++ return ((cmSystemTools::GetEnv("MODCMAKE_USE_SAHRED_LIBS", use_slibs) &&
++ use_slibs == std::string("yes")));
++ };
+
-+ std::string env_vers;
-+ const std::string env_name("LIB" + targetNames.Base + "_VERSION");
-+ if (char * env = getenv(env_name.c_str()))
-+ env_vers = env;
++ // Target name libXXX with PREFIX set to ""
++ auto getLibName = [&](std::string& baseName) {
++ const std::string toMatch = "lib";
++ if (baseName.find(toMatch) == 0 && prefix == "")
++ return baseName.substr(toMatch.length());
++ return baseName;
++ };
+
-+ if (!env_vers.empty()) {
-+ const size_t first = env_vers.find_first_of(".");
-+ const size_t last = env_vers.find_last_of(".");
++ if (isUseSahredLibs() && this->GetType() == cmStateEnums::SHARED_LIBRARY) {
++ std::string lib_version;
++ const std::string lib_name = "LIB" + getLibName(targetNames.Base) +
"_VERSION";
++ if (cmSystemTools::GetEnv(lib_name, lib_version)) {
++ if (!lib_version.empty()) {
++ const size_t first = lib_version.find_first_of(".");
++ const size_t last = lib_version.find_last_of(".");
+
-+ if ((first != last) || (first == std::string::npos)) {
-+ std::string msg = "Bad ";
-+ msg += env_name;
-+ msg += " specification: ";
-+ msg += env_vers;
-+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
-+ } else {
-+ version = new std::string(env_vers);
-+ soversion = new std::string(env_vers);
++ if ((first != last) || (first == std::string::npos)) {
++ const std::string msg = "Bad " + lib_name + " specification: " +
lib_version;
++ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR,
msg);
++ }
++ else {
++ version = new std::string(lib_version);
++ soversion = new std::string(lib_version);
++ }
++ }
++ }
++ else {
++ if (soversion) {
++ version = new std::string("0.0");
++ soversion = new std::string("0.0");
+ }
+ }
+ }
+#endif
+
-
if (this->IsFrameworkOnApple()) {
targetNames.Real = prefix;
+ if (!this->Makefile->PlatformIsAppleEmbedded()) {