kou commented on code in PR #6:
URL: https://github.com/apache/iceberg-cpp/pull/6#discussion_r1899827873


##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -0,0 +1,142 @@
+# 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.
+
+# Accumulate all dependencies to provide suitable static link parameters to the
+# third party libraries.
+set(ICEBERG_SYSTEM_DEPENDENCIES)
+set(ICEBERG_VENDOR_DEPENDENCIES)
+set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
+
+# ----------------------------------------------------------------------
+# Versions and URLs for toolchain builds
+
+set(ICEBERG_ARROW_BUILD_VERSION "18.1.0")
+set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
+    "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc")
+set(ARROW_VENDORED TRUE)

Review Comment:
   Can we remove this?



##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -0,0 +1,142 @@
+# 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.
+
+# Accumulate all dependencies to provide suitable static link parameters to the
+# third party libraries.
+set(ICEBERG_SYSTEM_DEPENDENCIES)
+set(ICEBERG_VENDOR_DEPENDENCIES)
+set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
+
+# ----------------------------------------------------------------------
+# Versions and URLs for toolchain builds
+
+set(ICEBERG_ARROW_BUILD_VERSION "18.1.0")
+set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
+    "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc")
+set(ARROW_VENDORED TRUE)
+
+if(DEFINED ENV{ICEBERG_ARROW_URL})
+  set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}")
+else()
+  set(ARROW_SOURCE_URL
+      
"https://www.apache.org/dyn/closer.cgi?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://github.com/apache/arrow/releases/download/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+  )
+endif()
+
+# ----------------------------------------------------------------------
+# FetchContent
+
+include(FetchContent)
+set(FC_DECLARE_COMMON_OPTIONS)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
+  list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE)
+endif()
+
+macro(prepare_fetchcontent)
+  set(BUILD_SHARED_LIBS OFF)
+  set(BUILD_STATIC_LIBS ON)
+  set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE)
+  set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endmacro()
+
+# ----------------------------------------------------------------------
+# Apache Arrow
+
+function(resolve_arrow_dependency)
+  prepare_fetchcontent()
+
+  set(ARROW_BUILD_SHARED
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_BUILD_STATIC
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_FILESYSTEM
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_RUNTIME_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_POSITION_INDEPENDENT_CODE
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_DEPENDENCY_SOURCE
+      "AUTO"
+      CACHE STRING "" FORCE)
+
+  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
+                       NAMES
+                       Arrow
+                       CONFIG)
+
+  # Add Arrow cmake modules to the search path
+  list(PREPEND CMAKE_MODULE_PATH
+       ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules)

Review Comment:
   Should we move this to the below `if(arrow_SOURCE_DIR)` block?
   



