Skip to content

Commit 111201c

Browse files
authored
fix(cmake): don't vendor nlohmann_json when USE_SYSTEM_DEPS is on. (#324)
* Add patch to not vendor nlohmann_json when USE_SYSTEM_DEPS is on. * fix(cmake): export nlohmann_json dependency
1 parent 72a601e commit 111201c

5 files changed

Lines changed: 29 additions & 6 deletions

File tree

cmake/icey_build_config.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ if(_icey_have_libdatachannel AND DEFINED icey_FIND_COMPONENTS AND "webrtc" IN_LI
4444
endif()
4545

4646
if(@USE_SYSTEM_DEPS@)
47+
if("json" IN_LIST _icey_supported_components)
48+
find_dependency(nlohmann_json CONFIG)
49+
endif()
4750
find_package(libuv CONFIG QUIET)
4851
if(NOT TARGET libuv::uv_a AND NOT TARGET libuv::uv AND NOT TARGET libuv::libuv AND PkgConfig_FOUND)
4952
pkg_check_modules(LIBUV QUIET IMPORTED_TARGET GLOBAL libuv)

cmake/icey_config.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ if(NOT TARGET llhttp_static)
5959
endif()
6060

6161
if(@USE_SYSTEM_DEPS@)
62+
if("json" IN_LIST _icey_supported_components)
63+
find_dependency(nlohmann_json CONFIG)
64+
endif()
6265
find_dependency(ZLIB)
6366
if("archo" IN_LIST _icey_supported_components OR "pacm" IN_LIST _icey_supported_components)
6467
find_dependency(unofficial-minizip CONFIG QUIET)

icey.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ else()
210210
pkg_check_modules(LIBUV QUIET IMPORTED_TARGET GLOBAL libuv)
211211
endif()
212212
find_package(llhttp CONFIG QUIET)
213+
if(BUILD_MODULES AND (NOT DEFINED BUILD_MODULE_json OR BUILD_MODULE_json))
214+
find_package(nlohmann_json CONFIG REQUIRED)
215+
endif()
213216
find_package(ZLIB REQUIRED)
214217
if(NOT TARGET llhttp_static
215218
AND NOT TARGET llhttp::llhttp_static

src/json/CMakeLists.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
icy_add_module(json
2-
DEPENDS base
3-
PRETTY_NAME JSON
4-
)
5-
# nlohmann/json.hpp is vendored in include/nlohmann/ (MIT licensed, single-header)
6-
# so no external dependency is needed - icy_add_module already adds our include dir.
1+
if(USE_SYSTEM_DEPS)
2+
icy_add_module(json
3+
DEPENDS base
4+
PACKAGES nlohmann_json::nlohmann_json
5+
PRETTY_NAME JSON
6+
)
7+
else()
8+
icy_add_module(json
9+
DEPENDS base
10+
PRETTY_NAME JSON
11+
)
12+
target_include_directories(json
13+
PUBLIC
14+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor>
15+
)
16+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vendor/"
17+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
18+
COMPONENT dev
19+
)
20+
endif()

0 commit comments

Comments
 (0)