Commit 4189da3f authored by PRUVOST Florent's avatar PRUVOST Florent

add rpath configuration

parent f7729683
Pipeline #26202 passed with stages
in 3 minutes and 28 seconds
......@@ -78,6 +78,14 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts)
# To transform relative path into absolute for a list of libraries
include(LibrariesAbsolutePath)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/MOD)
# Set the RPATH config
# 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)
# the RPATH to be used when installing
list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Define some variables which will be fill in with ccmake or cmake-gui
option(PAMPA_CTEST_MEMCHECK "Use valgrind memcheck explicitly during ctests" OFF)
......@@ -188,6 +196,10 @@ if (COMMON_COMPRESSION)
# BZIP2
find_package (BZip2)
if (BZIP2_FOUND)
list(GET BZIP2_LIBRARIES 0 first_lib)
get_filename_component(lib_path "${first_lib}" PATH)
set(BZIP2_LIBRARY_DIR "${lib_path}")
list(APPEND CMAKE_INSTALL_RPATH "${BZIP2_LIBRARY_DIR}")
add_definitions (-DCOMMON_FILE_COMPRESS_BZ2)
include_directories(${BZIP2_INCLUDE_DIR})
list (APPEND PAMPA_DEPENDENCIES ${BZIP2_LIBRARY} ${BZIP2_LIBRARIES})
......@@ -202,6 +214,10 @@ if (COMMON_COMPRESSION)
# ZLIB
find_package (ZLIB)
if (ZLIB_FOUND)
list(GET ZLIB_LIBRARIES 0 first_lib)
get_filename_component(lib_path "${first_lib}" PATH)
set(ZLIB_LIBRARY_DIR "${lib_path}")
list(APPEND CMAKE_INSTALL_RPATH "${ZLIB_LIBRARY_DIR}")
add_definitions (-DCOMMON_FILE_COMPRESS_GZ)
include_directories(${ZLIB_INCLUDE_DIR})
list (APPEND PAMPA_DEPENDENCIES ${ZLIB_LIBRARIES})
......@@ -212,8 +228,9 @@ endif (COMMON_COMPRESSION)
# PT-Scotch
option (PTSCOTCH "Build PaMPA with PT-Scotch dependencies" ON)
if (PTSCOTCH)
add_definitions (-DPTSCOTCH)
find_package(PTSCOTCH REQUIRED)
list(APPEND CMAKE_INSTALL_RPATH "${PTSCOTCH_LIBRARY_DIRS_DEP}")
add_definitions (-DPTSCOTCH)
file(STRINGS "${PTSCOTCH_INCLUDE_DIRS}/scotch.h" CHECK_SCOTCH_VERSION REGEX "^[ \t]*#define[ \t]+SCOTCH_[A-Z]+[ \t]+[0-9]+.*$")
foreach(item IN ITEMS VERSION RELEASE PATCHLEVEL)
string(REGEX REPLACE ".*#define[ \t]+SCOTCH_${item}[ \t]+([0-9]+).*" "\\1" XYZ ${CHECK_SCOTCH_VERSION})
......@@ -229,6 +246,10 @@ endif ()
# MPI
find_package(MPI REQUIRED)
list(GET MPI_C_LIBRARIES 0 first_lib)
get_filename_component(lib_path "${first_lib}" PATH)
set(MPI_LIBRARY_DIR "${lib_path}")
list(APPEND CMAKE_INSTALL_RPATH "${MPI_LIBRARY_DIR}")
include_directories(${MPI_INCLUDE_PATH})
if (MPI_C_LIBRARIES)
list (APPEND PAMPA_DEPENDENCIES ${MPI_C_LIBRARIES} m)
......@@ -245,6 +266,10 @@ endif ()
# Pthread
if (NOT PTHREAD STREQUAL "None")
find_package(Threads REQUIRED)
list(GET CMAKE_THREAD_LIBS_INIT 0 first_lib)
get_filename_component(lib_path "${first_lib}" PATH)
set(PTHREAD_LIBRARY_DIR "${lib_path}")
list(APPEND CMAKE_INSTALL_RPATH "${PTHREAD_LIBRARY_DIR}")
if (NOT CMAKE_USE_PTHREADS_INIT) # if pthread was not found
message (FATAL_ERROR "Pthread are not available")
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment