# src/CMakeLists.txt - Build configuration for the main executable # Collect source files set(SOURCES main.cpp server.cpp model_manager.cpp model_detector.cpp generation_queue.cpp stable_diffusion_wrapper.cpp logger.cpp jwt_auth.cpp user_manager.cpp auth_middleware.cpp version.cpp ) # Collect header files set(HEADERS ../include/server.h ../include/model_manager.h ../include/model_detector.h ../include/generation_queue.h ../include/stable_diffusion_wrapper.h ../include/jwt_auth.h ../include/user_manager.h ../include/auth_middleware.h ../include/server_config.h ${CMAKE_CURRENT_BINARY_DIR}/../include/version.h ) # Add PAM authentication files if enabled if(ENABLE_PAM_AUTH AND PAM_FOUND) list(APPEND SOURCES pam_auth.cpp) list(APPEND HEADERS ../include/pam_auth.h) message(STATUS "PAM authentication support enabled") else() message(STATUS "PAM authentication support disabled") endif() # Create the executable target add_executable(stable-diffusion-rest-server ${SOURCES} ${HEADERS}) # Set target properties set_target_properties(stable-diffusion-rest-server PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF ) # Add include directories target_include_directories(stable-diffusion-rest-server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include ${CMAKE_CURRENT_BINARY_DIR}/../include ) # Link against dependencies target_link_libraries(stable-diffusion-rest-server PRIVATE sd-cpp ggml ggml-base ggml-cpu ${DEPENDENCY_LIBRARIES} OpenMP::OpenMP_CXX ) # Link PAM library if enabled if(ENABLE_PAM_AUTH AND PAM_FOUND) target_link_libraries(stable-diffusion-rest-server PRIVATE ${PAM_LIBRARIES}) endif() # Set compiler flags based on build type target_compile_options(stable-diffusion-rest-server PRIVATE $<$:-g -O0 -Wall -Wextra> $<$:-O3 -DNDEBUG> ) # Add CUDA flags if CUDA is enabled if(SD_CUDA_SUPPORT AND CUDA_FOUND) target_compile_definitions(stable-diffusion-rest-server PRIVATE SD_CUDA_SUPPORT) endif() # Add PAM flags if PAM is enabled if(ENABLE_PAM_AUTH AND PAM_FOUND) target_compile_definitions(stable-diffusion-rest-server PRIVATE ENABLE_PAM_AUTH) endif() # Add dependency on web UI build if enabled if(BUILD_WEBUI AND WEBUI_BUILT) add_dependencies(stable-diffusion-rest-server webui-build) message(STATUS "stable-diffusion-rest-server will build web UI automatically") endif() # Install target install(TARGETS stable-diffusion-rest-server RUNTIME DESTINATION bin ) # Install headers install(FILES ${HEADERS} DESTINATION include/stable-diffusion-rest ) message(STATUS "Configured stable-diffusion-rest-server executable")