From 126c3a3510a37e21c7404745144b5872b72aafdd Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Mon, 05 Feb 2024 18:52:50 +0000
Subject: [PATCH] deleted external prebuild stuffs, reload model if vae changed - otherwise the vae model not loading
---
CMakeLists.txt | 109 ++++++++++++++++++++++++++++--------------------------
1 files changed, 57 insertions(+), 52 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4eee7c6..d194a7c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.10)
+set(PROJECT_NAME "sd.ui")
-project(sd.ui)
+project(${PROJECT_NAME})
set (CMAKE_CXX_STANDARD 20)
@@ -10,71 +11,76 @@
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)
+if(NOT CMAKE_BUILD_TYPE)
+set(CMAKE_BUILD_TYPE Debug)
+endif()
+
+add_executable(${PROJECT_NAME} ${OPTIONS} main.cpp ui/MainWindow.cpp ui/MainWindowSettings.cpp ui/MainWindowUi.cpp ui/MainWindowImageViewer.cpp ui/QueueManager.cpp)
-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)
+set(STABLE_DIFFUSION_DIR "${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp")
+include_directories(${STABLE_DIFFUSION_DIR}/include)
+link_directories(${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE})
IF(MSVC)
- set(CUDA_PATH "$ENV{CUDA_PATH}")
+ set(CUDA_PATH "$ENV{CUDA_PATH}")
+
+ #set(STABLE_DIFFUSION_LIB ${CMAKE_SOURCE_DIR}/external/stable-diffusion.cpp/${CMAKE_BUILD_TYPE}/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}")
+
+ add_library(stable-diffusion SHARED IMPORTED)
+ add_library(ggml SHARED IMPORTED)
+
+ set_target_properties(stable-diffusion PROPERTIES
+ IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
+ IMPORTED_LOCATION_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/stable-diffusion.dll
+ IMPORTED_IMPLIB_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/stable-diffusion.lib
+ IMPORTED_LOCATION_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/stable-diffusion.dll
+ IMPORTED_IMPLIB_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/stable-diffusion.lib
+ INTERFACE_INCLUDE_DIRECTORIES ${STABLE_DIFFUSION_DIR}/include
+ )
+
+ set_target_properties(ggml PROPERTIES
+ IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
+ IMPORTED_LOCATION_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/ggml.dll
+ IMPORTED_IMPLIB_DEBUG ${STABLE_DIFFUSION_DIR}/CUDA/Debug/ggml.lib
+ IMPORTED_LOCATION_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/ggml.dll
+ IMPORTED_IMPLIB_RELEASE ${STABLE_DIFFUSION_DIR}/CUDA/Release/ggml.lib
+ )
- 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
+ add_custom_command(TARGET ${PROJECT_NAME} 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
+ "${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE}/stable-diffusion.dll" # <--this is in-file
+ $<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path0
+ add_custom_command(TARGET ${PROJECT_NAME} 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
+ "${STABLE_DIFFUSION_DIR}/CUDA/${CMAKE_BUILD_TYPE}/ggml.dll" # <--this is in-file
+ $<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path0
+ set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
ENDIF(MSVC)
-set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
+#set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
find_package(OpenCV REQUIRED)
@@ -95,16 +101,15 @@
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})
+#set(CUDA_LIB_PATH "C:/CUDA/lib/x64")
-target_compile_definitions(sd.ui PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>")
-target_include_directories(sd.ui PRIVATE ${wxWidgets_INCLUDE_DIRS})
+target_compile_definitions(${PROJECT_NAME} PRIVATE ${wxWidgets_DEFINITIONS} "$<$<CONFIG:DEBUG>:${wxWidgets_DEFINITIONS_DEBUG}>")
+target_include_directories(${PROJECT_NAME} PRIVATE ${wxWidgets_INCLUDE_DIRS})
-target_link_libraries(sd.ui ${CUDA_LIBRARIES})
+target_link_libraries(${PROJECT_NAME} ${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)
+target_link_libraries(${PROJECT_NAME} PRIVATE stable-diffusion ggml restclient-cpp opencv_ml opencv_dnn opencv_core opencv_flann nlohmann_json::nlohmann_json fmt::fmt wx::core wx::base wx::xrc wx::adv wx::richtext wx::aui CUDA::cudart CUDA::cublas CUDA::cublasLt CUDA::cuda_driver)
include_directories(ui)
--
Gitblit v1.9.3