Skip to content

Commit 264e1cf

Browse files
committed
feat: add nlohmann/json library
1 parent d05a9b2 commit 264e1cf

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,31 @@ function(resolve_nanoarrow_dependency)
226226
endfunction()
227227

228228
resolve_nanoarrow_dependency()
229+
230+
# ----------------------------------------------------------------------
231+
# nlohmann-json
232+
233+
function(resolve_nlohmann_json_dependency)
234+
prepare_fetchcontent()
235+
236+
set(JSON_BuildTests
237+
OFF
238+
CACHE BOOL "" FORCE)
239+
240+
fetchcontent_declare(nlohmann_json
241+
${FC_DECLARE_COMMON_OPTIONS}
242+
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
243+
)
244+
fetchcontent_makeavailable(nlohmann_json)
245+
246+
set_target_properties(nlohmann_json
247+
PROPERTIES OUTPUT_NAME "iceberg_vendored_nlohmann_json"
248+
POSITION_INDEPENDENT_CODE ON)
249+
install(TARGETS nlohmann_json
250+
EXPORT iceberg_targets
251+
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
252+
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
253+
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
254+
endfunction()
255+
256+
resolve_nlohmann_json_dependency()

src/iceberg/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ set(ICEBERG_SHARED_BUILD_INTERFACE_LIBS)
3333
set(ICEBERG_STATIC_INSTALL_INTERFACE_LIBS)
3434
set(ICEBERG_SHARED_INSTALL_INTERFACE_LIBS)
3535

36-
list(APPEND ICEBERG_STATIC_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow)
37-
list(APPEND ICEBERG_SHARED_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow)
38-
list(APPEND ICEBERG_STATIC_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow")
39-
list(APPEND ICEBERG_SHARED_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow")
36+
list(APPEND ICEBERG_STATIC_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow nlohmann_json::nlohmann_json)
37+
list(APPEND ICEBERG_SHARED_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow nlohmann_json::nlohmann_json)
38+
list(APPEND ICEBERG_STATIC_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow" "Iceberg::nlohmann_json")
39+
list(APPEND ICEBERG_SHARED_INSTALL_INTERFACE_LIBS "Iceberg::nanoarrow" "Iceberg::nlohmann_json")
4040

4141
add_iceberg_lib(iceberg
4242
SOURCES

src/iceberg/arrow_c_data_internal.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <string>
2424
#include <utility>
2525

26+
#include <nlohmann/json.hpp>
27+
2628
namespace iceberg::internal {
2729

2830
std::pair<ArrowSchema, ArrowArray> CreateExampleArrowSchemaAndArrayByNanoarrow() {
@@ -73,4 +75,11 @@ std::pair<ArrowSchema, ArrowArray> CreateExampleArrowSchemaAndArrayByNanoarrow()
7375
return {out_schema, out_array};
7476
}
7577

78+
void TestNlohmannJsonCompile() {
79+
nlohmann::json j;
80+
j["name"] = "foo";
81+
j["age"] = 30;
82+
j["city"] = "New York";
83+
}
84+
7685
} // namespace iceberg::internal

0 commit comments

Comments
 (0)