Skip to content

Commit 38d3bc2

Browse files
committed
fix(cmake): clean utils resolution logic in log module
1 parent 131ed59 commit 38d3bc2

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4242
# --------------------------------------------------------------------
4343
# Umbrella build policy:
4444
# When building inside the Vix umbrella, dependencies are managed by the
45-
# umbrella (add_subdirectory order + options). Log must not FetchContent
46-
# nor add sibling subdirectories in umbrella mode.
45+
# umbrella. In that mode, log must not auto-fetch utils.
4746
# --------------------------------------------------------------------
47+
option(VIX_LOG_FETCH_UTILS "Auto-fetch vix::utils if missing" ON)
48+
4849
if (DEFINED VIX_UMBRELLA_BUILD AND VIX_UMBRELLA_BUILD)
4950
set(VIX_LOG_FETCH_UTILS OFF CACHE BOOL "Auto-fetch vix::utils if missing" FORCE)
5051
endif()
@@ -57,12 +58,24 @@ file(GLOB_RECURSE LOG_SOURCES CONFIGURE_DEPENDS
5758
# Utils dependency
5859
if (NOT TARGET vix::utils AND NOT TARGET vix_utils)
5960
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/../utils/CMakeLists.txt")
60-
message(STATUS "[log] Adding utils from umbrella: ../utils")
61+
message(STATUS "[log] Adding utils from sibling: ../utils")
6162
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../utils" "utils")
62-
elseif (VIX_LOG_FETCH_UTILS)
63+
endif()
64+
65+
if (NOT TARGET vix::utils AND NOT TARGET vix_utils)
6366
find_package(vix_utils CONFIG QUIET)
6467
find_package(utils CONFIG QUIET)
6568
endif()
69+
70+
if (NOT TARGET vix::utils AND NOT TARGET vix_utils AND VIX_LOG_FETCH_UTILS)
71+
include(FetchContent)
72+
message(STATUS "[log] Fetching vix::utils via FetchContent")
73+
FetchContent_Declare(vix_utils
74+
GIT_REPOSITORY https://github.com/vixcpp/utils.git
75+
GIT_TAG v0.1.0
76+
)
77+
FetchContent_MakeAvailable(vix_utils)
78+
endif()
6679
endif()
6780

6881
set(VIX_UTILS_TARGET "")

0 commit comments

Comments
 (0)