Skip to content

Commit 394725a

Browse files
committed
feat: add spdlog dependency to implement logging
1 parent c00ee8f commit 394725a

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,55 @@ function(resolve_nlohmann_json_dependency)
282282
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
283283
endfunction()
284284

285+
# ----------------------------------------------------------------------
286+
# spdlog
287+
288+
function(resolve_spdlog_dependency)
289+
prepare_fetchcontent()
290+
291+
find_package(Threads REQUIRED)
292+
293+
set(SPDLOG_USE_STD_FORMAT
294+
ON
295+
CACHE BOOL "" FORCE)
296+
set(SPDLOG_BUILD_PIC
297+
ON
298+
CACHE BOOL "" FORCE)
299+
300+
fetchcontent_declare(spdlog
301+
${FC_DECLARE_COMMON_OPTIONS}
302+
URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz"
303+
FIND_PACKAGE_ARGS
304+
NAMES
305+
spdlog
306+
CONFIG)
307+
fetchcontent_makeavailable(spdlog)
308+
309+
if(spdlog_SOURCE_DIR)
310+
set_target_properties(spdlog PROPERTIES OUTPUT_NAME "iceberg_vendored_spdlog"
311+
POSITION_INDEPENDENT_CODE ON)
312+
target_link_libraries(spdlog INTERFACE Threads::Threads)
313+
install(TARGETS spdlog
314+
EXPORT iceberg_targets
315+
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
316+
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
317+
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
318+
set(SPDLOG_VENDORED TRUE)
319+
else()
320+
set(SPDLOG_VENDORED FALSE)
321+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES spdlog)
322+
endif()
323+
324+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Threads)
325+
326+
set(ICEBERG_SYSTEM_DEPENDENCIES
327+
${ICEBERG_SYSTEM_DEPENDENCIES}
328+
PARENT_SCOPE)
329+
set(SPDLOG_VENDORED
330+
${SPDLOG_VENDORED}
331+
PARENT_SCOPE)
332+
endfunction()
333+
285334
# ----------------------------------------------------------------------
286335
# zlib
287336

@@ -302,6 +351,7 @@ endfunction()
302351
resolve_zlib_dependency()
303352
resolve_nanoarrow_dependency()
304353
resolve_nlohmann_json_dependency()
354+
resolve_spdlog_dependency()
305355

306356
if(ICEBERG_BUILD_BUNDLE)
307357
resolve_arrow_dependency()

src/iceberg/CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,24 @@ list(APPEND
5858
ICEBERG_STATIC_BUILD_INTERFACE_LIBS
5959
nanoarrow::nanoarrow
6060
nlohmann_json::nlohmann_json
61+
spdlog::spdlog
6162
ZLIB::ZLIB)
6263
list(APPEND
6364
ICEBERG_SHARED_BUILD_INTERFACE_LIBS
6465
nanoarrow::nanoarrow
6566
nlohmann_json::nlohmann_json
67+
spdlog::spdlog
6668
ZLIB::ZLIB)
67-
list(APPEND ICEBERG_STATIC_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow"
68-
"Iceberg::nlohmann_json")
69-
list(APPEND ICEBERG_SHARED_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow"
70-
"Iceberg::nlohmann_json")
69+
list(APPEND
70+
ICEBERG_STATIC_INSTALL_INTERFACE_LIBS
71+
"Iceberg::nanoarrow"
72+
"Iceberg::nlohmann_json"
73+
"$<IF:$<BOOL:${SPDLOG_VENDORED}>,Iceberg::spdlog,spdlog::spdlog>")
74+
list(APPEND
75+
ICEBERG_SHARED_INSTALL_INTERFACE_LIBS
76+
"Iceberg::nanoarrow"
77+
"Iceberg::nlohmann_json"
78+
"$<IF:$<BOOL:${SPDLOG_VENDORED}>,Iceberg::spdlog,spdlog::spdlog>")
7179

7280
add_iceberg_lib(iceberg
7381
SOURCES

0 commit comments

Comments
 (0)