From 848e031f0289c7fd67c2d6d098de26e479a40adb Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sun, 10 Jul 2022 20:14:00 +0300 Subject: [PATCH] Use shared webp library Added option -DUSE_SHARED_WEBP --- CMakeLists.txt | 13 ++++++++++--- third_party/CMakeLists.txt | 34 ++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 306049917..0196a47f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ option(USE_SHARED_LIBARCHIVE "Use your installed copy of libarchive" off) option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off) option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off) option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off) +option(USE_SHARED_WEBP "User your installed copy of webp" off) option(USE_SHARED_FREETYPE "Use shared FreeType library" off) option(USE_SHARED_HARFBUZZ "Use shared HarfBuzz library" off) option(ENABLE_ASEPRITE_EXE "Compile main Aseprite executable" on) @@ -241,9 +242,15 @@ add_definitions(-DPNG_NO_MMX_CODE) # Do not use MMX optimizations in PNG code # libwebp if(ENABLE_WEBP) - set(WEBP_LIBRARIES webp webpdemux libwebpmux) - set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src) - include_directories(${WEBP_INCLUDE_DIR}) + if(USE_SHARED_WEBP) + find_package(PkgConfig QUIET) + pkg_check_modules(WEBP libwebp libwebpdemux libwebpmux) + include_directories(${WEBP_INCLUDE_DIR}) + else() + set(WEBP_LIBRARIES webp webpdemux libwebpmux) + set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src) + include_directories(${WEBP_INCLUDE_DIR}) + endif() endif() # tinyxml diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index f499545b6..6855fd6db 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -34,22 +34,24 @@ if(NOT USE_SHARED_GIFLIB) endif() if(ENABLE_WEBP) - set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.") - set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "Build animation utilities.") - set(WEBP_BUILD_CWEBP OFF CACHE BOOL "Build the cwebp command line tool.") - set(WEBP_BUILD_DWEBP OFF CACHE BOOL "Build the dwebp command line tool.") - set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "Build the gif2webp conversion tool.") - set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "Build the img2webp animation tool.") - set(WEBP_BUILD_VWEBP OFF CACHE BOOL "Build the vwebp viewer tool.") - set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "Build the webpinfo command line tool.") - set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "Build the webpmux command line tool.") - - add_subdirectory(libwebp) - - if(NOT USE_SHARED_LIBPNG) - add_dependencies(webp ${PNG_LIBRARY}) - add_dependencies(webpdemux ${PNG_LIBRARY}) - add_dependencies(libwebpmux ${PNG_LIBRARY}) + if(NOT USE_SHARED_WEBP) + set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.") + set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "Build animation utilities.") + set(WEBP_BUILD_CWEBP OFF CACHE BOOL "Build the cwebp command line tool.") + set(WEBP_BUILD_DWEBP OFF CACHE BOOL "Build the dwebp command line tool.") + set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "Build the gif2webp conversion tool.") + set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "Build the img2webp animation tool.") + set(WEBP_BUILD_VWEBP OFF CACHE BOOL "Build the vwebp viewer tool.") + set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "Build the webpinfo command line tool.") + set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "Build the webpmux command line tool.") + + add_subdirectory(libwebp) + + if(NOT USE_SHARED_LIBPNG) + add_dependencies(webp ${PNG_LIBRARY}) + add_dependencies(webpdemux ${PNG_LIBRARY}) + add_dependencies(libwebpmux ${PNG_LIBRARY}) + endif() endif() endif() -- 2.35.1