|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# Accumulate all dependencies to provide suitable static link parameters to the |
| 19 | +# third party libraries. |
| 20 | +set(ICEBERG_SYSTEM_DEPENDENCIES) |
| 21 | +set(ICEBERG_VENDOR_DEPENDENCIES) |
| 22 | +set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS) |
| 23 | + |
| 24 | +# ---------------------------------------------------------------------- |
| 25 | +# Versions and URLs for toolchain builds |
| 26 | + |
| 27 | +set(ICEBERG_ARROW_BUILD_VERSION "18.1.0") |
| 28 | +set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM |
| 29 | + "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc") |
| 30 | +set(ARROW_VENDORED TRUE) |
| 31 | + |
| 32 | +if(DEFINED ENV{ICEBERG_ARROW_URL}) |
| 33 | + set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}") |
| 34 | +else() |
| 35 | + set(ARROW_SOURCE_URL |
| 36 | + "https://www.apache.org/dyn/closer.cgi?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz" |
| 37 | + "https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz" |
| 38 | + "https://github.com/apache/arrow/releases/download/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz" |
| 39 | + ) |
| 40 | +endif() |
| 41 | + |
| 42 | +# ---------------------------------------------------------------------- |
| 43 | +# FetchContent |
| 44 | + |
| 45 | +include(FetchContent) |
| 46 | +set(FC_DECLARE_COMMON_OPTIONS) |
| 47 | +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) |
| 48 | + list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE) |
| 49 | +endif() |
| 50 | + |
| 51 | +macro(prepare_fetchcontent) |
| 52 | + set(BUILD_SHARED_LIBS OFF) |
| 53 | + set(BUILD_STATIC_LIBS ON) |
| 54 | + set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE) |
| 55 | + set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE) |
| 56 | +endmacro() |
| 57 | + |
| 58 | +# ---------------------------------------------------------------------- |
| 59 | +# Apache Arrow |
| 60 | + |
| 61 | +function(resolve_arrow_dependency) |
| 62 | + set(ARROW_BUILD_SHARED |
| 63 | + OFF |
| 64 | + CACHE BOOL "" FORCE) |
| 65 | + set(ARROW_BUILD_STATIC |
| 66 | + ON |
| 67 | + CACHE BOOL "" FORCE) |
| 68 | + set(ARROW_FILESYSTEM |
| 69 | + OFF |
| 70 | + CACHE BOOL "" FORCE) |
| 71 | + set(ARROW_SIMD_LEVEL |
| 72 | + "NONE" |
| 73 | + CACHE STRING "" FORCE) |
| 74 | + set(ARROW_RUNTIME_SIMD_LEVEL |
| 75 | + "NONE" |
| 76 | + CACHE STRING "" FORCE) |
| 77 | + |
| 78 | + fetchcontent_declare(Arrow |
| 79 | + ${FC_DECLARE_COMMON_OPTIONS} |
| 80 | + URL ${ARROW_SOURCE_URL} |
| 81 | + URL_HASH "SHA256=${ICEBERG_ARROW_BUILD_SHA256_CHECKSUM}" |
| 82 | + SOURCE_SUBDIR |
| 83 | + cpp |
| 84 | + FIND_PACKAGE_ARGS |
| 85 | + NAMES |
| 86 | + Arrow |
| 87 | + CONFIG) |
| 88 | + |
| 89 | + # Add Arrow cmake modules to the search path |
| 90 | + list(PREPEND CMAKE_MODULE_PATH |
| 91 | + ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules) |
| 92 | + |
| 93 | + fetchcontent_makeavailable(Arrow) |
| 94 | + |
| 95 | + if(NOT TARGET Arrow::arrow_static) |
| 96 | + add_library(Arrow::arrow_static INTERFACE IMPORTED) |
| 97 | + target_link_libraries(Arrow::arrow_static INTERFACE arrow_static) |
| 98 | + target_include_directories(Arrow::arrow_static INTERFACE ${arrow_SOURCE_DIR}/cpp/src |
| 99 | + ${arrow_BINARY_DIR}/src) |
| 100 | + endif() |
| 101 | + |
| 102 | + fetchcontent_getproperties(Arrow) |
| 103 | + if(arrow_SOURCE_DIR) |
| 104 | + set(ARROW_VENDORED TRUE) |
| 105 | + install(TARGETS arrow_static |
| 106 | + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 107 | + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" |
| 108 | + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") |
| 109 | + |
| 110 | + get_target_property(ARROW_STATIC_LIB arrow_static OUTPUT_NAME) |
| 111 | + set(ARROW_STATIC_LIB_NAME |
| 112 | + "${CMAKE_STATIC_LIBRARY_PREFIX}${ARROW_STATIC_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX}") |
| 113 | + list(APPEND ICEBERG_VENDOR_DEPENDENCIES |
| 114 | + "Iceberg::arrow_vendored|${ARROW_STATIC_LIB_NAME}") |
| 115 | + else() |
| 116 | + set(ARROW_VENDORED FALSE) |
| 117 | + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Arrow) |
| 118 | + endif() |
| 119 | + |
| 120 | + set(ICEBERG_VENDOR_DEPENDENCIES |
| 121 | + ${ICEBERG_VENDOR_DEPENDENCIES} |
| 122 | + PARENT_SCOPE) |
| 123 | + set(ICEBERG_SYSTEM_DEPENDENCIES |
| 124 | + ${ICEBERG_SYSTEM_DEPENDENCIES} |
| 125 | + PARENT_SCOPE) |
| 126 | + set(ARROW_VENDORED |
| 127 | + ${ARROW_VENDORED} |
| 128 | + PARENT_SCOPE) |
| 129 | +endfunction() |
| 130 | + |
| 131 | +if(ICEBERG_ARROW) |
| 132 | + resolve_arrow_dependency() |
| 133 | +endif() |
0 commit comments