CMakeLists.txt 2.6 KB

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