Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make RPATH relative #158

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ option(BUILD_ROCKSDB_BENCH "Build rocksdb benchmark." OFF)

option(FORMAT_FILES_WITH_CLANG_FORMAT_BEFORE_EACH_BUILD "If the command clang-format is available, format source files before each build. Turn this off if the build time is too slow." OFF)

if (FORCE_INSTALL_RPATH)
message(DEPRECATION "FORCE_INSTALL_RPATH is obsoleted")
endif (FORCE_INSTALL_RPATH)

if (BUILD_PWAL)
find_package(limestone REQUIRED)
endif()
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* CMake `>= 3.10`
* C++ Compiler `>= C++17`
* Build related libraries - on Ubuntu, you can install with following command.
* Build related libraries - on Ubuntu, you can install with following command.
Please check in advance whether ubuntu.deps is correct.:

```sh
Expand Down Expand Up @@ -44,8 +44,6 @@ Available options:
* Create static libraries instead of shared libraries
* `-DCMAKE_PREFIX_PATH=<installation directory>`
* Indicate prerequiste installation directory (ex. yakushima)
* `-DFORCE_INSTALL_RPATH=ON`
* Force set RPATH for non-default library paths
* `-DFORMAT_FILES_WITH_CLANG_FORMAT_BEFORE_EACH_BUILD=ON`
* Use formatting for source files
* `-DTSURUGI_FAST_SHUTDOWN=ON`
Expand Down Expand Up @@ -105,7 +103,7 @@ Available options:
succeeds in an environment with low contention. Because, as a result,
the probability of aborting is small.

## Install
## Install

```sh
ninja install
Expand Down
31 changes: 0 additions & 31 deletions cmake/InstallOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,6 @@ function(install_custom target_name export_name)
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime
)
# Add INSTALL_RPATH from CMAKE_INSTALL_PREFIX and CMAKE_PREFIX_PATH
# The default behavior of CMake omits RUNPATH if it is already in CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES.
if (FORCE_INSTALL_RPATH)
get_target_property(target_type ${target_name} TYPE)
if (target_type STREQUAL "SHARED_LIBRARY"
OR target_type STREQUAL "EXECUTABLE")
get_target_property(rpath ${target_name} INSTALL_RPATH)

# add ${CMAKE_INSTALL_PREFIX}/lib if it is not in system link directories
get_filename_component(p "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ABSOLUTE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${p}" is_system)
if (is_system STREQUAL "-1")
list(APPEND rpath "${p}")
endif()

# add each ${CMAKE_PREFIX_PATH}/lib
foreach (p IN LISTS CMAKE_PREFIX_PATH)
get_filename_component(p "${p}/${CMAKE_INSTALL_LIBDIR}" ABSOLUTE)
list(APPEND rpath "${p}")
endforeach()

if (rpath)
set_target_properties(${target_name} PROPERTIES
INSTALL_RPATH "${rpath}")
endif()

# add other than */lib paths
set_target_properties(${target_name} PROPERTIES
INSTALL_RPATH_USE_LINK_PATH ON)
endif()
endif (FORCE_INSTALL_RPATH)
# Install include files of interface libraries manually
# INTERFACE_INCLUDE_DIRECTORIES must contains the following entries:
# - one or more `$<BUILD_INTERFACE:...>` paths (may be absolute paths on source-tree)
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ endif()

set_target_properties(shirakami
PROPERTIES
LIBRARY_OUTPUT_NAME "kvs"
INSTALL_RPATH "\$ORIGIN/../lib"
LIBRARY_OUTPUT_NAME "kvs"
)

set_compile_options(shirakami)
Expand Down