Skip to content

Commit be514fc

Browse files
authored
feat: add spdlog dependency to implement logging (#140)
Added `spdlog` as a third-party dependency to implement logger support. My plan is to add a logger interface so we don't expose `spdlog` symbols externally (just like what we did with `nanoarrow` and `nlohman-json`).
1 parent 0a807ca commit be514fc

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

@@ -316,6 +365,7 @@ endfunction()
316365
resolve_zlib_dependency()
317366
resolve_nanoarrow_dependency()
318367
resolve_nlohmann_json_dependency()
368+
resolve_spdlog_dependency()
319369

320370
if(ICEBERG_BUILD_BUNDLE)
321371
resolve_arrow_dependency()

src/iceberg/CMakeLists.txt

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

7179
add_iceberg_lib(iceberg
7280
SOURCES

0 commit comments

Comments
 (0)