mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-17 20:31:47 +02:00
This commit updates cmake to use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR for paths in function calls. The motivation for this is that when using add_subdirectory, CMAKE_SOURCE_DIR is fixed to the top-level projects source directory, that is the caller of add_subdirectory and not the llama.cpp root which means that common/common.h header will not be resolved. Refs: https://github.com/ggml-org/llama.cpp/pull/28091#issuecomment-5636106377
68 lines
1.7 KiB
CMake
68 lines
1.7 KiB
CMake
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
# server-context containing the core server logic, used by llama-server and CLI
|
|
|
|
set(TARGET server-context)
|
|
|
|
add_library(${TARGET} STATIC
|
|
server-chat.cpp
|
|
server-chat.h
|
|
server-task.cpp
|
|
server-task.h
|
|
server-queue.cpp
|
|
server-queue.h
|
|
server-common.cpp
|
|
server-common.h
|
|
server-context.cpp
|
|
server-context.h
|
|
server-stream.cpp
|
|
server-stream.h
|
|
server-tools.cpp
|
|
server-tools.h
|
|
server-mcp.cpp
|
|
server-mcp.h
|
|
server-schema.cpp
|
|
server-schema.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 ${PROJECT_SOURCE_DIR})
|
|
target_link_libraries(${TARGET} PUBLIC llama-common mtmd ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
# llama-server-impl: server logic, reusable by app
|
|
|
|
set(TARGET llama-server-impl)
|
|
|
|
add_library(${TARGET}
|
|
server.cpp
|
|
server-http.cpp
|
|
server-http.h
|
|
server-models.cpp
|
|
server-models.h
|
|
)
|
|
set_target_properties(${TARGET} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_include_directories(${TARGET} PRIVATE ../mtmd ${PROJECT_SOURCE_DIR})
|
|
target_link_libraries(${TARGET} PUBLIC server-context llama-ui cpp-httplib ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
add_dependencies(${TARGET} llama-ui-assets)
|
|
|
|
if(LLAMA_TOOLS_INSTALL)
|
|
install(TARGETS ${TARGET} LIBRARY)
|
|
endif()
|
|
|
|
# llama-server executable
|
|
|
|
set(TARGET llama-server)
|
|
|
|
add_executable(${TARGET} main.cpp)
|
|
install(TARGETS ${TARGET} RUNTIME)
|
|
|
|
target_link_libraries(${TARGET} PRIVATE llama-server-impl)
|
|
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|