Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2179,3 +2179,31 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------

The file cpp/cmake_modules/BuildUtils.cmake contains code from

https://gist.github.com/cristianadam/ef920342939a89fae3e8a85ca9459b49

which is made available under the MIT license

Copyright (c) 2019 Cristian Adam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions ci/scripts/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ build() {
-DARROW_HDFS=OFF \
-DARROW_JEMALLOC=OFF \
-DARROW_JSON=ON \
-DARROW_MIMALLOC=ON \
-DARROW_PACKAGE_PREFIX="${MINGW_PREFIX}" \
-DARROW_PARQUET=ON \
-DARROW_USE_GLOG=OFF \
Expand Down
30 changes: 9 additions & 21 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@ endif()
# Linker and Dependencies
#

# TODO: Also rework how these libs work
set(ARROW_LINK_LIBS)
set(ARROW_SHARED_INSTALL_INTERFACE_LIBS)
set(ARROW_STATIC_INSTALL_INTERFACE_LIBS)

# Libraries to link statically with libarrow.so
set(ARROW_LINK_LIBS)
set(ARROW_STATIC_LINK_LIBS)
Expand All @@ -655,53 +650,43 @@ if(ARROW_USE_OPENSSL)
set(ARROW_OPENSSL_LIBS OpenSSL::Crypto OpenSSL::SSL)
list(APPEND ARROW_LINK_LIBS ${ARROW_OPENSSL_LIBS})
list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_OPENSSL_LIBS})
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_OPENSSL_LIBS})
endif()

if(ARROW_WITH_BROTLI)
# Order is important for static linking
set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon)
list(APPEND ARROW_LINK_LIBS ${ARROW_BROTLI_LIBS})
list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS})
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_BROTLI_LIBS})
endif()

if(ARROW_WITH_BZ2)
list(APPEND ARROW_STATIC_LINK_LIBS BZip2::BZip2)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS BZip2::BZip2)
endif()

if(ARROW_WITH_LZ4)
list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4)
endif()

if(ARROW_WITH_SNAPPY)
list(APPEND ARROW_STATIC_LINK_LIBS Snappy::snappy)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS Snappy::snappy)
endif()

if(ARROW_WITH_ZLIB)
list(APPEND ARROW_STATIC_LINK_LIBS ZLIB::ZLIB)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ZLIB::ZLIB)
endif()

if(ARROW_WITH_ZSTD)
list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_ZSTD_LIBZSTD})
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_ZSTD_LIBZSTD})
endif()

if(ARROW_ORC)
list(APPEND ARROW_LINK_LIBS orc::liborc ${ARROW_PROTOBUF_LIBPROTOBUF})
list(APPEND ARROW_STATIC_LINK_LIBS orc::liborc ${ARROW_PROTOBUF_LIBPROTOBUF})
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS orc::liborc
${ARROW_PROTOBUF_LIBPROTOBUF})
endif()

if(ARROW_USE_GLOG)
list(APPEND ARROW_LINK_LIBS glog::glog)
list(APPEND ARROW_STATIC_LINK_LIBS glog::glog)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS glog::glog)
add_definitions("-DARROW_USE_GLOG")
endif()

Expand All @@ -712,7 +697,6 @@ endif()
if(ARROW_WITH_UTF8PROC)
list(APPEND ARROW_LINK_LIBS utf8proc::utf8proc)
list(APPEND ARROW_STATIC_LINK_LIBS utf8proc::utf8proc)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS utf8proc::utf8proc)
endif()

add_custom_target(arrow_dependencies)
Expand Down Expand Up @@ -807,19 +791,24 @@ if(ARROW_BUILD_BENCHMARKS)
endif()
endif()

set(ARROW_SYSTEM_LINK_LIBS)

if(ARROW_JEMALLOC)
add_definitions(-DARROW_JEMALLOC)
add_definitions(-DARROW_JEMALLOC_INCLUDE_DIR=${JEMALLOC_INCLUDE_DIR})
list(APPEND ARROW_SYSTEM_LINK_LIBS jemalloc::jemalloc)
list(APPEND ARROW_LINK_LIBS jemalloc::jemalloc)
list(APPEND ARROW_STATIC_LINK_LIBS jemalloc::jemalloc)
endif()

if(ARROW_MIMALLOC)
add_definitions(-DARROW_MIMALLOC)
list(APPEND ARROW_SYSTEM_LINK_LIBS mimalloc::mimalloc)
list(APPEND ARROW_LINK_LIBS mimalloc::mimalloc)
list(APPEND ARROW_STATIC_LINK_LIBS mimalloc::mimalloc)
endif()

# ----------------------------------------------------------------------
# Handle platform-related libraries like -pthread

set(ARROW_SYSTEM_LINK_LIBS)

if(THREADS_FOUND)
list(APPEND ARROW_SYSTEM_LINK_LIBS Threads::Threads)
endif()
Expand All @@ -836,7 +825,6 @@ endif()

