Skip to content

Commit

Permalink
Set proper RPATH also for macOS + add a rationale behind it (#77).
Browse files Browse the repository at this point in the history
On macOS, RPATH has to be set differently from Linux. For more details, see
https://cmake.org/Wiki/CMake_RPATH_handling
  • Loading branch information
s3rvac committed Jan 12, 2018
1 parent 60436fb commit 3c76114
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ option(RETDEC_TESTS "Build tests." OFF)

set(CMAKE_CXX_STANDARD 14)

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

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

0 comments on commit 3c76114

Please sign in to comment.