mdbx-cmake: fix/refine RPATH for tools.

Change-Id: Id97db43475b757f74eb5a5532390e0e65d610df0
This commit is contained in:
Leonid Yuriev 2019-09-11 01:23:48 +03:00
parent 5cfcc0e3c1
commit 17ba1f4d22

View File

@ -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)