CMakeLists.txt 1.6 KB

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