mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-09-21 13:38:01 -05:00
28 lines
1.2 KiB
CMake
28 lines
1.2 KiB
CMake
if(NOT TARGET ggml AND NOT TARGET ggml::ggml)
|
|
if(SD_USE_SYSTEM_GGML)
|
|
find_package(ggml REQUIRED)
|
|
else()
|
|
add_subdirectory("${SD_GGML_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ggml")
|
|
endif()
|
|
endif()
|
|
if(NOT TARGET ggml)
|
|
add_library(ggml ALIAS ggml::ggml)
|
|
endif()
|
|
|
|
get_target_property(sd_ggml_imported ggml IMPORTED)
|
|
if(sd_ggml_imported)
|
|
set(sd_ggml_private_include "${SD_GGML_SOURCE_DIR}/src")
|
|
else()
|
|
get_target_property(sd_ggml_private_include ggml SOURCE_DIR)
|
|
endif()
|
|
if(NOT EXISTS "${sd_ggml_private_include}/ggml-impl.h")
|
|
message(FATAL_ERROR "Set SD_GGML_SOURCE_DIR to the source tree matching the selected ggml library (ggml-impl.h is required).")
|
|
endif()
|
|
target_include_directories(${SD_LIB} PRIVATE "${sd_ggml_private_include}")
|
|
set_property(TARGET ${SD_LIB} PROPERTY SD_GGML_PRIVATE_INCLUDE_DIR "${sd_ggml_private_include}")
|
|
|
|
if(SD_USE_UPSTREAM_GGML)
|
|
target_compile_definitions(${SD_LIB} PUBLIC SD_USE_UPSTREAM_GGML)
|
|
message(WARNING "Using upstream GGML: INT8 tensorwise/convrot is disabled and FP8 weights are converted to F16 at load time. Some operators may be unsupported and performance may be lower than with patched GGML.")
|
|
endif()
|