File 0002-Set-only-relevant-RUNPATHs-for-executable-and-librar.patch of Package nest
From 99a9703b28f411818db067d236444c001de45368 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 16:42:37 +0200
Subject: [PATCH 2/2] Set only relevant RUNPATHs for executable and libraries
Remove the RUNPATHs relevant only for executables from all nest libraries,
and vice versa.
Fixes #2438.
---
cmake/ProcessOptions.cmake | 23 ++---------------------
models/CMakeLists.txt | 12 ++++++++++++
nest/CMakeLists.txt | 8 ++++++++
nestkernel/CMakeLists.txt | 12 ++++++++++++
pynest/CMakeLists.txt | 12 ++++++++++++
sli/CMakeLists.txt | 20 ++++++++++++++++++++
6 files changed, 66 insertions(+), 21 deletions(-)
diff --git a/cmake/ProcessOptions.cmake b/cmake/ProcessOptions.cmake
index f789ecb..48490e1 100644
--- a/cmake/ProcessOptions.cmake
+++ b/cmake/ProcessOptions.cmake
@@ -193,13 +193,13 @@ function( NEST_PROCESS_STATIC_LIBRARIES )
# ``${CMAKE_INSTALL_PREFIX}/lib/python3.x/site-packages/nest`` for ``pynestkernel.so``. The RPATH is relative to
# 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)
+ set( executable_libdir_relative_path ${executable_libdir_relative_path} PARENT_SCOPE )
cmake_path(ABSOLUTE_PATH PYEXECDIR
BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
@@ -207,26 +207,7 @@ function( NEST_PROCESS_STATIC_LIBRARIES )
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
- "@executable_path/${executable_libdir_relative_path}/nest"
- # for libraries (except pynestkernel)
- "@loader_path"
- # for pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
- "@loader_path/${python_libdir_relative_path}/nest"
- PARENT_SCOPE )
- else ()
- set( CMAKE_INSTALL_RPATH
- # for binaries
- "\$ORIGIN/${executable_libdir_relative_path}/nest"
- # for libraries (except pynestkernel)
- "\$ORIGIN"
- # for pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
- "\$ORIGIN/${python_libdir_relative_path}/nest"
- PARENT_SCOPE )
- endif ()
+ set( python_libdir_relative_path ${python_libdir_relative_path} PARENT_SCOPE )
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
diff --git a/models/CMakeLists.txt b/models/CMakeLists.txt
index 01012b5..6faeb85 100644
--- a/models/CMakeLists.txt
+++ b/models/CMakeLists.txt
@@ -145,6 +145,18 @@ set( models_sources
add_library( models ${models_sources} )
target_link_libraries( models nestutil sli_lib nestkernel )
+if ( NOT APPLE )
+ set_target_properties( models
+ PROPERTIES
+ INSTALL_RPATH "\$ORIGIN"
+ )
+else ()
+ set_target_properties( models
+ PROPERTIES
+ INSTALL_RPATH "@loader_path"
+ )
+endif ()
+
target_include_directories( models PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty
${PROJECT_SOURCE_DIR}/libnestutil
diff --git a/nest/CMakeLists.txt b/nest/CMakeLists.txt
index 4d0329e..3a44315 100644
--- a/nest/CMakeLists.txt
+++ b/nest/CMakeLists.txt
@@ -27,6 +27,12 @@ if ( NOT APPLE )
set_target_properties( nest
PROPERTIES
LINK_FLAGS "-Wl,--no-as-needed"
+ INSTALL_RPATH "\$ORIGIN/${executable_libdir_relative_path}/nest"
+ )
+else ()
+ set_target_properties( nest
+ PROPERTIES
+ INSTALL_RPATH "@executable_path/${executable_libdir_relative_path}/nest"
)
endif ()
@@ -36,12 +42,14 @@ if ( NOT APPLE )
set_target_properties( nest_lib
PROPERTIES
OUTPUT_NAME nest
+ INSTALL_RPATH "\$ORIGIN"
LINK_FLAGS "-Wl,--no-as-needed"
)
else ()
set_target_properties( nest_lib
PROPERTIES
OUTPUT_NAME nest
+ INSTALL_RPATH "@loader_path"
# delay lookup of symbols from libpython when building with MPI4Py
LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup"
diff --git a/nestkernel/CMakeLists.txt b/nestkernel/CMakeLists.txt
index 916fd92..f50d5b9 100644
--- a/nestkernel/CMakeLists.txt
+++ b/nestkernel/CMakeLists.txt
@@ -152,6 +152,18 @@ install( TARGETS nestkernel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
+if ( NOT APPLE )
+ set_target_properties( nestkernel
+ PROPERTIES
+ INSTALL_RPATH "\$ORIGIN"
+ )
+else ()
+ set_target_properties( nestkernel
+ PROPERTIES
+ INSTALL_RPATH "@loader_path"
+ )
+endif ()
+
FILTER_HEADERS("${nestkernel_sources}" install_headers )
install( FILES ${install_headers}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nest)
diff --git a/pynest/CMakeLists.txt b/pynest/CMakeLists.txt
index 1815f78..e8f2568 100644
--- a/pynest/CMakeLists.txt
+++ b/pynest/CMakeLists.txt
@@ -58,6 +58,18 @@ if ( HAVE_PYTHON )
${SLI_MODULES} ${EXTERNAL_MODULE_LIBRARIES}
)
+ if ( NOT APPLE )
+ set_target_properties( pynestkernel
+ PROPERTIES
+ INSTALL_RPATH "\$ORIGIN/${python_libdir_relative_path}/nest"
+ )
+ else ()
+ set_target_properties( pynestkernel
+ PROPERTIES
+ INSTALL_RPATH "@executable_path/${python_libdir_relative_path}/nest"
+ )
+ endif ()
+
target_include_directories( pynestkernel PRIVATE
${PROJECT_BINARY_DIR}/libnestutil
${PROJECT_SOURCE_DIR}/libnestutil
diff --git a/sli/CMakeLists.txt b/sli/CMakeLists.txt
index 18248ee..22bca5b 100644
--- a/sli/CMakeLists.txt
+++ b/sli/CMakeLists.txt
@@ -125,6 +125,26 @@ install( TARGETS sli_readline sli_lib sli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
+if ( APPLE )
+ set_target_properties( sli
+ PROPERTIES
+ INSTALL_RPATH "@executable_path/${executable_libdir_relative_path}/nest"
+ )
+ set_target_properties( sli_lib sli_readline
+ PROPERTIES
+ INSTALL_RPATH "@loader_path"
+ )
+else ()
+ set_target_properties( sli
+ PROPERTIES
+ INSTALL_RPATH "\$ORIGIN/${executable_libdir_relative_path}/nest"
+ )
+ set_target_properties( sli_lib sli_readline
+ PROPERTIES
+ INSTALL_RPATH "\$ORIGIN"
+ )
+endif ()
+
FILTER_HEADERS("${sli_sources}" install_headers )
install( FILES ${install_headers} gnureadline.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nest)
--
2.37.1