Skip to content

Commit 7f3e2ce

Browse files
author
Chris Warren-Smith
committed
LLAMA: replace test_main with nitro agent application
1 parent 370e440 commit 7f3e2ce

2 files changed

Lines changed: 874 additions & 297 deletions

File tree

llama/CMakeLists.txt

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ set_target_properties(llm PROPERTIES
155155
# -----------------------------
156156
find_package(PkgConfig QUIET)
157157

158+
# ── notcurses ─────────────────────────────────────────────────────────────
158159
set(NC_FOUND FALSE)
159160
set(NC_TARGET "")
160-
161161
if(DEFINED NOTCURSES_DIR)
162162
# Explicit path — create an imported target manually
163163
find_library(NC_LIB NAMES notcurses HINTS "${NOTCURSES_DIR}/lib" REQUIRED)
@@ -170,14 +170,11 @@ if(DEFINED NOTCURSES_DIR)
170170
endif()
171171
set(NC_TARGET notcurses_imported)
172172
set(NC_FOUND TRUE)
173-
174173
elseif(PkgConfig_FOUND)
175-
# IMPORTED_TARGET gives a PkgConfig::NC target with full lib paths baked in
176174
pkg_check_modules(NC QUIET IMPORTED_TARGET notcurses)
177175
if(NC_FOUND)
178176
set(NC_TARGET PkgConfig::NC)
179177
endif()
180-
181178
else()
182179
find_library(NC_LIB NAMES notcurses)
183180
find_library(NC_CORE_LIB NAMES notcurses-core)
@@ -189,9 +186,55 @@ else()
189186
endif()
190187
endif()
191188

189+
# ── libcurl ───────────────────────────────────────────────────────────────
190+
# Try the modern CMake find-module first (ships with CMake ≥ 3.12).
191+
# Fall back to pkg-config, then a raw library search.
192+
set(CURL_FOUND_INTERNAL FALSE)
193+
set(CURL_TARGET "")
194+
195+
if(DEFINED CURL_DIR)
196+
# Explicit path supplied by the user (-DCURL_DIR=...)
197+
find_library(CURL_LIB NAMES curl HINTS "${CURL_DIR}/lib" REQUIRED)
198+
find_path(CURL_INCLUDE NAMES curl/curl.h HINTS "${CURL_DIR}/include" REQUIRED)
199+
add_library(curl_imported INTERFACE IMPORTED)
200+
target_include_directories(curl_imported INTERFACE "${CURL_INCLUDE}")
201+
target_link_libraries(curl_imported INTERFACE ${CURL_LIB})
202+
set(CURL_TARGET curl_imported)
203+
set(CURL_FOUND_INTERNAL TRUE)
204+
else()
205+
# CMake built-in (sets CURL::libcurl target when found)
206+
find_package(CURL QUIET)
207+
if(CURL_FOUND)
208+
set(CURL_TARGET CURL::libcurl)
209+
set(CURL_FOUND_INTERNAL TRUE)
210+
elseif(PkgConfig_FOUND)
211+
pkg_check_modules(CURL_PC QUIET IMPORTED_TARGET libcurl)
212+
if(CURL_PC_FOUND)
213+
set(CURL_TARGET PkgConfig::CURL_PC)
214+
set(CURL_FOUND_INTERNAL TRUE)
215+
endif()
216+
endif()
217+
if(NOT CURL_FOUND_INTERNAL)
218+
find_library(CURL_LIB NAMES curl)
219+
find_path(CURL_INCLUDE NAMES curl/curl.h)
220+
if(CURL_LIB AND CURL_INCLUDE)
221+
add_library(curl_imported INTERFACE IMPORTED)
222+
target_include_directories(curl_imported INTERFACE "${CURL_INCLUDE}")
223+
target_link_libraries(curl_imported INTERFACE ${CURL_LIB})
224+
set(CURL_TARGET curl_imported)
225+
set(CURL_FOUND_INTERNAL TRUE)
226+
endif()
227+
endif()
228+
endif()
229+
230+
# ── nitro target ──────────────────────────────────────────────────────────
192231
if(NC_FOUND)
193-
message(STATUS "notcurses found — building nitro")
232+
if(NOT CURL_FOUND_INTERNAL)
233+
message(WARNING "libcurl not found — TOOL:CURL will be unavailable. "
234+
"Install libcurl-dev or set -DCURL_DIR=<prefix> to enable.")
235+
endif()
194236

237+
message(STATUS "notcurses found — building nitro")
195238
add_executable(nitro
196239
nitro.cpp
197240
)
@@ -206,35 +249,19 @@ if(NC_FOUND)
206249
ggml
207250
${NC_TARGET} # imported target carries include + lib paths
208251
)
252+
if(CURL_FOUND_INTERNAL)
253+
target_link_libraries(nitro PRIVATE ${CURL_TARGET})
254+
target_compile_definitions(nitro PRIVATE NITRO_HAVE_CURL=1)
255+
else()
256+
target_compile_definitions(nitro PRIVATE NITRO_HAVE_CURL=0)
257+
endif()
209258
set_target_properties(nitro PROPERTIES
210259
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
211260
)
212261
else()
213262
message(STATUS "notcurses not found — skipping nitro (set -DNOTCURSES_DIR=... to enable)")
214263
endif()
215264

216-
# -----------------------------
217-
# RAG indexer
218-
# -----------------------------
219-
add_executable(rag_index
220-
rag_index.cpp
221-
)
222-
223-
target_include_directories(rag_index PRIVATE
224-
${LLAMA_DIR}/include
225-
${LLAMA_DIR}/ggml/include
226-
)
227-
228-
target_link_libraries(rag_index PRIVATE
229-
llm
230-
llama
231-
ggml
232-
)
233-
234-
set_target_properties(rag_index PROPERTIES
235-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
236-
)
237-
238265
# -----------------------------
239266
# Header preparation for RAG indexer
240267
# -----------------------------

0 commit comments

Comments
 (0)