Skip to content

Commit 00c251e

Browse files
committed
sync: add explicit json dependency and fail fast if missing
1 parent 12325b3 commit 00c251e

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,37 @@ if (NOT TARGET ${VIX_NET_TARGET} AND TARGET vix::net)
9292
set(VIX_NET_TARGET vix::net)
9393
endif()
9494

95+
# JSON dependency (needed by FileOutboxStore.cpp via <vix/json/...>)
96+
option(VIX_SYNC_FETCH_JSON "Auto-fetch vix::json if missing" ON)
97+
98+
if (NOT TARGET vix::json AND NOT TARGET vix_json)
99+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/../json/CMakeLists.txt")
100+
message(STATUS "[sync] Adding json from umbrella: ../json")
101+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../json" "json")
102+
elseif (VIX_SYNC_FETCH_JSON)
103+
include(FetchContent)
104+
message(STATUS "[sync] Fetching vix::json via FetchContent")
105+
FetchContent_Declare(vix_json_mod
106+
GIT_REPOSITORY https://github.com/vixcpp/json.git
107+
GIT_TAG dev
108+
)
109+
FetchContent_MakeAvailable(vix_json_mod)
110+
else()
111+
message(FATAL_ERROR "vix::json not found. Enable VIX_SYNC_FETCH_JSON=ON or provide the target before sync.")
112+
endif()
113+
endif()
114+
115+
set(VIX_JSON_TARGET "")
116+
if (TARGET vix::json)
117+
set(VIX_JSON_TARGET vix::json)
118+
elseif (TARGET vix_json)
119+
set(VIX_JSON_TARGET vix_json)
120+
endif()
121+
122+
if (VIX_JSON_TARGET STREQUAL "")
123+
message(FATAL_ERROR "[sync] JSON backend not found (expected vix::json or vix_json)")
124+
endif()
125+
95126
# STATIC
96127
if (SYNC_SOURCES)
97128
message(STATUS "[sync] Building STATIC library with detected sources.")
@@ -122,6 +153,7 @@ if (SYNC_SOURCES)
122153
PUBLIC
123154
${VIX_UTILS_TARGET}
124155
${VIX_NET_TARGET}
156+
${VIX_JSON_TARGET}
125157
)
126158

127159
set_target_properties(vix_sync PROPERTIES
@@ -157,8 +189,10 @@ else()
157189
target_link_libraries(vix_sync INTERFACE
158190
${VIX_UTILS_TARGET}
159191
${VIX_NET_TARGET}
192+
${VIX_JSON_TARGET}
160193
)
161194

195+
162196
if (VIX_ENABLE_SANITIZERS AND TARGET vix_sanitizers)
163197
target_link_libraries(vix_sync INTERFACE vix_sanitizers)
164198
endif()

0 commit comments

Comments
 (0)