2024-04-21 18:48:53 +01:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2025-12-10 15:28:59 +01:00
|
|
|
# server-context containing the core server logic, used by llama-server and CLI
|
|
|
|
|
|
|
|
|
|
set(TARGET server-context)
|
|
|
|
|
|
|
|
|
|
add_library(${TARGET} STATIC
|
|
|
|
|
server-task.cpp
|
|
|
|
|
server-task.h
|
|
|
|
|
server-queue.cpp
|
|
|
|
|
server-queue.h
|
|
|
|
|
server-common.cpp
|
|
|
|
|
server-common.h
|
|
|
|
|
server-context.cpp
|
|
|
|
|
server-context.h
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
target_include_directories(${TARGET} PRIVATE ../mtmd)
|
|
|
|
|
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
|
|
|
|
|
target_link_libraries(${TARGET} PUBLIC common mtmd ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# llama-server executable
|
|
|
|
|
|
|
|
|
|
set(TARGET llama-server)
|
|
|
|
|
|
2025-11-12 12:32:50 +01:00
|
|
|
if (NOT LLAMA_HTTPLIB)
|
|
|
|
|
message(FATAL_ERROR "LLAMA_HTTPLIB is OFF, cannot build llama-server. Hint: to skip building server, set -DLLAMA_BUILD_SERVER=OFF")
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-04-21 18:48:53 +01:00
|
|
|
set(TARGET_SRCS
|
2024-03-21 11:50:43 +00:00
|
|
|
server.cpp
|
2025-11-17 22:05:44 +01:00
|
|
|
server-http.cpp
|
|
|
|
|
server-http.h
|
2025-12-01 19:41:04 +01:00
|
|
|
server-models.cpp
|
|
|
|
|
server-models.h
|
2024-03-21 11:50:43 +00:00
|
|
|
)
|
2024-04-21 18:48:53 +01:00
|
|
|
set(PUBLIC_ASSETS
|
2024-12-15 05:55:54 -06:00
|
|
|
index.html.gz
|
2024-09-13 14:23:11 +02:00
|
|
|
loading.html
|
2024-04-21 18:48:53 +01:00
|
|
|
)
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2024-04-21 18:48:53 +01:00
|
|
|
foreach(asset ${PUBLIC_ASSETS})
|
|
|
|
|
set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}")
|
|
|
|
|
set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp")
|
|
|
|
|
list(APPEND TARGET_SRCS ${output})
|
|
|
|
|
add_custom_command(
|
|
|
|
|
DEPENDS "${input}"
|
|
|
|
|
OUTPUT "${output}"
|
|
|
|
|
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${input}" "-DOUTPUT=${output}" -P "${PROJECT_SOURCE_DIR}/scripts/xxd.cmake"
|
|
|
|
|
)
|
2024-12-03 19:38:44 +01:00
|
|
|
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
|
2024-04-21 18:48:53 +01:00
|
|
|
endforeach()
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2024-04-21 18:48:53 +01:00
|
|
|
add_executable(${TARGET} ${TARGET_SRCS})
|
2023-07-19 15:01:11 +08:00
|
|
|
install(TARGETS ${TARGET} RUNTIME)
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2025-08-20 18:32:05 +08:00
|
|
|
target_include_directories(${TARGET} PRIVATE ../mtmd)
|
2024-12-24 21:33:04 +01:00
|
|
|
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR})
|
2025-12-10 15:28:59 +01:00
|
|
|
target_link_libraries(${TARGET} PRIVATE server-context PUBLIC common cpp-httplib ${CMAKE_THREAD_LIBS_INIT})
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2023-07-21 09:42:21 +02:00
|
|
|
if (WIN32)
|
|
|
|
|
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
|
|
|
|
|
endif()
|
2024-06-26 18:33:02 +03:00
|
|
|
|
2024-11-29 21:54:58 +01:00
|
|
|
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|