CMakeLists.txt 1.79 KB
Newer Older
xuxzh1's avatar
init  
xuxzh1 committed
1
set(TARGET llama-server)
mashun1's avatar
v1  
mashun1 committed
2
option(LLAMA_SERVER_VERBOSE "Build verbose logging option for Server" ON)
xuxzh1's avatar
init  
xuxzh1 committed
3
4
option(LLAMA_SERVER_SSL     "Build SSL support for the server"        OFF)

mashun1's avatar
v1  
mashun1 committed
5
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
xuxzh1's avatar
init  
xuxzh1 committed
6
7
8
9
10
11

if (MINGW)
    # fix: https://github.com/ggerganov/llama.cpp/actions/runs/9651004652/job/26617901362?pr=8006
    add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
endif()

mashun1's avatar
v1  
mashun1 committed
12
13
14
15
16
17
set(TARGET_SRCS
    server.cpp
    utils.hpp
    httplib.h
)
set(PUBLIC_ASSETS
xuxzh1's avatar
init  
xuxzh1 committed
18
19
20
21
22
23
24
25
    colorthemes.css
    style.css
    theme-beeninorder.css
    theme-ketivah.css
    theme-mangotango.css
    theme-playground.css
    theme-polarnight.css
    theme-snowstorm.css
mashun1's avatar
v1  
mashun1 committed
26
    index.html
xuxzh1's avatar
init  
xuxzh1 committed
27
    index-new.html
mashun1's avatar
v1  
mashun1 committed
28
29
    index.js
    completion.js
xuxzh1's avatar
init  
xuxzh1 committed
30
31
    system-prompts.js
    prompt-formats.js
mashun1's avatar
v1  
mashun1 committed
32
33
    json-schema-to-grammar.mjs
)
xuxzh1's avatar
init  
xuxzh1 committed
34

mashun1's avatar
v1  
mashun1 committed
35
36
37
38
39
40
41
42
43
44
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"
    )
endforeach()
xuxzh1's avatar
init  
xuxzh1 committed
45

mashun1's avatar
v1  
mashun1 committed
46
47
48
49
50
add_executable(${TARGET} ${TARGET_SRCS})
install(TARGETS ${TARGET} RUNTIME)
target_compile_definitions(${TARGET} PRIVATE
    SERVER_VERBOSE=$<BOOL:${LLAMA_SERVER_VERBOSE}>
)
xuxzh1's avatar
init  
xuxzh1 committed
51

mashun1's avatar
v1  
mashun1 committed
52
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
xuxzh1's avatar
init  
xuxzh1 committed
53

mashun1's avatar
v1  
mashun1 committed
54
55
56
57
58
if (LLAMA_SERVER_SSL)
    find_package(OpenSSL REQUIRED)
    target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
    target_compile_definitions(${TARGET} PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
endif()
xuxzh1's avatar
init  
xuxzh1 committed
59

mashun1's avatar
v1  
mashun1 committed
60
61
62
if (WIN32)
    TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
endif()
xuxzh1's avatar
init  
xuxzh1 committed
63

mashun1's avatar
v1  
mashun1 committed
64
target_compile_features(${TARGET} PRIVATE cxx_std_11)