Skip to content

Commit b7cc87d

Browse files
author
nullccxsy
committed
chore: update CI workflow and enhance dependency management
- Updated the dependencies installation command to include `nlohmann-json` and `nanoarrow`. - Refactored the `IcebergThirdpartyToolchain.cmake` to improve handling of `nanoarrow` and `nlohmann_json` dependencies, allowing for better integration and installation based on their availability.
1 parent 88f5520 commit b7cc87d

File tree

2 files changed

+71
-23
lines changed

2 files changed

+71
-23
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ jobs:
8080
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
8181
with:
8282
fetch-depth: 0
83-
- name: Install ZLIB
83+
- name: Install dependencies
8484
shell: cmd
8585
run: |
86-
vcpkg install zlib:x64-windows
86+
vcpkg install zlib:x64-windows nlohmann-json:x64-windows nanoarrow:x64-windows
8787
- name: Build Iceberg
8888
shell: cmd
8989
run: |

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,41 @@ function(resolve_nanoarrow_dependency)
238238
fetchcontent_declare(nanoarrow
239239
${FC_DECLARE_COMMON_OPTIONS}
240240
URL "https://dlcdn.apache.org/arrow/apache-arrow-nanoarrow-0.7.0/apache-arrow-nanoarrow-0.7.0.tar.gz"
241-
)
241+
FIND_PACKAGE_ARGS
242+
NAMES
243+
nanoarrow
244+
CONFIG)
242245
fetchcontent_makeavailable(nanoarrow)
243246

244-
set_target_properties(nanoarrow_static
245-
PROPERTIES OUTPUT_NAME "iceberg_vendored_nanoarrow"
246-
POSITION_INDEPENDENT_CODE ON)
247-
install(TARGETS nanoarrow_static
248-
EXPORT iceberg_targets
249-
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
250-
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
251-
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
247+
if(nanoarrow_SOURCE_DIR)
248+
if(NOT TARGET nanoarrow::nanoarrow_static)
249+
add_library(nanoarrow::nanoarrow_static INTERFACE IMPORTED)
250+
target_link_libraries(nanoarrow::nanoarrow_static INTERFACE nanoarrow_static)
251+
target_include_directories(nanoarrow::nanoarrow_static
252+
INTERFACE ${nanoarrow_BINARY_DIR}
253+
${nanoarrow_SOURCE_DIR})
254+
endif()
255+
256+
set(NANOARROW_VENDORED TRUE)
257+
set_target_properties(nanoarrow_static
258+
PROPERTIES OUTPUT_NAME "iceberg_vendored_nanoarrow"
259+
POSITION_INDEPENDENT_CODE ON)
260+
install(TARGETS nanoarrow_static
261+
EXPORT iceberg_targets
262+
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
263+
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
264+
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
265+
else()
266+
set(NANOARROW_VENDORED FALSE)
267+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES nanoarrow)
268+
endif()
269+
270+
set(ICEBERG_SYSTEM_DEPENDENCIES
271+
${ICEBERG_SYSTEM_DEPENDENCIES}
272+
PARENT_SCOPE)
273+
set(NANOARROW_VENDORED
274+
${NANOARROW_VENDORED}
275+
PARENT_SCOPE)
252276
endfunction()
253277

254278
# ----------------------------------------------------------------------
@@ -264,22 +288,46 @@ function(resolve_nlohmann_json_dependency)
264288
fetchcontent_declare(nlohmann_json
265289
${FC_DECLARE_COMMON_OPTIONS}
266290
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
267-
)
291+
FIND_PACKAGE_ARGS
292+
NAMES
293+
nlohmann_json
294+
CONFIG)
268295
fetchcontent_makeavailable(nlohmann_json)
269296

270-
set_target_properties(nlohmann_json
271-
PROPERTIES OUTPUT_NAME "iceberg_vendored_nlohmann_json"
272-
POSITION_INDEPENDENT_CODE ON)
273-
if(MSVC_TOOLCHAIN)
274-
set(NLOHMANN_NATVIS_FILE ${nlohmann_json_SOURCE_DIR}/nlohmann_json.natvis)
275-
install(FILES ${NLOHMANN_NATVIS_FILE} DESTINATION .)
297+
if(nlohmann_json_SOURCE_DIR)
298+
if(NOT TARGET nlohmann_json::nlohmann_json)
299+
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
300+
target_link_libraries(nlohmann_json::nlohmann_json INTERFACE nlohmann_json)
301+
target_include_directories(nlohmann_json::nlohmann_json
302+
INTERFACE ${nlohmann_json_BINARY_DIR}
303+
${nlohmann_json_SOURCE_DIR})
304+
endif()
305+
306+
set(NLOHMANN_JSON_VENDORED TRUE)
307+
set_target_properties(nlohmann_json
308+
PROPERTIES OUTPUT_NAME "iceberg_vendored_nlohmann_json"
309+
POSITION_INDEPENDENT_CODE ON)
310+
if(MSVC_TOOLCHAIN)
311+
set(NLOHMANN_NATVIS_FILE ${nlohmann_json_SOURCE_DIR}/nlohmann_json.natvis)
312+
install(FILES ${NLOHMANN_NATVIS_FILE} DESTINATION .)
313+
endif()
314+
315+
install(TARGETS nlohmann_json
316+
EXPORT iceberg_targets
317+
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
318+
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
319+
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
320+
else()
321+
set(NLOHMANN_JSON_VENDORED FALSE)
322+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES nlohmann_json)
276323
endif()
277324

278-
install(TARGETS nlohmann_json
279-
EXPORT iceberg_targets
280-
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
281-
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
282-
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
325+
set(ICEBERG_SYSTEM_DEPENDENCIES
326+
${ICEBERG_SYSTEM_DEPENDENCIES}
327+
PARENT_SCOPE)
328+
set(NLOHMANN_JSON_VENDORED
329+
${NLOHMANN_JSON_VENDORED}
330+
PARENT_SCOPE)
283331
endfunction()
284332

285333
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)