Skip to content

Commit

Permalink
Use relative RPATHs on Linux and Darwin (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn authored Mar 8, 2021
1 parent 30bfe6d commit ad665d1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,36 @@ find_package(ApMon MODULE)
find_package(CURL MODULE)
find_package(RdKafka CONFIG)

####################################
# Set OUTPUT vars
####################################

set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")

####################################
# Handle RPATH
####################################
include(GNUInstallDirs)

# Build targets with install rpath on Mac to dramatically speed up installation
# Use relative RPATHs
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if("${isSystemDir}" STREQUAL "-1")
if("${isSystemDir}" STREQUAL "-1")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
unset(isSystemDir)

####################################
# Library
####################################

set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")

# Backends
message(STATUS "Backends")
message(STATUS " Compiling StdCout backend")
Expand Down

0 comments on commit ad665d1

Please sign in to comment.