65fa4c
From 635ab930f6185d1ec3e4d99109e2edf0533b0d00 Mon Sep 17 00:00:00 2001
65fa4c
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
65fa4c
Date: Wed, 23 Jun 2021 21:03:15 +0200
65fa4c
Subject: [PATCH] testDynamicLoader: Use LIBDL_SO macro if defined.
65fa4c
MIME-Version: 1.0
65fa4c
Content-Type: text/plain; charset=UTF-8
65fa4c
Content-Transfer-Encoding: 8bit
65fa4c
65fa4c
Starting with glibc v2.34 there is no external version of libdl.so
65fa4c
anymore.  It has been merged into the glibc libc.so.
65fa4c
65fa4c
Assuming libdl.so will be present will break the test, thus the
65fa4c
LIBDL_SO macro should be used.  If the macro is not defined on
65fa4c
the system, we ensure it will be defined using the previously
65fa4c
hardcoded value.
65fa4c
65fa4c
Signed-off-by: Björn Esser <besser82@fedoraproject.org>
65fa4c
---
65fa4c
 cmake-3.20.4/Source/kwsys/testDynamicLoader.cxx | 14 ++++++++++++--
65fa4c
 1 file changed, 12 insertions(+), 2 deletions(-)
65fa4c
65fa4c
Index: cmake-3.21.0-rc1/Source/kwsys/testDynamicLoader.cxx
65fa4c
===================================================================
65fa4c
--- cmake-3.21.0-rc1.orig/Source/kwsys/testDynamicLoader.cxx
65fa4c
+++ cmake-3.21.0-rc1/Source/kwsys/testDynamicLoader.cxx
65fa4c
@@ -8,6 +8,25 @@
65fa4c
 #  include <be/kernel/OS.h> /* disable_debugger() API. */
65fa4c
 #endif
65fa4c
 
65fa4c
+// Needed for __GLIBC__ test macro.
65fa4c
+#ifdef __linux__
65fa4c
+#  include <features.h>
65fa4c
+#endif
65fa4c
+
65fa4c
+// Will define LIBDL_SO macro on systems with glibc.
65fa4c
+#ifdef __GLIBC__
65fa4c
+#  include <gnu/lib-names.h>
65fa4c
+// Define to LIBC_SO, if not defined by above header.
65fa4c
+#  ifndef LIBDL_SO
65fa4c
+#    define LIBDL_SO LIBC_SO
65fa4c
+#  endif
65fa4c
+#endif
65fa4c
+
65fa4c
+// Define the LIBDL_SO macro, if not defined above.
65fa4c
+#ifndef LIBDL_SO
65fa4c
+#  define LIBDL_SO "libdl.so"
65fa4c
+#endif
65fa4c
+
65fa4c
 // Work-around CMake dependency scanning limitation.  This must
65fa4c
 // duplicate the above list of headers.
65fa4c
 #if 0
65fa4c
@@ -107,8 +126,8 @@ int testDynamicLoader(int argc, char* ar
65fa4c
   // This one is actually fun to test, since dlopen is by default
65fa4c
   // loaded...wonder why :)
65fa4c
   res += TestDynamicLoader("foobar.lib", "dlopen", 0, 1, 0);
65fa4c
-  res += TestDynamicLoader("libdl.so", "dlopen", 1, 1, 1);
65fa4c
-  res += TestDynamicLoader("libdl.so", "TestDynamicLoader", 1, 0, 1);
65fa4c
+  res += TestDynamicLoader(LIBDL_SO, "dlopen", 1, 1, 1);
65fa4c
+  res += TestDynamicLoader(LIBDL_SO, "TestDynamicLoader", 1, 0, 1);
65fa4c
 #endif
65fa4c
   // Now try on the generated library
65fa4c
   std::string libname = GetLibName(KWSYS_NAMESPACE_STRING "TestDynload");