list(APPEND ARROW_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS})
list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS})
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_SYSTEM_LINK_LIBS})

#
# Subdirectories
Expand Down
104 changes: 98 additions & 6 deletions cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,89 @@ function(REUSE_PRECOMPILED_HEADER_LIB TARGET_NAME LIB_NAME)
endif()
endfunction()

# Based on MIT-licensed
# https://gist.github.com/cristianadam/ef920342939a89fae3e8a85ca9459b49
function(create_merged_static_lib output_target)
set(options)
set(one_value_args NAME ROOT)
set(multi_value_args TO_MERGE)
cmake_parse_arguments(ARG
"${options}"
"${one_value_args}"
"${multi_value_args}"
${ARGN})
if(ARG_UNPARSED_ARGUMENTS)
message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
endif()

set(
output_lib_path
${BUILD_OUTPUT_ROOT_DIRECTORY}${CMAKE_STATIC_LIBRARY_PREFIX}${ARG_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
)

set(all_library_paths $<TARGET_FILE:${ARG_ROOT}>)
foreach(lib ${ARG_TO_MERGE})
list(APPEND all_library_paths $<TARGET_FILE:${lib}>)
endforeach()

if(APPLE)
set(BUNDLE_COMMAND
"libtool"
"-no_warning_for_no_symbols"
"-static"
"-o"
${output_lib_path}
${all_library_paths})
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU)$")
set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar)

file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n")
file(APPEND ${ar_script_path}.in "ADDLIB $<TARGET_FILE:${ARG_ROOT}>\n")

foreach(lib ${ARG_TO_MERGE})
file(APPEND ${ar_script_path}.in "ADDLIB $<TARGET_FILE:${lib}>\n")
endforeach()

file(APPEND ${ar_script_path}.in "SAVE\nEND\n")
file(GENERATE OUTPUT ${ar_script_path} INPUT ${ar_script_path}.in)
set(ar_tool ${CMAKE_AR})

if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(ar_tool ${CMAKE_CXX_COMPILER_AR})
endif()

set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path})

elseif(MSVC)
if(NOT CMAKE_LIBTOOL)
find_program(lib_tool lib HINTS "${CMAKE_CXX_COMPILER}/..")
if("${lib_tool}" STREQUAL "lib_tool-NOTFOUND")
message(FATAL_ERROR "Cannot locate libtool to bundle libraries")
endif()
else()
set(${lib_tool} ${CMAKE_LIBTOOL})
endif()
set(BUNDLE_TOOL ${lib_tool})
set(BUNDLE_COMMAND ${BUNDLE_TOOL} /NOLOGO /OUT:${output_lib_path}
${all_library_paths})
else()
message(FATAL_ERROR "Unknown bundle scenario!")
endif()

add_custom_command(COMMAND ${BUNDLE_COMMAND}
OUTPUT ${output_lib_path}
COMMENT "Bundling ${output_lib_path}"
VERBATIM)

message(
STATUS "Creating bundled static library target ${output_target} at ${output_lib_path}"
)

add_custom_target(${output_target} ALL DEPENDS ${output_lib_path})
add_dependencies(${output_target} ${ARG_ROOT} ${ARG_TO_MERGE})
install(FILES ${output_lib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endfunction()

# \arg OUTPUTS list to append built targets to
function(ADD_ARROW_LIB LIB_NAME)
set(options BUILD_SHARED BUILD_STATIC)
Expand Down Expand Up @@ -351,14 +434,14 @@ function(ADD_ARROW_LIB LIB_NAME)
${LIB_NAME_STATIC})

if(ARG_STATIC_INSTALL_INTERFACE_LIBS)
set(INTERFACE_LIBS ${ARG_STATIC_INSTALL_INTERFACE_LIBS})
else()
set(INTERFACE_LIBS ${ARG_STATIC_LINK_LIBS})
target_link_libraries(${LIB_NAME}_static LINK_PUBLIC
"$<INSTALL_INTERFACE:${ARG_STATIC_INSTALL_INTERFACE_LIBS}>")
endif()

target_link_libraries(${LIB_NAME}_static LINK_PUBLIC
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>"
"$<INSTALL_INTERFACE:${INTERFACE_LIBS}>")
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
endif()

install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
EXPORT ${LIB_NAME}_targets
Expand Down Expand Up @@ -832,3 +915,12 @@ function(ARROW_INSTALL_CMAKE_FIND_MODULE MODULE)
install(FILES "${ARROW_SOURCE_DIR}/cmake_modules/Find${MODULE}.cmake"
DESTINATION "${ARROW_CMAKE_INSTALL_DIR}")
endfunction()

# Implementations of lisp "car" and "cdr" functions
macro(ARROW_CAR var)
set(${var} ${ARGV1})
endmacro()

macro(ARROW_CDR var rest)
set(${var} ${ARGN})
endmacro()
Loading