Skip to content

Commit 12c0bb2

Browse files
committed
fix: add third-party fallbacks for standalone io builds
1 parent a515308 commit 12c0bb2

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ endif()
6868
option(VIX_IO_FETCH_ERROR "Auto-fetch vix::error if missing" ON)
6969
option(VIX_IO_FETCH_UTILS "Auto-fetch vix::utils if missing" ON)
7070
option(VIX_IO_FETCH_LOG "Auto-fetch vix::log if missing" ON)
71+
option(VIX_IO_FETCH_THIRD_PARTY "Auto-fetch third-party dependencies needed by fetched Vix modules" ON)
7172
option(VIX_IO_BUILD_TESTS "Build io module tests" OFF)
7273
option(VIX_IO_BUILD_EXAMPLES "Build io module examples" OFF)
7374

@@ -83,6 +84,7 @@ if (DEFINED VIX_UMBRELLA_BUILD AND VIX_UMBRELLA_BUILD)
8384
set(VIX_IO_FETCH_ERROR OFF CACHE BOOL "Auto-fetch vix::error if missing" FORCE)
8485
set(VIX_IO_FETCH_UTILS OFF CACHE BOOL "Auto-fetch vix::utils if missing" FORCE)
8586
set(VIX_IO_FETCH_LOG OFF CACHE BOOL "Auto-fetch vix::log if missing" FORCE)
87+
set(VIX_IO_FETCH_THIRD_PARTY OFF CACHE BOOL "Auto-fetch third-party dependencies needed by fetched Vix modules" FORCE)
8688
endif()
8789

8890
# --------------------------------------------------------------------
@@ -154,6 +156,55 @@ function(vix_io_resolve_dependency module_name target_name package_name fetch_op
154156
endif()
155157
endfunction()
156158

159+
function(vix_io_prepare_utils_third_party)
160+
if (TARGET spdlog::spdlog_header_only OR TARGET spdlog::spdlog)
161+
if (TARGET fmt::fmt-header-only OR TARGET fmt::fmt)
162+
return()
163+
endif()
164+
endif()
165+
166+
find_package(fmt CONFIG QUIET)
167+
find_package(spdlog CONFIG QUIET)
168+
169+
if ((TARGET spdlog::spdlog_header_only OR TARGET spdlog::spdlog) AND
170+
(TARGET fmt::fmt-header-only OR TARGET fmt::fmt))
171+
return()
172+
endif()
173+
174+
if (NOT VIX_IO_FETCH_THIRD_PARTY)
175+
return()
176+
endif()
177+
178+
include(FetchContent)
179+
180+
if (NOT TARGET fmt::fmt-header-only AND NOT TARGET fmt::fmt)
181+
message(STATUS "[io] Fetching fmt for vix::utils")
182+
set(FMT_DOC OFF CACHE BOOL "" FORCE)
183+
set(FMT_TEST OFF CACHE BOOL "" FORCE)
184+
set(FMT_INSTALL OFF CACHE BOOL "" FORCE)
185+
FetchContent_Declare(vix_fmt
186+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
187+
GIT_TAG 10.2.1
188+
)
189+
FetchContent_MakeAvailable(vix_fmt)
190+
endif()
191+
192+
if (NOT TARGET spdlog::spdlog_header_only AND NOT TARGET spdlog::spdlog)
193+
message(STATUS "[io] Fetching spdlog for vix::utils")
194+
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "" FORCE)
195+
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
196+
set(SPDLOG_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
197+
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
198+
set(SPDLOG_BUILD_BENCH OFF CACHE BOOL "" FORCE)
199+
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
200+
FetchContent_Declare(vix_spdlog
201+
GIT_REPOSITORY https://github.com/gabime/spdlog.git
202+
GIT_TAG v1.14.1
203+
)
204+
FetchContent_MakeAvailable(vix_spdlog)
205+
endif()
206+
endfunction()
207+
157208
# --------------------------------------------------------------------
158209
# Required dependencies
159210
# --------------------------------------------------------------------
@@ -168,13 +219,15 @@ vix_io_resolve_dependency(
168219

169220
set(VIX_ERROR_TARGET vix::error)
170221

222+
vix_io_prepare_utils_third_party()
223+
171224
vix_io_resolve_dependency(
172225
utils
173226
vix::utils
174227
vix_utils
175228
VIX_IO_FETCH_UTILS
176229
https://github.com/vixcpp/utils.git
177-
v1.5.2
230+
v1.14.7
178231
)
179232

180233
set(VIX_UTILS_TARGET vix::utils)

‎vix.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
{
5151
"id": "vix/utils",
52-
"version": "1.5.2"
52+
"version": "1.14.7"
5353
},
5454
{
5555
"id": "vix/log",

0 commit comments

Comments
 (0)