@cryptotaxi247 / netdata / commits / 402389ecf

Switch to using a relative RUNPATH for IBM plugin library lookup. (#21131)

We can’t rely on CMAKE_INSTALL_PREFIX at build time because it may be different at install time from what was specified at build time. Instead, set the RUNPATH relative to the binary itself. This is done using the `$ORIGIN` keyword in the RUNPATH to reference the directory the plugin is located in and then using `..` to reference parent directories.

Austin S. Hemmelgarn committed Oct 14, 2025 at 07:13 UTC 402389ecf7abb6f54550e5fefe703e7b73a9996d
1 file changed +4 -3
packaging/cmake/Modules/NetdataIBMPlugin.cmake
+4 -3
@@ -8,8 +8,9 @@ include(FetchContent)
8 # This plugin requires CGO and IBM DB2/MQ headers for compilation.
9 # The plugin will download IBM libraries on first run.
10 macro(add_ibm_plugin_target)
11 - set(IBM_MQ_BUILD_DIR "${CMAKE_BINARY_DIR}/ibm-mqclient")
12 - set(IBM_MQ_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/ibm-mqclient")
11 + set(IBM_MQ_DIR_NAME "ibm-mqclient")
12 + set(IBM_MQ_BUILD_DIR "${CMAKE_BINARY_DIR}/${IBM_MQ_DIR_NAME}")
13 + set(IBM_MQ_INSTALL_SUFFIX "lib/netdata/${IBM_MQ_DIR_NAME}")
14
15 FetchContent_Declare(
16 ibm_mq
@@ -44,7 +45,7 @@ macro(add_ibm_plugin_target)
45 if(EXISTS "${IBM_MQ_BUILD_DIR}/inc/cmqc.h")
46 set(IBM_CGO_CFLAGS "-I${IBM_MQ_BUILD_DIR}/inc")
47 set(IBM_CGO_LDFLAGS "-L${IBM_MQ_BUILD_DIR}/lib64 -lmqic_r")
47 - set(IBM_RPATH_FLAGS "-Wl,-rpath,${IBM_MQ_INSTALL_DIR}/lib64")
48 + set(IBM_RPATH_FLAGS "-Wl,-rpath,$ORIGIN/../../../${IBM_MQ_INSTALL_SUFFIX}/lib64")
49 set(MQ_INSTALLATION_PATH "${IBM_MQ_BUILD_DIR}")
50 else()
51 message(WARNING "IBM MQ client libraries not found - MQ PCF collector will be disabled")