@@ -68,6 +68,7 @@ endif()
6868option (VIX_IO_FETCH_ERROR "Auto-fetch vix::error if missing" ON )
6969option (VIX_IO_FETCH_UTILS "Auto-fetch vix::utils if missing" ON )
7070option (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 )
7172option (VIX_IO_BUILD_TESTS "Build io module tests" OFF )
7273option (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 )
8688endif ()
8789
8890# --------------------------------------------------------------------
@@ -154,6 +156,55 @@ function(vix_io_resolve_dependency module_name target_name package_name fetch_op
154156 endif ()
155157endfunction ()
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
169220set (VIX_ERROR_TARGET vix::error)
170221
222+ vix_io_prepare_utils_third_party ()
223+
171224vix_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
180233set (VIX_UTILS_TARGET vix::utils)
0 commit comments