diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index a1a73dcff..383d0396a 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -233,14 +233,33 @@ function(resolve_arrow_dependency) "https://archive.apache.org/dist/thrift/0.22.0/thrift-0.22.0.tar.gz") endif() + # FetchContent sets arrow_SOURCE_DIR to the tarball root (SOURCE_SUBDIR is cpp) + # and on CMake < 3.30 project(arrow) only sets it as a cache variable, so the + # normal variable takes precedence and Arrow looks for thirdparty/versions.txt + # outside cpp/ (see CMP0180). Patch Arrow to use ARROW_SOURCE_DIR instead. + # See https://github.com/apache/iceberg-cpp/issues/1028. + # TODO: remove once the upstream Arrow fix is released. + set(ARROW_PATCH_COMMAND) + find_program(PATCH patch) + if(PATCH) + set(ARROW_PATCH_COMMAND ${PATCH} -p1 -i) + else() + find_program(GIT git) + if(GIT) + set(ARROW_PATCH_COMMAND ${GIT} apply) + endif() + endif() + if(ARROW_PATCH_COMMAND) + list(APPEND ARROW_PATCH_COMMAND + ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/arrow-thirdparty-dir.patch) + endif() + fetchcontent_declare(Arrow ${FC_DECLARE_COMMON_OPTIONS} URL ${ARROW_SOURCE_URL} URL_HASH "SHA256=${ICEBERG_ARROW_BUILD_SHA256_CHECKSUM}" - SOURCE_SUBDIR - cpp - FIND_PACKAGE_ARGS - CONFIG) + PATCH_COMMAND ${ARROW_PATCH_COMMAND} SOURCE_SUBDIR cpp + FIND_PACKAGE_ARGS CONFIG) fetchcontent_makeavailable(Arrow) diff --git a/cmake_modules/arrow-thirdparty-dir.patch b/cmake_modules/arrow-thirdparty-dir.patch new file mode 100644 index 000000000..b3e3843a3 --- /dev/null +++ b/cmake_modules/arrow-thirdparty-dir.patch @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -365,7 +365,7 @@ + # ---------------------------------------------------------------------- + # Thirdparty versions, environment variables, source URLs + +-set(THIRDPARTY_DIR "${arrow_SOURCE_DIR}/thirdparty") ++set(THIRDPARTY_DIR "${ARROW_SOURCE_DIR}/thirdparty") + + add_library(arrow::flatbuffers INTERFACE IMPORTED) + target_include_directories(arrow::flatbuffers