You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
I'm trying to build a small toy project. I want to build spdlog as a shared library, link it relative to my executable using a rpath.
Before installation, the executable is correctly linked to spdlog
cmake_minimum_required(VERSION 3.28)
project(rpath_and_output_directory)
set(CMAKE_CXX_STANDARD 17)
# -----------------------------------------------------------------------# bibliothèque partagée# -----------------------------------------------------------------------option(BUILD_SHARED_LIBS "Build using shared libraries"ON)
# ------------------------------------------------------------------------------# fmt# ------------------------------------------------------------------------------message(STATUS "-> getting fmt from github")
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 0c9fce2ffefecfdce794e1859584e25877b7b592 # 11.0.2
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(fmt)
# ------------------------------------------------------------------------------# spdlog# ------------------------------------------------------------------------------message(STATUS "-> getting spdlog from github")
set(SPDLOG_FMT_EXTERNAL ON)
set(SPDLOG_BUILD_SHARED ON)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG 27cb4c76708608465c413f6d0e6b8d99a4d84302
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(spdlog)
# ------------------------------------------------------------------------------# installation# ------------------------------------------------------------------------------# où est-ce que le projet est installéset(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")
# Configurer le rpath pour pointer vers le répertoire des bibliothèques dynamiquesset(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../lib64:$ORIGIN")
# use, i.e. don't skip the full RPATH for the build treeset(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)
# add the automatically determined parts of the RPATH# which point to directories outside the build tree to the install RPATHset(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# ------------------------------------------------------------------------------# les bibliothèques internes# ------------------------------------------------------------------------------add_subdirectory("${CMAKE_SOURCE_DIR}/src/lib/x2_daq_configuration")
add_subdirectory("${CMAKE_SOURCE_DIR}/src/lib/x2_time_stamp_generator")
add_subdirectory("${CMAKE_SOURCE_DIR}/src/lib/x2_mapping_generator")
# ------------------------------------------------------------------------------# les éxecutables# ------------------------------------------------------------------------------add_executable(exe_1 exe_1.cxx)
target_link_libraries(exe_1 PRIVATE
x2_daq_configuration
x2_timestamp_generator
x2_mapping
fmt::fmt
spdlog::spdlog
)
add_executable(exe_2 exe_2.cxx)
target_link_libraries(exe_2 PRIVATE
x2_daq_configuration
x2_timestamp_generator
x2_mapping
fmt::fmt
spdlog::spdlog
)
# ------------------------------------------------------------------------------# installation# ------------------------------------------------------------------------------install(TARGETS exe_1 DESTINATION bin)
install(TARGETS exe_2 DESTINATION bin)
install(TARGETS x2_timestamp_generator x2_mapping x2_daq_configuration DESTINATION lib)
Why is spdlog not correctly linked after installation, while all other libraries are?
Thank you for your time and consideration.
Olivier
The text was updated successfully, but these errors were encountered:
Hi there,
I'm trying to build a small toy project. I want to build spdlog as a shared library, link it relative to my executable using a rpath.
Before installation, the executable is correctly linked to spdlog
after install the executable can no longer find spdlog
Below is my CmakeLists
Why is spdlog not correctly linked after installation, while all other libraries are?
Thank you for your time and consideration.
Olivier
The text was updated successfully, but these errors were encountered: