Skip to content

Commit

Permalink
Merge pull request #172 from boeschf/rpaths/for_bundled
Browse files Browse the repository at this point in the history
rpaths for bundled oomph libs
  • Loading branch information
boeschf authored Dec 16, 2024
2 parents 48f32aa + eb77640 commit 02a06aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,16 @@ install(

export(EXPORT ghex-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/ghex-targets.cmake")

# set rpaths for bundled oomph libraries
if(GHEX_USE_BUNDLED_OOMPH)
include(ghex_rpath)
set_target_properties(ghex PROPERTIES INSTALL_RPATH "${rpath_origin}")
if (GHEX_TRANSPORT_BACKEND STREQUAL "LIBFABRIC")
set_target_properties(oomph_libfabric PROPERTIES INSTALL_RPATH "${rpath_origin}")
elseif (GHEX_TRANSPORT_BACKEND STREQUAL "UCX")
set_target_properties(oomph_ucx PROPERTIES INSTALL_RPATH "${rpath_origin}")
else()
set_target_properties(oomph_mpi PROPERTIES INSTALL_RPATH "${rpath_origin}")
endif()
endif()
21 changes: 1 addition & 20 deletions bindings/python/src/_pyghex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,10 @@ target_link_libraries(pyghex PRIVATE ghex)
ghex_link_to_oomph(ghex)

# Set RPaths such that the python module is able to find libghex
include(ghex_rpath)
if (SKBUILD_PROJECT_NAME)
# rpath_origin for libraries that have their dependencies in the same directory (installed in ${CMAKE_INSTALL_LIBDIR})
# rpath_origin_install_libdir for the pyghex library that has its dependencies in ${CMAKE_INSTALL_LIBDIR} relative to its directory
if(APPLE)
set(rpath_origin "@loader_path")
set(rpath_origin_install_libdir "@loader_path/${CMAKE_INSTALL_LIBDIR}")
else()
set(rpath_origin "$ORIGIN")
set(rpath_origin_install_libdir "$ORIGIN/${CMAKE_INSTALL_LIBDIR}")
endif()

set_target_properties(pyghex PROPERTIES INSTALL_RPATH "${rpath_origin_install_libdir}")
install(TARGETS pyghex DESTINATION .)

# all other packages are installed to ${CMAKE_INSTALL_LIBDIR}, therefore can resolve to each other via $ORIGIN
set_target_properties(ghex PROPERTIES INSTALL_RPATH "${rpath_origin}")
if (GHEX_TRANSPORT_BACKEND STREQUAL "LIBFABRIC")
set_target_properties(oomph_libfabric PROPERTIES INSTALL_RPATH "${rpath_origin}")
elseif (GHEX_TRANSPORT_BACKEND STREQUAL "UCX")
set_target_properties(oomph_ucx PROPERTIES INSTALL_RPATH "${rpath_origin}")
else()
set_target_properties(oomph_mpi PROPERTIES INSTALL_RPATH "${rpath_origin}")
endif()
else()
set_target_properties(pyghex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(TARGETS pyghex DESTINATION ${GHEX_PYTHON_LIB_PATH}/ghex)
Expand Down
9 changes: 9 additions & 0 deletions cmake/ghex_rpath.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# rpath_origin for libraries that have their dependencies in the same directory (installed in ${CMAKE_INSTALL_LIBDIR})
# rpath_origin_install_libdir for the pyghex library that has its dependencies in ${CMAKE_INSTALL_LIBDIR} relative to its directory
if(APPLE)
set(rpath_origin "@loader_path")
set(rpath_origin_install_libdir "@loader_path/${CMAKE_INSTALL_LIBDIR}")
else()
set(rpath_origin "$ORIGIN")
set(rpath_origin_install_libdir "$ORIGIN/${CMAKE_INSTALL_LIBDIR}")
endif()

0 comments on commit 02a06aa

Please sign in to comment.