From 4679230070f29d029f9682f0dd2b2fadba01dbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 16 Oct 2026 18:42:34 +0200 Subject: [PATCH 1/2] build: apply patch on Arrow so it can be used with older versions of CMake --- .../IcebergThirdpartyToolchain.cmake | 27 +++++++++++++++--- cmake_modules/arrow-thirdparty-dir.patch | 28 +++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 cmake_modules/arrow-thirdparty-dir.patch diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index a1a73dcff6..6971b6fe75 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 older CMake (e.g. 3.28) does not override it in project(arrow), so Arrow + # looks for thirdparty/versions.txt outside cpp/. 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(NOT ARROW_PATCH_COMMAND) + message(FATAL_ERROR "patch or git is required to build the vendored Arrow") + endif() + list(APPEND ARROW_PATCH_COMMAND + ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/arrow-thirdparty-dir.patch) + 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 0000000000..b3e3843a3c --- /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 From 74fa731d5668c19e66c2d22a74a390f18031cd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 16 Oct 2026 19:42:40 +0200 Subject: [PATCH 2/2] Review comment --- cmake_modules/IcebergThirdpartyToolchain.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index 6971b6fe75..383d0396a3 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -234,9 +234,10 @@ function(resolve_arrow_dependency) endif() # FetchContent sets arrow_SOURCE_DIR to the tarball root (SOURCE_SUBDIR is cpp) - # and older CMake (e.g. 3.28) does not override it in project(arrow), so Arrow - # looks for thirdparty/versions.txt outside cpp/. Patch Arrow to use - # ARROW_SOURCE_DIR instead. See https://github.com/apache/iceberg-cpp/issues/1028. + # 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) @@ -248,11 +249,10 @@ function(resolve_arrow_dependency) set(ARROW_PATCH_COMMAND ${GIT} apply) endif() endif() - if(NOT ARROW_PATCH_COMMAND) - message(FATAL_ERROR "patch or git is required to build the vendored Arrow") + if(ARROW_PATCH_COMMAND) + list(APPEND ARROW_PATCH_COMMAND + ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/arrow-thirdparty-dir.patch) endif() - list(APPEND ARROW_PATCH_COMMAND - ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/arrow-thirdparty-dir.patch) fetchcontent_declare(Arrow ${FC_DECLARE_COMMON_OPTIONS}