Skip to content

Commit d3b02bb

Browse files
Revert "chore: remove spdlog dependency (#459)" (#718)
## What Re-adds spdlog (v1.15.3, configured with SPDLOG_USE_STD_FORMAT) as a build dependency, reverting #459. ## Why #459 removed spdlog because nothing used it at the time, with the note that it could be added back "when it is actually needed." It is now needed: this is the foundation for the upcoming logging system for iceberg-cpp. Restoring the dependency wiring in its own change keeps that follow-up focused purely on the logger itself.
1 parent 577c8e4 commit d3b02bb

5 files changed

Lines changed: 94 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ If you experience network issues when downloading dependencies, you can customiz
152152
- `ICEBERG_NANOARROW_URL`: Nanoarrow tarball URL
153153
- `ICEBERG_CROARING_URL`: CRoaring tarball URL
154154
- `ICEBERG_NLOHMANN_JSON_URL`: nlohmann-json tarball URL
155+
- `ICEBERG_SPDLOG_URL`: spdlog tarball URL
155156
- `ICEBERG_CPR_URL`: cpr tarball URL
156157

157158
Example:

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ endfunction()
7373
# ICEBERG_NANOARROW_URL - Nanoarrow tarball URL
7474
# ICEBERG_CROARING_URL - CRoaring tarball URL
7575
# ICEBERG_NLOHMANN_JSON_URL - nlohmann-json tarball URL
76+
# ICEBERG_SPDLOG_URL - spdlog tarball URL
7677
# ICEBERG_CPR_URL - cpr tarball URL
7778
#
7879
# Example usage:
@@ -482,6 +483,61 @@ function(resolve_nlohmann_json_dependency)
482483
PARENT_SCOPE)
483484
endfunction()
484485

486+
# ----------------------------------------------------------------------
487+
# spdlog
488+
489+
function(resolve_spdlog_dependency)
490+
prepare_fetchcontent()
491+
492+
find_package(Threads REQUIRED)
493+
494+
set(SPDLOG_USE_STD_FORMAT
495+
ON
496+
CACHE BOOL "" FORCE)
497+
set(SPDLOG_BUILD_PIC
498+
ON
499+
CACHE BOOL "" FORCE)
500+
501+
if(DEFINED ENV{ICEBERG_SPDLOG_URL})
502+
set(SPDLOG_URL "$ENV{ICEBERG_SPDLOG_URL}")
503+
else()
504+
set(SPDLOG_URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz")
505+
endif()
506+
507+
fetchcontent_declare(spdlog
508+
${FC_DECLARE_COMMON_OPTIONS}
509+
URL ${SPDLOG_URL}
510+
FIND_PACKAGE_ARGS
511+
NAMES
512+
spdlog
513+
CONFIG)
514+
fetchcontent_makeavailable(spdlog)
515+
516+
if(spdlog_SOURCE_DIR)
517+
set_target_properties(spdlog PROPERTIES OUTPUT_NAME "iceberg_vendored_spdlog"
518+
POSITION_INDEPENDENT_CODE ON)
519+
target_link_libraries(spdlog INTERFACE Threads::Threads)
520+
install(TARGETS spdlog
521+
EXPORT iceberg_targets
522+
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
523+
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
524+
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
525+
set(SPDLOG_VENDORED TRUE)
526+
else()
527+
set(SPDLOG_VENDORED FALSE)
528+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES spdlog)
529+
endif()
530+
531+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Threads)
532+
533+
set(ICEBERG_SYSTEM_DEPENDENCIES
534+
${ICEBERG_SYSTEM_DEPENDENCIES}
535+
PARENT_SCOPE)
536+
set(SPDLOG_VENDORED
537+
${SPDLOG_VENDORED}
538+
PARENT_SCOPE)
539+
endfunction()
540+
485541
# ----------------------------------------------------------------------
486542
# zlib
487543

@@ -664,6 +720,7 @@ resolve_zlib_dependency()
664720
resolve_nanoarrow_dependency()
665721
resolve_croaring_dependency()
666722
resolve_nlohmann_json_dependency()
723+
resolve_spdlog_dependency()
667724

668725
if(ICEBERG_S3 OR ICEBERG_SIGV4)
669726
if(ICEBERG_SIGV4 AND NOT ICEBERG_BUILD_REST)

