From 17ba1f4d228c9ff798f7a4bd98f2d2c1a19abb86 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Wed, 11 Sep 2019 01:23:48 +0300 Subject: [PATCH] mdbx-cmake: fix/refine RPATH for tools. Change-Id: Id97db43475b757f74eb5a5532390e0e65d610df0 --- src/tools/CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index e54f5146..2724a11a 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,5 +1,25 @@ set(MDBX_TOOLS mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat) +# 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) + +# 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) + +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if(isSystemDir EQUAL -1) + if(APPLE) + set(CMAKE_INSTALL_RPATH "@executable_path/../lib") + else() + set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib") + endif() +endif() + foreach(TOOL ${MDBX_TOOLS}) if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") add_executable(${TOOL} ${TOOL}.c wingetopt.c wingetopt.h)