CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # src/CMakeLists.txt - Build configuration for the main executable
  2. # Collect source files
  3. set(SOURCES
  4. main.cpp
  5. server.cpp
  6. model_manager.cpp
  7. model_detector.cpp
  8. generation_queue.cpp
  9. stable_diffusion_wrapper.cpp
  10. logger.cpp
  11. jwt_auth.cpp
  12. user_manager.cpp
  13. auth_middleware.cpp
  14. version.cpp
  15. )
  16. # Collect header files
  17. set(HEADERS
  18. ../include/server.h
  19. ../include/model_manager.h
  20. ../include/model_detector.h
  21. ../include/generation_queue.h
  22. ../include/stable_diffusion_wrapper.h
  23. ../include/jwt_auth.h
  24. ../include/user_manager.h
  25. ../include/auth_middleware.h
  26. ../include/server_config.h
  27. ${CMAKE_CURRENT_BINARY_DIR}/../include/version.h
  28. )
  29. # Add PAM authentication files if enabled
  30. if(ENABLE_PAM_AUTH AND PAM_FOUND)
  31. list(APPEND SOURCES pam_auth.cpp)
  32. list(APPEND HEADERS ../include/pam_auth.h)
  33. message(STATUS "PAM authentication support enabled")
  34. else()
  35. message(STATUS "PAM authentication support disabled")
  36. endif()
  37. # Create the executable target
  38. add_executable(stable-diffusion-rest-server ${SOURCES} ${HEADERS})
  39. # Set target properties
  40. set_target_properties(stable-diffusion-rest-server PROPERTIES
  41. CXX_STANDARD 17
  42. CXX_STANDARD_REQUIRED ON
  43. CXX_EXTENSIONS OFF
  44. )
  45. # Add include directories
  46. target_include_directories(stable-diffusion-rest-server PRIVATE
  47. ${CMAKE_CURRENT_SOURCE_DIR}/../include
  48. ${CMAKE_CURRENT_BINARY_DIR}/../include
  49. )
  50. # Link against dependencies
  51. target_link_libraries(stable-diffusion-rest-server PRIVATE
  52. sd-cpp
  53. ggml
  54. ggml-base
  55. ggml-cpu
  56. ${DEPENDENCY_LIBRARIES}
  57. OpenMP::OpenMP_CXX
  58. )
  59. # Link PAM library if enabled
  60. if(ENABLE_PAM_AUTH AND PAM_FOUND)
  61. target_link_libraries(stable-diffusion-rest-server PRIVATE ${PAM_LIBRARIES})
  62. endif()
  63. # Set compiler flags based on build type
  64. target_compile_options(stable-diffusion-rest-server PRIVATE
  65. $<$<CONFIG:Debug>:-g -O0 -Wall -Wextra>
  66. $<$<CONFIG:Release>:-O3 -DNDEBUG>
  67. )
  68. # Add CUDA flags if CUDA is enabled
  69. if(SD_CUDA_SUPPORT AND CUDA_FOUND)
  70. target_compile_definitions(stable-diffusion-rest-server PRIVATE SD_CUDA_SUPPORT)
  71. endif()
  72. # Add PAM flags if PAM is enabled
  73. if(ENABLE_PAM_AUTH AND PAM_FOUND)
  74. target_compile_definitions(stable-diffusion-rest-server PRIVATE ENABLE_PAM_AUTH)
  75. endif()
  76. # Add dependency on web UI build if enabled
  77. if(BUILD_WEBUI AND WEBUI_BUILT)
  78. add_dependencies(stable-diffusion-rest-server webui-build)
  79. message(STATUS "stable-diffusion-rest-server will build web UI automatically")
  80. endif()
  81. # Install target
  82. install(TARGETS stable-diffusion-rest-server
  83. RUNTIME DESTINATION bin
  84. )
  85. # Install headers
  86. install(FILES ${HEADERS}
  87. DESTINATION include/stable-diffusion-rest
  88. )
  89. message(STATUS "Configured stable-diffusion-rest-server executable")