From 8d54e333ff4d4b4aa90336231d42dd4c3a944bab Mon Sep 17 00:00:00 2001 From: Merlyn Morgan-Graham Date: Thu, 22 Sep 2016 22:05:13 -0700 Subject: [PATCH] Add RPATH to dynamic library build on OSX --- CMakeLists.txt | 5 +++++ src/lib_json/CMakeLists.txt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bb891e..7c3ae98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ IF(NOT WIN32) ENDIF() ENDIF() +# Enable runtime search path support for dynamic libraries on OSX +IF(APPLE) + SET(CMAKE_MACOSX_RPATH 1) +ENDIF() + SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build") SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory") diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index 99ddc7f..b70c5a8 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -46,6 +46,11 @@ IF(BUILD_SHARED_LIBS) SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} ) + # Set library's runtime search path on OSX + IF(APPLE) + SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." ) + ENDIF() + INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT} RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}