From da6bcfcc70d1e4e36c8d8d37113d6a774f89a78a Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 21 Nov 2016 02:14:13 -0800 Subject: [PATCH] Statically link arrow libraries when building numbuf (#53) * Fix numbuf compilation on Linux * Statically link arrow libraries when building numbuf. * Last fixes. --- numbuf/CMakeLists.txt | 34 ++++++++---------------- numbuf/thirdparty/download_thirdparty.sh | 2 +- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/numbuf/CMakeLists.txt b/numbuf/CMakeLists.txt index 7266e102a..634911383 100644 --- a/numbuf/CMakeLists.txt +++ b/numbuf/CMakeLists.txt @@ -82,21 +82,12 @@ endif() set(ARROW_DIR "${CMAKE_SOURCE_DIR}/thirdparty/arrow/" CACHE STRING "Path of the arrow source directory") -if(APPLE) - set(ARROW_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow.dylib" - CACHE STRING "Path to libarrow.dylib (needs to be changed if arrow is build in debug mode)") - set(ARROW_IO_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_io.dylib" - CACHE STRING "Path to libarrow_io.dylib (needs to be changed if arrow is build in debug mode)") - set(ARROW_IPC_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_ipc.dylib" - CACHE STRING "Path to libarrow_ipc.dylib (needs to be changed if arrow is build in debug mode)") -else() - set(ARROW_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow.so" - CACHE STRING "Path to libarrow.so (needs to be changed if arrow is build in debug mode)") - set(ARROW_IO_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_io.so" - CACHE STRING "Path to libarrow_io.so (needs to be changed if arrow is build in debug mode)") - set(ARROW_IPC_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_ipc.so" - CACHE STRING "Path to libarrow_ipc.so (needs to be changed if arrow is build in debug mode)") -endif() +set(ARROW_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow.a" + CACHE STRING "Path to libarrow.a (needs to be changed if arrow is build in debug mode)") +set(ARROW_IO_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_io.a" + CACHE STRING "Path to libarrow_io.a (needs to be changed if arrow is build in debug mode)") +set(ARROW_IPC_LIB "${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow_ipc.a" + CACHE STRING "Path to libarrow_ipc.a (needs to be changed if arrow is build in debug mode)") include_directories("${ARROW_DIR}/cpp/src/") include_directories("cpp/src/") @@ -116,15 +107,12 @@ get_filename_component(PYTHON_SHARED_LIBRARY ${PYTHON_LIBRARIES} NAME) if(APPLE) add_custom_command(TARGET numbuf POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change ${PYTHON_SHARED_LIBRARY} ${PYTHON_LIBRARIES} libnumbuf.so) - add_custom_command(TARGET numbuf - POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libarrow.dylib" "@loader_path/libarrow.dylib" libnumbuf.so) - add_custom_command(TARGET numbuf - POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libarrow_io.dylib" "@loader_path/libarrow_io.dylib" libnumbuf.so) - add_custom_command(TARGET numbuf - POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libarrow_ipc.dylib" "@loader_path/libarrow_ipc.dylib" libnumbuf.so) endif(APPLE) -target_link_libraries(numbuf ${ARROW_LIB} ${ARROW_IO_LIB} ${ARROW_IPC_LIB} ${PYTHON_LIBRARIES}) +if(APPLE) + target_link_libraries(numbuf ${ARROW_LIB} ${ARROW_IO_LIB} ${ARROW_IPC_LIB} ${PYTHON_LIBRARIES}) +else() + target_link_libraries(numbuf -Wl,--whole-archive ${ARROW_LIB} -Wl,--no-whole-archive ${ARROW_IO_LIB} ${ARROW_IPC_LIB} ${PYTHON_LIBRARIES}) +endif() install(TARGETS numbuf DESTINATION ${CMAKE_SOURCE_DIR}/numbuf/) -install(FILES ${ARROW_LIB} ${ARROW_IO_LIB} ${ARROW_IPC_LIB} DESTINATION ${CMAKE_SOURCE_DIR}/numbuf/) diff --git a/numbuf/thirdparty/download_thirdparty.sh b/numbuf/thirdparty/download_thirdparty.sh index c6a9ea19b..ff5cad62e 100755 --- a/numbuf/thirdparty/download_thirdparty.sh +++ b/numbuf/thirdparty/download_thirdparty.sh @@ -7,4 +7,4 @@ TP_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) git clone https://github.com/pcmoritz/arrow.git "$TP_DIR/arrow" cd "$TP_DIR/arrow" -git checkout 58bd7bedc63d66d5898297bab25b54dfb67665db +git checkout c88bd70c13cf16c07b840623cb466aa98d535be0