Skip to content

Commit

Permalink
set CMAKE_INSTALL_RPATH to installed lib dir
Browse files Browse the repository at this point in the history
Ensures the bundled libraries are found
  • Loading branch information
dschwoerer committed Feb 3, 2023
1 parent 6427a41 commit efe5e3d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,21 @@ This warning is only important for BOUT++ developers and can otherwise be \
safely ignored.")
endif()

include(GNUInstallDirs)

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site ; print('/'.join(site.getusersitepackages().split('/')[-2:]))"
RESULT_VARIABLE PYTHON_WORKING
OUTPUT_VARIABLE PYTHON_SITEPATH_SUFFIX
Expand All @@ -395,6 +410,7 @@ add_custom_command(
MAIN_DEPENDENCY "${CMAKE_CURRENT_LIST_DIR}/cmake/GenerateDateTimeFile.cmake"
)


add_library(bout++
${BOUT_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/bout++-time.cxx
Expand Down Expand Up @@ -656,9 +672,6 @@ endif()
##################################################
# L10N: localisation - include translations


include(GNUInstallDirs)

find_package(Gettext)

if (GETTEXT_FOUND)
Expand Down
5 changes: 5 additions & 0 deletions bout++Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ if(NOT "@ISINSTALLED@")
if(EXISTS "@PROJECT_SOURCE_DIR@/cmake")
list(APPEND CMAKE_MODULE_PATH "@PROJECT_SOURCE_DIR@/cmake")
endif()
else()
if(EXISTS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/ ")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

include(BOUT++functions)
Expand Down

0 comments on commit efe5e3d

Please sign in to comment.