File 0001-Use-correct-relative-paths-for-RUNPATH.patch of Package nest
From 74922ef892d6e95848c1a46bb6962ac041eb064d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Wed, 27 Jul 2022 15:39:23 +0200
Subject: [PATCH 1/2] Use correct relative paths for RUNPATH
CMAKE_INSTALL_LIBDIR may be a path relative to CMAKE_INSTALL_PREFIX or
absolute. Make sure used paths are absolute, and then calculate the
relative paths between.
For libraries, the relative path is trivially just "./" (all libraries
are in the same directory).
Partial fix for #2438.
---
cmake/ProcessOptions.cmake | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/cmake/ProcessOptions.cmake b/cmake/ProcessOptions.cmake
index fc4bd44..f789ecb 100644
--- a/cmake/ProcessOptions.cmake
+++ b/cmake/ProcessOptions.cmake
@@ -191,29 +191,40 @@ function( NEST_PROCESS_STATIC_LIBRARIES )
# ``${CMAKE_INSTALL_PREFIX}/bin`` for the nest and sli executables, ``${CMAKE_INSTALL_PREFIX}/lib/nest`` for all
# dynamic libraries except PyNEST (libnestkernel.so, etc.), and something like
# ``${CMAKE_INSTALL_PREFIX}/lib/python3.x/site-packages/nest`` for ``pynestkernel.so``. The RPATH is relative to
- # this origin, so the binary ``bin/nest`` can find the files in the relative location ``../lib/nest``, and
- # similarly for PyNEST and the other libraries. For simplicity, we set all the possibilities on all generated
- # objects.
+ # this origin. For the libraries, the relative path is the same dir ("./"), for the exucutables and python
+ # module the relative path is calculated below.
+ # For simplicity, we set all the possibilities on all generated objects.
# PyNEST can only act as an entry point; it does not need to be included in the other objects' RPATH itself.
+ cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
+ BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
+ OUTPUT_VARIABLE executable_libdir_relative_path)
+
+ cmake_path(ABSOLUTE_PATH PYEXECDIR
+ BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+ OUTPUT_VARIABLE pyexecdir_full)
+ cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
+ BASE_DIRECTORY "${pyexecdir_full}/nest"
+ OUTPUT_VARIABLE python_libdir_relative_path)
+
if ( APPLE )
set( CMAKE_INSTALL_RPATH
# for binaries
- "@loader_path/../${CMAKE_INSTALL_LIBDIR}/nest"
+ "@executable_path/${executable_libdir_relative_path}/nest"
# for libraries (except pynestkernel)
- "@loader_path/../../${CMAKE_INSTALL_LIBDIR}/nest"
+ "@loader_path"
# for pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
- "@loader_path/../../../nest"
+ "@loader_path/${python_libdir_relative_path}/nest"
PARENT_SCOPE )
else ()
set( CMAKE_INSTALL_RPATH
# for binaries
- "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/nest"
+ "\$ORIGIN/${executable_libdir_relative_path}/nest"
# for libraries (except pynestkernel)
- "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}/nest"
+ "\$ORIGIN"
# for pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
- "\$ORIGIN/../../../nest"
+ "\$ORIGIN/${python_libdir_relative_path}/nest"
PARENT_SCOPE )
endif ()
--
2.37.1