Skip to content

Commit dec919e

Browse files
committed
fix(agent): link io examples dependency
1 parent f7dabae commit dec919e

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ option(VIX_AI_AGENT_FETCH_TIME "Auto-fetch vix::time if missing" ON)
7878
option(VIX_AI_AGENT_FETCH_CRYPTO "Auto-fetch vix::crypto if missing" ON)
7979
option(VIX_AI_AGENT_FETCH_LOG "Auto-fetch vix::log if missing" ON)
8080
option(VIX_AI_AGENT_FETCH_CACHE "Auto-fetch vix::cache if missing" ON)
81+
option(VIX_AI_AGENT_FETCH_IO "Auto-fetch vix::io if missing for examples" ON)
8182

8283
# --------------------------------------------------------------------
8384
# Export set selection
@@ -107,8 +108,8 @@ if(DEFINED VIX_UMBRELLA_BUILD AND VIX_UMBRELLA_BUILD)
107108
set(VIX_AI_AGENT_FETCH_CRYPTO OFF CACHE BOOL "Auto-fetch vix::crypto if missing" FORCE)
108109
set(VIX_AI_AGENT_FETCH_LOG OFF CACHE BOOL "Auto-fetch vix::log if missing" FORCE)
109110
set(VIX_AI_AGENT_FETCH_CACHE OFF CACHE BOOL "Auto-fetch vix::cache if missing" FORCE)
111+
set(VIX_AI_AGENT_FETCH_IO OFF CACHE BOOL "Auto-fetch vix::io if missing for examples" FORCE)
110112
endif()
111-
112113
# --------------------------------------------------------------------
113114
# Dependency helper
114115
# --------------------------------------------------------------------
@@ -158,6 +159,52 @@ function(vix_ai_agent_require_dependency target package_name sibling_dir fetch_o
158159
endif()
159160
endfunction()
160161

162+
function(vix_ai_agent_require_io_for_examples)
163+
if(TARGET vix::io)
164+
return()
165+
endif()
166+
167+
if(DEFINED VIX_UMBRELLA_BUILD AND VIX_UMBRELLA_BUILD)
168+
message(FATAL_ERROR "[ai_agent/examples] Umbrella build: vix::io must be provided before ai_agent examples.")
169+
endif()
170+
171+
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../io/CMakeLists.txt")
172+
message(STATUS "[ai_agent/examples] Adding io from sibling: ../io")
173+
174+
add_subdirectory(
175+
"${CMAKE_CURRENT_LIST_DIR}/../io"
176+
"${CMAKE_CURRENT_BINARY_DIR}/deps/io"
177+
EXCLUDE_FROM_ALL
178+
)
179+
else()
180+
find_package(vix_io CONFIG QUIET)
181+
endif()
182+
183+
if(TARGET vix::io)
184+
return()
185+
endif()
186+
187+
if(VIX_AI_AGENT_FETCH_IO)
188+
include(FetchContent)
189+
190+
message(STATUS "[ai_agent/examples] Fetching vix::io via FetchContent")
191+
192+
FetchContent_Declare(vix_io
193+
GIT_REPOSITORY https://github.com/vixcpp/io.git
194+
GIT_TAG v0.1.0
195+
)
196+
197+
FetchContent_MakeAvailable(vix_io)
198+
endif()
199+
200+
if(NOT TARGET vix::io)
201+
message(FATAL_ERROR
202+
"[ai_agent/examples] vix::io not found. Examples include <vix/print.hpp>, "
203+
"so they require vix::io."
204+
)
205+
endif()
206+
endfunction()
207+
161208
# --------------------------------------------------------------------
162209
# Nested dependency policy
163210
# --------------------------------------------------------------------
@@ -411,13 +458,16 @@ endif()
411458
# Examples
412459
# --------------------------------------------------------------------
413460
if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples")
461+
vix_ai_agent_require_io_for_examples()
462+
414463
add_executable(vix_ai_agent_basic_agent
415464
examples/basic_agent.cpp
416465
)
417466

418467
target_link_libraries(vix_ai_agent_basic_agent
419468
PRIVATE
420469
vix::ai_agent
470+
vix::io
421471
)
422472

423473
add_executable(vix_ai_agent_scan_project
@@ -427,6 +477,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
427477
target_link_libraries(vix_ai_agent_scan_project
428478
PRIVATE
429479
vix::ai_agent
480+
vix::io
430481
)
431482

432483
add_executable(vix_ai_agent_ollama_agent
@@ -436,6 +487,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
436487
target_link_libraries(vix_ai_agent_ollama_agent
437488
PRIVATE
438489
vix::ai_agent
490+
vix::io
439491
)
440492

441493
add_executable(vix_ai_agent_with_cache
@@ -445,6 +497,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
445497
target_link_libraries(vix_ai_agent_with_cache
446498
PRIVATE
447499
vix::ai_agent
500+
vix::io
448501
)
449502

450503
add_executable(vix_ai_agent_with_command_tool
@@ -454,6 +507,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
454507
target_link_libraries(vix_ai_agent_with_command_tool
455508
PRIVATE
456509
vix::ai_agent
510+
vix::io
457511
)
458512

459513
add_executable(vix_ai_agent_custom_provider
@@ -463,6 +517,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
463517
target_link_libraries(vix_ai_agent_custom_provider
464518
PRIVATE
465519
vix::ai_agent
520+
vix::io
466521
)
467522

468523
add_executable(vix_ai_agent_public_api
@@ -472,6 +527,7 @@ if(VIX_AI_AGENT_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples"
472527
target_link_libraries(vix_ai_agent_public_api
473528
PRIVATE
474529
vix::ai_agent
530+
vix::io
475531
)
476532
endif()
477533
# --------------------------------------------------------------------

0 commit comments

Comments
 (0)