##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -0,0 +1,142 @@
+# 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.
+
+# Accumulate all dependencies to provide suitable static link parameters to the
+# third party libraries.
+set(ICEBERG_SYSTEM_DEPENDENCIES)
+set(ICEBERG_VENDOR_DEPENDENCIES)
+set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
+
+# ----------------------------------------------------------------------
+# Versions and URLs for toolchain builds
+
+set(ICEBERG_ARROW_BUILD_VERSION "18.1.0")
+set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
+    "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc")
+set(ARROW_VENDORED TRUE)
+
+if(DEFINED ENV{ICEBERG_ARROW_URL})
+  set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}")
+else()
+  set(ARROW_SOURCE_URL
+      
"https://www.apache.org/dyn/closer.cgi?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://github.com/apache/arrow/releases/download/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+  )
+endif()
+
+# ----------------------------------------------------------------------
+# FetchContent
+
+include(FetchContent)
+set(FC_DECLARE_COMMON_OPTIONS)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
+  list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE)
+endif()
+
+macro(prepare_fetchcontent)
+  set(BUILD_SHARED_LIBS OFF)
+  set(BUILD_STATIC_LIBS ON)
+  set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE)
+  set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endmacro()
+
+# ----------------------------------------------------------------------
+# Apache Arrow
+
+function(resolve_arrow_dependency)
+  prepare_fetchcontent()
+
+  set(ARROW_BUILD_SHARED
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_BUILD_STATIC
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_FILESYSTEM
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_RUNTIME_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_POSITION_INDEPENDENT_CODE
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_DEPENDENCY_SOURCE
+      "AUTO"
+      CACHE STRING "" FORCE)
+
+  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
+                       NAMES
+                       Arrow
+                       CONFIG)
+
+  # Add Arrow cmake modules to the search path
+  list(PREPEND CMAKE_MODULE_PATH
+       ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules)
+
+  fetchcontent_makeavailable(Arrow)
+
+  if(NOT TARGET Arrow::arrow_static)
+    add_library(Arrow::arrow_static INTERFACE IMPORTED)
+    target_link_libraries(Arrow::arrow_static INTERFACE arrow_static)
+    target_include_directories(Arrow::arrow_static INTERFACE 
${arrow_SOURCE_DIR}/cpp/src
+                                                             
${arrow_BINARY_DIR}/src)
+  endif()
+
+  fetchcontent_getproperties(Arrow)
+  if(arrow_SOURCE_DIR)
+    set(ARROW_VENDORED TRUE)
+    install(TARGETS arrow_static
+            RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"

Review Comment:
   ```suggestion
               RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
   ```



##########
example/CMakeLists.txt:
##########
@@ -22,10 +22,10 @@ project(example)
 
 set(CMAKE_CXX_STANDARD 20)
 
-find_package(iceberg CONFIG REQUIRED)
-find_package(puffin CONFIG REQUIRED)
+find_package(Iceberg CONFIG REQUIRED)
 
 add_executable(demo_example demo_example.cc)
 
-target_link_libraries(demo_example PRIVATE iceberg::iceberg_core_static
-                                           puffin::iceberg_puffin_static)
+target_link_libraries(demo_example
+                      PRIVATE Iceberg::iceberg_core_static 
Iceberg::iceberg_puffin_static
+                              Iceberg::iceberg_arrow_static)

Review Comment:
   Does `libiceberg_arrow.a` depend on `libiceberg_core.a` and 
`libiceberg_puffine.a` in the future?
   
   If so, `Iceberg::iceberg_arrow_static` should have 
`Iceberg::iceberg_puffine_static` and `Iceberg::iceberg_core_static` 
dependencies.



##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -0,0 +1,142 @@
+# 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.
+
+# Accumulate all dependencies to provide suitable static link parameters to the
+# third party libraries.
+set(ICEBERG_SYSTEM_DEPENDENCIES)
+set(ICEBERG_VENDOR_DEPENDENCIES)
+set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
+
+# ----------------------------------------------------------------------
+# Versions and URLs for toolchain builds
+
+set(ICEBERG_ARROW_BUILD_VERSION "18.1.0")
+set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
+    "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc")
+set(ARROW_VENDORED TRUE)
+
+if(DEFINED ENV{ICEBERG_ARROW_URL})
+  set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}")
+else()
+  set(ARROW_SOURCE_URL
+      
"https://www.apache.org/dyn/closer.cgi?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://github.com/apache/arrow/releases/download/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+  )
+endif()
+
+# ----------------------------------------------------------------------
+# FetchContent
+
+include(FetchContent)
+set(FC_DECLARE_COMMON_OPTIONS)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
+  list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE)
+endif()
+
+macro(prepare_fetchcontent)
+  set(BUILD_SHARED_LIBS OFF)
+  set(BUILD_STATIC_LIBS ON)
+  set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE)
+  set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endmacro()
+
+# ----------------------------------------------------------------------
+# Apache Arrow
+
+function(resolve_arrow_dependency)
+  prepare_fetchcontent()
+
+  set(ARROW_BUILD_SHARED
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_BUILD_STATIC
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_FILESYSTEM
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_RUNTIME_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_POSITION_INDEPENDENT_CODE
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_DEPENDENCY_SOURCE
+      "AUTO"
+      CACHE STRING "" FORCE)
+
+  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
+                       NAMES
+                       Arrow
+                       CONFIG)
+
+  # Add Arrow cmake modules to the search path
+  list(PREPEND CMAKE_MODULE_PATH
+       ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules)
+
+  fetchcontent_makeavailable(Arrow)
+
+  if(NOT TARGET Arrow::arrow_static)
+    add_library(Arrow::arrow_static INTERFACE IMPORTED)
+    target_link_libraries(Arrow::arrow_static INTERFACE arrow_static)
+    target_include_directories(Arrow::arrow_static INTERFACE 
${arrow_SOURCE_DIR}/cpp/src
+                                                             
${arrow_BINARY_DIR}/src)
+  endif()
+
+  fetchcontent_getproperties(Arrow)
+  if(arrow_SOURCE_DIR)
+    set(ARROW_VENDORED TRUE)
+    install(TARGETS arrow_static
+            RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+            ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
+            LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
+
+    get_target_property(ARROW_STATIC_LIB arrow_static OUTPUT_NAME)
+    set(ARROW_STATIC_LIB_NAME
+        
"${CMAKE_STATIC_LIBRARY_PREFIX}${ARROW_STATIC_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    list(APPEND ICEBERG_VENDOR_DEPENDENCIES
+         "Iceberg::arrow_vendored|${ARROW_STATIC_LIB_NAME}")

Review Comment:
   We may be able to simplify this by using `install(TARGETS arrow_static 
EXPORT iceberg_arrow_targets ...)`.



##########
cmake_modules/BuildUtils.cmake:
##########
@@ -210,9 +184,12 @@ function(ADD_ICEBERG_LIB LIB_NAME)
             DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
   endif()
 
-  if(ARG_CMAKE_PACKAGE_NAME)
-    iceberg_install_cmake_package(${ARG_CMAKE_PACKAGE_NAME} 
${LIB_NAME}_targets)
-  endif()
+  string(TOLOWER ${LIB_NAME} LIB_NAME_LOWER_CASE)
+  string(REPLACE "_" "-" LIB_NAME_DASH_SEPARATED_LOWER_CASE 
${LIB_NAME_LOWER_CASE})
+  install(EXPORT ${LIB_NAME}_targets

Review Comment:
   How about using the same export name (something like `iceberg_targets`) for 
all targets?
   If we use the same export name, we can use 
`include("${CMAKE_CURRENT_LIST_DIR}/iceberg-targets.cmake")` in 
`iceberg-config.cmake`.



##########
src/config.cmake.in:
##########
@@ -0,0 +1,123 @@
+# 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.
+#
+# This config sets the following variables in your project::
+#
+#   Iceberg_FOUND - true if Iceberg found on the system
+#   Iceberg_VERSION - version of the found Iceberg
+#
+# This config sets the following targets (if built) in your project::
+#
+#   Iceberg::iceberg_core_shared
+#   Iceberg::iceberg_core_static
+#   Iceberg::iceberg_puffin_shared
+#   Iceberg::iceberg_puffin_static
+#   Iceberg::iceberg_arrow_shared
+#   Iceberg::iceberg_arrow_static
+
+@PACKAGE_INIT@
+
+set(ICEBERG_BUILD_STATIC "@ICEBERG_BUILD_STATIC@")
+set(ICEBERG_VENDOR_DEPENDENCIES "@ICEBERG_VENDOR_DEPENDENCIES@")
+set(ICEBERG_SYSTEM_DEPENDENCIES "@ICEBERG_SYSTEM_DEPENDENCIES@")
+
+include(CMakeFindDependencyMacro)
+
+macro(iceberg_find_dependencies dependencies)
+  if(DEFINED CMAKE_MODULE_PATH)
+    set(ICEBERG_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH})
+  else()
+    unset(ICEBERG_CMAKE_MODULE_PATH_OLD)
+  endif()
+  set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+
+  foreach(dependency ${dependencies})
+    find_dependency(${dependency})
+  endforeach()
+
+  if(DEFINED ICEBERG_CMAKE_MODULE_PATH_OLD)
+    set(CMAKE_MODULE_PATH ${ICEBERG_CMAKE_MODULE_PATH_OLD})
+    unset(ICEBERG_CMAKE_MODULE_PATH_OLD)
+  else()
+    unset(CMAKE_MODULE_PATH)
+  endif()
+endmacro()
+
+macro(iceberg_find_components components)
+  file(GLOB_RECURSE _target_cmake_files 
"${CMAKE_CURRENT_LIST_DIR}/*-targets.cmake")
+  foreach(_target_cmake_file ${_target_cmake_files})
+    include(${_target_cmake_file})
+  endforeach()
+
+  foreach(comp ${components})
+    string(TOLOWER "${comp}" _comp_lower_case)
+    if(EXISTS 
"${CMAKE_CURRENT_LIST_DIR}/iceberg-${_comp_lower_case}-targets.cmake")

Review Comment:
   How about using `TARGET` instead?
   
   ```suggestion
       if(TARGET "Iceberg::iceberg_${_comp_lower_case}_shared" OR TARGET 
"Iceberg::iceberg_${_comp_lower_case}_static")
   ```



##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -0,0 +1,142 @@
+# 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.
+
+# Accumulate all dependencies to provide suitable static link parameters to the
+# third party libraries.
+set(ICEBERG_SYSTEM_DEPENDENCIES)
+set(ICEBERG_VENDOR_DEPENDENCIES)
+set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
+
+# ----------------------------------------------------------------------
+# Versions and URLs for toolchain builds
+
+set(ICEBERG_ARROW_BUILD_VERSION "18.1.0")
+set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
+    "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc")
+set(ARROW_VENDORED TRUE)
+
+if(DEFINED ENV{ICEBERG_ARROW_URL})
+  set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}")
+else()
+  set(ARROW_SOURCE_URL
+      
"https://www.apache.org/dyn/closer.cgi?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+      
"https://github.com/apache/arrow/releases/download/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz";
+  )
+endif()
+
+# ----------------------------------------------------------------------
+# FetchContent
+
+include(FetchContent)
+set(FC_DECLARE_COMMON_OPTIONS)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
+  list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE)
+endif()
+
+macro(prepare_fetchcontent)
+  set(BUILD_SHARED_LIBS OFF)
+  set(BUILD_STATIC_LIBS ON)
+  set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE)
+  set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endmacro()
+
+# ----------------------------------------------------------------------
+# Apache Arrow
+
+function(resolve_arrow_dependency)
+  prepare_fetchcontent()
+
+  set(ARROW_BUILD_SHARED
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_BUILD_STATIC
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_FILESYSTEM
+      OFF
+      CACHE BOOL "" FORCE)
+  set(ARROW_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_RUNTIME_SIMD_LEVEL
+      "NONE"
+      CACHE STRING "" FORCE)
+  set(ARROW_POSITION_INDEPENDENT_CODE
+      ON
+      CACHE BOOL "" FORCE)
+  set(ARROW_DEPENDENCY_SOURCE
+      "AUTO"
+      CACHE STRING "" FORCE)
+
+  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
+                       NAMES
+                       Arrow
+                       CONFIG)
+
+  # Add Arrow cmake modules to the search path
+  list(PREPEND CMAKE_MODULE_PATH
+       ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules)
+
+  fetchcontent_makeavailable(Arrow)
+
+  if(NOT TARGET Arrow::arrow_static)
+    add_library(Arrow::arrow_static INTERFACE IMPORTED)
+    target_link_libraries(Arrow::arrow_static INTERFACE arrow_static)
+    target_include_directories(Arrow::arrow_static INTERFACE 
${arrow_SOURCE_DIR}/cpp/src
+                                                             
${arrow_BINARY_DIR}/src)
+  endif()
+
+  fetchcontent_getproperties(Arrow)
+  if(arrow_SOURCE_DIR)
+    set(ARROW_VENDORED TRUE)
+    install(TARGETS arrow_static
+            RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+            ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
+            LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")

Review Comment:
   Can we rename `libarrow.a` to `libiceberg_vendored_arrow.a` or something so 
that we can avoid file name conflict?
   
   ```cmake
   set_target_properties(arrow_static PROPERTIES OUTPUT_NAME 
"iceberg_vendored_arrow")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to