CMakeLists.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. set(TARGET llama-server)
  2. option(LLAMA_SERVER_VERBOSE "Build verbose logging option for Server" ON)
  3. option(LLAMA_SERVER_SSL "Build SSL support for the server" OFF)
  4. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
  5. if (MINGW)
  6. # fix: https://github.com/ggerganov/llama.cpp/actions/runs/9651004652/job/26617901362?pr=8006
  7. add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
  8. endif()
  9. set(TARGET_SRCS
  10. server.cpp
  11. utils.hpp
  12. httplib.h
  13. )
  14. set(PUBLIC_ASSETS
  15. colorthemes.css
  16. style.css
  17. theme-beeninorder.css
  18. theme-ketivah.css
  19. theme-mangotango.css
  20. theme-playground.css
  21. theme-polarnight.css
  22. theme-snowstorm.css
  23. index.html
  24. index-new.html
  25. index.js
  26. completion.js
  27. system-prompts.js
  28. prompt-formats.js
  29. json-schema-to-grammar.mjs
  30. loading.html
  31. )
  32. foreach(asset ${PUBLIC_ASSETS})
  33. set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}")
  34. set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp")
  35. list(APPEND TARGET_SRCS ${output})
  36. add_custom_command(
  37. DEPENDS "${input}"
  38. OUTPUT "${output}"
  39. COMMAND "${CMAKE_COMMAND}" "-DINPUT=${input}" "-DOUTPUT=${output}" -P "${PROJECT_SOURCE_DIR}/scripts/xxd.cmake"
  40. )
  41. endforeach()
  42. add_executable(${TARGET} ${TARGET_SRCS})
  43. install(TARGETS ${TARGET} RUNTIME)
  44. target_compile_definitions(${TARGET} PRIVATE
  45. SERVER_VERBOSE=$<BOOL:${LLAMA_SERVER_VERBOSE}>
  46. )
  47. target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
  48. if (LLAMA_SERVER_SSL)
  49. find_package(OpenSSL REQUIRED)
  50. target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
  51. target_compile_definitions(${TARGET} PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
  52. endif()
  53. if (WIN32)
  54. TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
  55. endif()
  56. target_compile_features(${TARGET} PRIVATE cxx_std_11)