Skip to content

Commit 3c76114

Browse files
committed
Set proper RPATH also for macOS + add a rationale behind it (#77).
On macOS, RPATH has to be set differently from Linux. For more details, see https://cmake.org/Wiki/CMake_RPATH_handling
1 parent 60436fb commit 3c76114

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

CMakeLists.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ option(RETDEC_TESTS "Build tests." OFF)
1313

1414
set(CMAKE_CXX_STANDARD 14)
1515

16-
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
16+
# On Linux and macOS, set RPATH relative to the origin of the installed
17+
# executables (i.e. relative to the bin directory). This allows us to move the
18+
# installation directory into a different location after installation, which is
19+
# useful e.g. when the installation is performed on one machine but we want to
20+
# run the executables on a different machine.
21+
#
22+
# On Windows, there is no need to set anything as DLLs are installed into the
23+
# bin directory, where they are automatically picked up by executables.
24+
#
25+
# For more details, see
26+
# - https://github.com/avast-tl/retdec/issues/77
27+
# - https://cmake.org/Wiki/CMake_RPATH_handling
28+
if(APPLE)
29+
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
30+
elseif(UNIX)
31+
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
32+
endif()
1733

1834
# Build all external projects in the same directory that is directly inside the
1935
# build directory. This reduces path lengths, which is important on Windows as

0 commit comments

Comments
 (0)