mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-05-08 08:18:51 +00:00
chore: make libwebp optional and support system libwebp (#1387)
Co-authored-by: leejet <leejet714@gmail.com>
This commit is contained in:
parent
87ecb95cbc
commit
687a81f251
@ -22,6 +22,16 @@ else()
|
|||||||
set(SD_STANDALONE OFF)
|
set(SD_STANDALONE OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(SD_SUBMODULE_WEBP FALSE)
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libwebp/CMakeLists.txt")
|
||||||
|
set(SD_SUBMODULE_WEBP TRUE)
|
||||||
|
endif()
|
||||||
|
if(SD_SUBMODULE_WEBP)
|
||||||
|
set(SD_WEBP_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set(SD_WEBP_DEFAULT ${SD_USE_SYSTEM_WEBP})
|
||||||
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Option list
|
# Option list
|
||||||
#
|
#
|
||||||
@ -29,7 +39,8 @@ endif()
|
|||||||
# general
|
# general
|
||||||
#option(SD_BUILD_TESTS "sd: build tests" ${SD_STANDALONE})
|
#option(SD_BUILD_TESTS "sd: build tests" ${SD_STANDALONE})
|
||||||
option(SD_BUILD_EXAMPLES "sd: build examples" ${SD_STANDALONE})
|
option(SD_BUILD_EXAMPLES "sd: build examples" ${SD_STANDALONE})
|
||||||
option(SD_WEBP "sd: enable WebP image I/O support" ON)
|
option(SD_WEBP "sd: enable WebP image I/O support" ${SD_WEBP_DEFAULT})
|
||||||
|
option(SD_USE_SYSTEM_WEBP "sd: link against system libwebp" OFF)
|
||||||
option(SD_CUDA "sd: cuda backend" OFF)
|
option(SD_CUDA "sd: cuda backend" OFF)
|
||||||
option(SD_HIPBLAS "sd: rocm backend" OFF)
|
option(SD_HIPBLAS "sd: rocm backend" OFF)
|
||||||
option(SD_METAL "sd: metal backend" OFF)
|
option(SD_METAL "sd: metal backend" OFF)
|
||||||
@ -79,6 +90,27 @@ if(SD_MUSA)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SD_WEBP)
|
if(SD_WEBP)
|
||||||
|
if(NOT SD_SUBMODULE_WEBP AND NOT SD_USE_SYSTEM_WEBP)
|
||||||
|
message(FATAL_ERROR "WebP support enabled but no source found.
|
||||||
|
Either initialize the submodule:\n git submodule update --init thirdparty/libwebp\n\n"
|
||||||
|
"Or link against system library:\n cmake (...) -DSD_USE_SYSTEM_WEBP=ON")
|
||||||
|
endif()
|
||||||
|
if(SD_USE_SYSTEM_WEBP)
|
||||||
|
find_package(WebP REQUIRED)
|
||||||
|
add_library(webp ALIAS WebP::webp)
|
||||||
|
# libwebp CMake target naming is not consistent across versions/distros.
|
||||||
|
# Some export WebP::libwebpmux, others export WebP::webpmux.
|
||||||
|
if(TARGET WebP::libwebpmux)
|
||||||
|
add_library(libwebpmux ALIAS WebP::libwebpmux)
|
||||||
|
elseif(TARGET WebP::webpmux)
|
||||||
|
add_library(libwebpmux ALIAS WebP::webpmux)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Could not find a compatible webpmux target in system WebP package. "
|
||||||
|
"Expected WebP::libwebpmux or WebP::webpmux."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
add_compile_definitions(SD_USE_WEBP)
|
add_compile_definitions(SD_USE_WEBP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
2
thirdparty/CMakeLists.txt
vendored
2
thirdparty/CMakeLists.txt
vendored
@ -2,7 +2,7 @@ set(Z_TARGET zip)
|
|||||||
add_library(${Z_TARGET} OBJECT zip.c zip.h miniz.h)
|
add_library(${Z_TARGET} OBJECT zip.c zip.h miniz.h)
|
||||||
target_include_directories(${Z_TARGET} PUBLIC .)
|
target_include_directories(${Z_TARGET} PUBLIC .)
|
||||||
|
|
||||||
if(SD_WEBP)
|
if(SD_WEBP AND NOT SD_USE_SYSTEM_WEBP)
|
||||||
set(WEBP_BUILD_ANIM_UTILS OFF)
|
set(WEBP_BUILD_ANIM_UTILS OFF)
|
||||||
set(WEBP_BUILD_CWEBP OFF)
|
set(WEBP_BUILD_CWEBP OFF)
|
||||||
set(WEBP_BUILD_DWEBP OFF)
|
set(WEBP_BUILD_DWEBP OFF)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user