@@ -239,17 +239,41 @@ function(resolve_nanoarrow_dependency)
239239 fetchcontent_declare(nanoarrow
240240 ${FC_DECLARE_COMMON_OPTIONS}
241241 URL "https://dlcdn.apache.org/arrow/apache-arrow-nanoarrow-0.7.0/apache-arrow-nanoarrow-0.7.0.tar.gz"
242- )
242+ FIND_PACKAGE_ARGS
243+ NAMES
244+ nanoarrow
245+ CONFIG)
243246 fetchcontent_makeavailable(nanoarrow)
244247
245- set_target_properties (nanoarrow_static
246- PROPERTIES OUTPUT_NAME "iceberg_vendored_nanoarrow"
247- POSITION_INDEPENDENT_CODE ON )
248- install (TARGETS nanoarrow_static
249- EXPORT iceberg_targets
250- RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR} "
251- ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR} "
252- LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR} " )
248+ if (nanoarrow_SOURCE_DIR)
249+ if (NOT TARGET nanoarrow::nanoarrow_static)
250+ add_library (nanoarrow::nanoarrow_static INTERFACE IMPORTED )
251+ target_link_libraries (nanoarrow::nanoarrow_static INTERFACE nanoarrow_static)
252+ target_include_directories (nanoarrow::nanoarrow_static
253+ INTERFACE ${nanoarrow_BINARY_DIR}
254+ ${nanoarrow_SOURCE_DIR} )
255+ endif ()
256+
257+ set (NANOARROW_VENDORED TRUE )
258+ set_target_properties (nanoarrow_static
259+ PROPERTIES OUTPUT_NAME "iceberg_vendored_nanoarrow"
260+ POSITION_INDEPENDENT_CODE ON )
261+ install (TARGETS nanoarrow_static
262+ EXPORT iceberg_targets
263+ RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR} "
264+ ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR} "
265+ LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR} " )
266+ else ()
267+ set (NANOARROW_VENDORED FALSE )
268+ list (APPEND ICEBERG_SYSTEM_DEPENDENCIES nanoarrow)
269+ endif ()
270+
271+ set (ICEBERG_SYSTEM_DEPENDENCIES
272+ ${ICEBERG_SYSTEM_DEPENDENCIES}
273+ PARENT_SCOPE)
274+ set (NANOARROW_VENDORED
275+ ${NANOARROW_VENDORED}
276+ PARENT_SCOPE)
253277endfunction ()
254278
255279# ----------------------------------------------------------------------
@@ -265,22 +289,46 @@ function(resolve_nlohmann_json_dependency)
265289 fetchcontent_declare(nlohmann_json
266290 ${FC_DECLARE_COMMON_OPTIONS}
267291 URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
268- )
292+ FIND_PACKAGE_ARGS
293+ NAMES
294+ nlohmann_json
295+ CONFIG)
269296 fetchcontent_makeavailable(nlohmann_json)
270297
271- set_target_properties (nlohmann_json
272- PROPERTIES OUTPUT_NAME "iceberg_vendored_nlohmann_json"
273- POSITION_INDEPENDENT_CODE ON )
274- if (MSVC_TOOLCHAIN)
275- set (NLOHMANN_NATVIS_FILE ${nlohmann_json_SOURCE_DIR} /nlohmann_json.natvis)
276- install (FILES ${NLOHMANN_NATVIS_FILE} DESTINATION .)
298+ if (nlohmann_json_SOURCE_DIR)
299+ if (NOT TARGET nlohmann_json::nlohmann_json)
300+ add_library (nlohmann_json::nlohmann_json INTERFACE IMPORTED )
301+ target_link_libraries (nlohmann_json::nlohmann_json INTERFACE nlohmann_json)
302+ target_include_directories (nlohmann_json::nlohmann_json
303+ INTERFACE ${nlohmann_json_BINARY_DIR}
304+ ${nlohmann_json_SOURCE_DIR} )
305+ endif ()
306+
307+ set (NLOHMANN_JSON_VENDORED TRUE )
308+ set_target_properties (nlohmann_json
309+ PROPERTIES OUTPUT_NAME "iceberg_vendored_nlohmann_json"
310+ POSITION_INDEPENDENT_CODE ON )
311+ if (MSVC_TOOLCHAIN)
312+ set (NLOHMANN_NATVIS_FILE ${nlohmann_json_SOURCE_DIR} /nlohmann_json.natvis)
313+ install (FILES ${NLOHMANN_NATVIS_FILE} DESTINATION .)
314+ endif ()
315+
316+ install (TARGETS nlohmann_json
317+ EXPORT iceberg_targets
318+ RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR} "
319+ ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR} "
320+ LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR} " )
321+ else ()
322+ set (NLOHMANN_JSON_VENDORED FALSE )
323+ list (APPEND ICEBERG_SYSTEM_DEPENDENCIES nlohmann_json)
277324 endif ()
278325
279- install (TARGETS nlohmann_json
280- EXPORT iceberg_targets
281- RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR} "
282- ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR} "
283- LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR} " )
326+ set (ICEBERG_SYSTEM_DEPENDENCIES
327+ ${ICEBERG_SYSTEM_DEPENDENCIES}
328+ PARENT_SCOPE)
329+ set (NLOHMANN_JSON_VENDORED
330+ ${NLOHMANN_JSON_VENDORED}
331+ PARENT_SCOPE)
284332endfunction ()
285333
286334# ----------------------------------------------------------------------
0 commit comments