projects/guix·blob java-team · refs

32 lines · 1.4 KiB

1From b54984063cd61636c57add80522bad23f70bb00a Mon Sep 17 00:00:00 2001
2From: Niels Dekker <[email protected]>
3Date: Tue, 3 Feb 2026 14:03:06 +0100
4Subject: [PATCH] ENH: Add relative path to lib directory to RPATH on Linux and
5 MacOS
6
7Addresses issue #1402, Avoid "error while loading shared libraries" on Linux
8---
9 Core/CMakeLists.txt | 10 ++++++++--
10 1 file changed, 8 insertions(+), 2 deletions(-)
11
12diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt
13index 3b70abf12..204782b29 100644
14--- a/Core/CMakeLists.txt
15+++ b/Core/CMakeLists.txt
16@@ -277,8 +277,14 @@ set(ELASTIX_LIBRARIES elastix_lib transformix_lib PARENT_SCOPE)
17
18 if(ELASTIX_BUILD_EXECUTABLE AND NOT WIN32)
19 # Tell the executables where to find the required .so files.
20- set_target_properties(elastix_exe transformix_exe
21- PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}")
22+ # Supports having the executables in bin, and the .so files in the lib directory next to the bin.
23+ if (APPLE)
24+ set_target_properties(elastix_exe transformix_exe
25+ PROPERTIES BUILD_RPATH "@executable_path/../lib" INSTALL_RPATH "@executable_path/../lib:${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}")
26+ else()
27+ set_target_properties(elastix_exe transformix_exe
28+ PROPERTIES BUILD_RPATH "\$ORIGIN/../lib" INSTALL_RPATH "\$ORIGIN/../lib:${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}")
29+ endif()
30 endif()
31
32 if(ELASTIX_BUILD_EXECUTABLE AND NOT ELASTIX_NO_INSTALL_EXECUTABLES)