ARROW-1537: [C++] Support building with full path install_name on macOS

If you use `@rpath` for install_name (default), you can use the
DYLD_LIBRARY_PATH environment variable to find libarrow.dylib. But the
DYLD_LIBRARY_PATH environment variable isn't inherited to sub process by
System Integration Protection (SIP). It's difficult to use
libarrow.dylib.

You can use full path install_name by -DARROW_INSTALL_NAME_RPATH=OFF
CMake option. If you use it, you can find libarrow.dylib without
DYLD_LIBRARY_PATH environment variable.

Author: Kouhei Sutou <k...@clear-code.com>

Closes #1100 from kou/cpp-macos-support-install-name and squashes the following 
commits:

8207ace [Kouhei Sutou] [C++] Support building with full path install_name on 
macOS


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/96d451f3
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/96d451f3
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/96d451f3

Branch: refs/heads/master
Commit: 96d451f37eb23d9c9cdc997032d7534a585537ff
Parents: d0b0b74
Author: Kouhei Sutou <k...@clear-code.com>
Authored: Fri Sep 15 10:47:04 2017 -0400
Committer: Wes McKinney <wes.mckin...@twosigma.com>
Committed: Sun Sep 17 13:45:20 2017 -0400

----------------------------------------------------------------------
 ci/travis_before_script_c_glib.sh  | 6 ------
 ci/travis_before_script_cpp.sh     | 3 ++-
 cpp/CMakeLists.txt                 | 4 ++++
 cpp/cmake_modules/BuildUtils.cmake | 9 +++++++--
 4 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/96d451f3/ci/travis_before_script_c_glib.sh
----------------------------------------------------------------------
diff --git a/ci/travis_before_script_c_glib.sh 
b/ci/travis_before_script_c_glib.sh
index 533c892..52bfe87 100755
--- a/ci/travis_before_script_c_glib.sh
+++ b/ci/travis_before_script_c_glib.sh
@@ -77,12 +77,6 @@ pushd $ARROW_C_GLIB_DIR
 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ARROW_CPP_INSTALL/lib/pkgconfig
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ARROW_CPP_INSTALL/lib
 
-if [ $TRAVIS_OS_NAME == "osx" ]; then
-  install_name_tool \
-    -id $ARROW_CPP_INSTALL/lib/libarrow.dylib \
-    $ARROW_CPP_INSTALL/lib/libarrow.dylib
-fi
-
 CONFIGURE_OPTIONS="--prefix=$ARROW_C_GLIB_INSTALL"
 if [ $TRAVIS_OS_NAME != "osx" ]; then
   CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-gtk-doc"

http://git-wip-us.apache.org/repos/asf/arrow/blob/96d451f3/ci/travis_before_script_cpp.sh
----------------------------------------------------------------------
diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh
index a613957..d46fa2f 100755
--- a/ci/travis_before_script_cpp.sh
+++ b/ci/travis_before_script_cpp.sh
@@ -70,7 +70,8 @@ if [ $only_library_mode == "yes" ]; then
   CMAKE_COMMON_FLAGS="\
 $CMAKE_COMMON_FLAGS \
 -DARROW_BUILD_TESTS=OFF \
--DARROW_BUILD_UTILITIES=OFF"
+-DARROW_BUILD_UTILITIES=OFF \
+-DARROW_INSTALL_NAME_RPATH=OFF"
 fi
 
 # Use Ninja for faster builds when using toolchain

http://git-wip-us.apache.org/repos/asf/arrow/blob/96d451f3/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 577a4bb..972132f 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -150,6 +150,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL 
"${CMAKE_CURRENT_SOURCE_DIR}")
     "Build Arrow libraries with RATH set to \$ORIGIN"
     OFF)
 
+  option(ARROW_INSTALL_NAME_RPATH
+    "Build Arrow libraries with install_name set to @rpath"
+    ON)
+
   option(ARROW_PLASMA
     "Build the plasma object store along with Arrow"
     OFF)

http://git-wip-us.apache.org/repos/asf/arrow/blob/96d451f3/cpp/cmake_modules/BuildUtils.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/BuildUtils.cmake 
b/cpp/cmake_modules/BuildUtils.cmake
index 6b2be41..8f92d73 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -176,10 +176,15 @@ function(ADD_ARROW_LIB LIB_NAME)
   endif()
 
   if (APPLE)
-      set_target_properties(${LIB_NAME}_shared
+    if (ARROW_INSTALL_NAME_RPATH)
+      set(_lib_install_name "@rpath")
+    else()
+      set(_lib_install_name "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+    endif()
+    set_target_properties(${LIB_NAME}_shared
       PROPERTIES
       BUILD_WITH_INSTALL_RPATH ON
-      INSTALL_NAME_DIR "@rpath")
+      INSTALL_NAME_DIR "${_lib_install_name}")
   endif()
 
 endfunction()

Reply via email to