cmake_minimum_required(VERSION 3.10)
|
|
|
project(sd.ui)
|
|
set (CMAKE_CXX_STANDARD 20)
|
|
|
|
option(SD_CUBLAS "sd: cuda backend" ON)
|
option(SD_HIPBLAS "sd: rocm backend" OFF)
|
option(SD_METAL "sd: metal backend" OFF)
|
set(SD_CUBLAS ON)
|
|
|
#enable_language(CUDA)
|
message("CUDA ON")
|
|
|
|
|
IF(MSVC)
|
SET(OPTIONS WIN32)
|
ENDIF(MSVC)
|
|
|
|
add_executable(sd.ui ${OPTIONS} main.cpp ui/MainWindow.cpp ui/MainWindowSettings.cpp ui/MainWindowUi.cpp ui/MainWindowImageViewer.cpp ui/QueueManager.cpp)
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/include)
|
link_directories(${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/lib)
|
|
|
IF(MSVC)
|
|
|
set(CUDA_PATH "$ENV{CUDA_PATH}")
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
set(CMAKE_BUILD_TYPE Debug)
|
endif()
|
|
set(STABLE_DIFFUSION_LIB ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/lib/stable-diffusion.lib)
|
set(GGML_LIB ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/lib/ggml.lib)
|
set(STABLE_DIFFUSION_DLL ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/stable-diffusion.dll)
|
set(GGML_DLL ${CMAKE_SOURCE_DIR}/external/ggml/${CMAKE_BUILD_TYPE}/ggml.dll)
|
|
add_library(SDLIB SHARED IMPORTED)
|
set_property(TARGET SDLIB PROPERTY IMPORTED_LOCATION "${STABLE_DIFFUSION_DLL}")
|
set_property(TARGET SDLIB PROPERTY IMPORTED_IMPLIB "${STABLE_DIFFUSION_LIB}")
|
|
add_library(GGMLLIB SHARED IMPORTED)
|
set_property(TARGET GGMLLIB PROPERTY IMPORTED_LOCATION "${GGML_DLL}")
|
set_property(TARGET GGMLLIB PROPERTY IMPORTED_IMPLIB "${GGML_LIB}")
|
|
|
message("STABLE_DIFFUSION_LIB=" ${STABLE_DIFFUSION_LIB})
|
message("GGML_LIB=" ${GGML_LIB})
|
message("CUDA_PATH=" ${CUDA_PATH})
|
|
|
add_custom_command(TARGET sd.ui POST_BUILD # Adds a post-build event to MyTest
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
|
"${STABLE_DIFFUSION_DLL}" # <--this is in-file
|
$<TARGET_FILE_DIR:sd.ui>) # <--this is out-file path0
|
|
add_custom_command(TARGET sd.ui POST_BUILD # Adds a post-build event to MyTest
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
|
"${GGML_DLL}" # <--this is in-file
|
$<TARGET_FILE_DIR:sd.ui>) # <--this is out-file path0
|
|
|
ENDIF(MSVC)
|
|
set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
|
|
find_package(OpenCV REQUIRED)
|
|
if( OpenCV_FOUND )
|
# Additional Include Directories
|
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
|
# Additional Library Directories
|
link_directories( ${OpenCV_LIB_DIR} )
|
|
# Additional Dependencies
|
# target_link_libraries(sd.ui ${OpenCV_LIBS} )
|
endif()
|
|
find_package(restclient-cpp CONFIG REQUIRED)
|
find_package(fmt CONFIG REQUIRED)
|
find_package(wxWidgets CONFIG REQUIRED)
|
find_package(nlohmann_json CONFIG REQUIRED)
|
find_package(CUDAToolkit REQUIRED)
|
|
set(CUDA_LIB_PATH "C:/CUDA/lib/x64")
|
message("CUDA_LIB_PATH=" ${CUDA_LIB_PATH})
|
|
|
target_compile_definitions(sd.ui PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>")
|
target_include_directories(sd.ui PRIVATE ${wxWidgets_INCLUDE_DIRS})
|
|
target_link_libraries(sd.ui ${CUDA_LIBRARIES})
|
|
target_link_libraries(sd.ui PRIVATE restclient-cpp ${OpenCV_LIBS} nlohmann_json::nlohmann_json fmt::fmt wx::core wx::base wx::xrc wx::adv wx::richtext wx::aui SDLIB GGMLLIB CUDA::cudart CUDA::cublas CUDA::cublasLt CUDA::cuda_driver)
|
|
include_directories(ui)
|