src/iceberg/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,24 @@ list(APPEND
139139
ICEBERG_STATIC_BUILD_INTERFACE_LIBS
140140
"$<IF:$<BOOL:${NANOARROW_VENDORED}>,nanoarrow::nanoarrow_static,$<IF:$<TARGET_EXISTS:nanoarrow::nanoarrow_static>,nanoarrow::nanoarrow_static,nanoarrow::nanoarrow_shared>>"
141141
nlohmann_json::nlohmann_json
142+
spdlog::spdlog
142143
ZLIB::ZLIB)
143144
list(APPEND
144145
ICEBERG_SHARED_BUILD_INTERFACE_LIBS
145146
"$<IF:$<BOOL:${NANOARROW_VENDORED}>,nanoarrow::nanoarrow_static,$<IF:$<TARGET_EXISTS:nanoarrow::nanoarrow_shared>,nanoarrow::nanoarrow_shared,nanoarrow::nanoarrow_static>>"
146147
nlohmann_json::nlohmann_json
148+
spdlog::spdlog
147149
ZLIB::ZLIB)
148150
list(APPEND
149151
ICEBERG_STATIC_INSTALL_INTERFACE_LIBS
150152
"$<IF:$<BOOL:${NANOARROW_VENDORED}>,iceberg::nanoarrow_static,$<IF:$<TARGET_EXISTS:nanoarrow::nanoarrow_static>,nanoarrow::nanoarrow_static,nanoarrow::nanoarrow_shared>>"
151153
"$<IF:$<BOOL:${NLOHMANN_JSON_VENDORED}>,iceberg::nlohmann_json,$<IF:$<TARGET_EXISTS:nlohmann_json::nlohmann_json>,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>"
152-
)
154+
"$<IF:$<BOOL:${SPDLOG_VENDORED}>,iceberg::spdlog,spdlog::spdlog>")
153155
list(APPEND
154156
ICEBERG_SHARED_INSTALL_INTERFACE_LIBS
155157
"$<IF:$<BOOL:${NANOARROW_VENDORED}>,iceberg::nanoarrow_static,$<IF:$<TARGET_EXISTS:nanoarrow::nanoarrow_shared>,nanoarrow::nanoarrow_shared,nanoarrow::nanoarrow_static>>"
156158
"$<IF:$<BOOL:${NLOHMANN_JSON_VENDORED}>,iceberg::nlohmann_json,$<IF:$<TARGET_EXISTS:nlohmann_json::nlohmann_json>,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>"
157-
)
159+
"$<IF:$<BOOL:${SPDLOG_VENDORED}>,iceberg::spdlog,spdlog::spdlog>")
158160

159161
add_iceberg_lib(iceberg
160162
SOURCES

src/iceberg/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ croaring_needs_static = (
180180
croaring_dep = dependency('croaring', static: croaring_needs_static)
181181
nanoarrow_dep = dependency('nanoarrow')
182182
nlohmann_json_dep = dependency('nlohmann_json')
183+
spdlog_dep = dependency('spdlog')
183184
zlib_dep = dependency('zlib')
184185

185-
iceberg_deps = [nanoarrow_dep, nlohmann_json_dep, zlib_dep]
186+
iceberg_deps = [nanoarrow_dep, nlohmann_json_dep, spdlog_dep, zlib_dep]
186187

187188
iceberg_lib = library(
188189
'iceberg',

subprojects/spdlog.wrap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[wrap-file]
19+
directory = spdlog-1.15.3
20+
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz
21+
source_filename = spdlog-1.15.3.tar.gz
22+
source_hash = 15a04e69c222eb6c01094b5c7ff8a249b36bb22788d72519646fb85feb267e67
23+
patch_filename = spdlog_1.15.3-4_patch.zip
24+
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.15.3-4/get_patch
25+
patch_hash = ccdc72f3d965980d5edd1a56129a9b7fa5f7c86f31e4ecf2dba6a6068829d4e2
26+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.15.3-4/spdlog-1.15.3.tar.gz
27+
wrapdb_version = 1.15.3-4
28+
29+
[provide]
30+
spdlog = spdlog_dep

0 commit comments

Comments
 (0)