1diff --git a/CMakeLists.txt b/CMakeLists.txt
2index 87aed2f28f9c..498472ec2a60 100644
3--- a/CMakeLists.txt
4+++ b/CMakeLists.txt
5@@ -76,6 +76,7 @@ option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
6 option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
7 option(USE_SHARED_FREETYPE "Use shared FreeType library" off)
8 option(USE_SHARED_HARFBUZZ "Use shared HarfBuzz library" off)
9+option(USE_SHARED_WEBP "Use your installed copy of webp" off)
10 option(ENABLE_ASEPRITE_EXE "Compile main Aseprite executable" on)
11 option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
12 option(ENABLE_NEWS "Enable the news in Home tab" on)
13@@ -380,7 +381,20 @@ add_subdirectory(laf)
14 # libwebp
15 if(ENABLE_WEBP)
16 # Use libwebp from Skia
17- if(LAF_BACKEND STREQUAL "skia")
18+ if(USE_SHARED_WEBP)
19+ find_library(WEBP_LIBRARY NAMES webp)
20+ find_library(WEBPDEMUX_LIBRARY NAMES webpdemux)
21+ find_library(WEBPMUX_LIBRARY NAMES webpmux)
22+ set(WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY} ${WEBPMUX_LIBRARY})
23+ find_path(WEBP_INCLUDE_DIRS NAMES decode.h PATH_SUFFIXES webp)
24+ find_path(WEBP_INCLUDE_DIRS NAMES decode.h PATH_SUFFIXES webp)
25+ find_path(WEBP_INCLUDE_DIRS NAMES decode.h PATH_SUFFIXES webp)
26+ if(WEBP_LIBRARIES)
27+ set(WEBP_FOUND ON)
28+ else()
29+ set(WEBP_FOUND OFF)
30+ endif()
31+ elseif(LAF_BACKEND STREQUAL "skia")
32 find_library(WEBP_LIBRARIES webp
33 NAMES libwebp # required for Windows
34 PATHS "${SKIA_LIBRARY_DIR}" NO_DEFAULT_PATH)
35diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
36index 1973b134b9f8..f15dba5a7968 100644
37--- a/third_party/CMakeLists.txt
38+++ b/third_party/CMakeLists.txt
39@@ -33,7 +33,7 @@ if(NOT USE_SHARED_GIFLIB)
40 add_subdirectory(giflib)
41 endif()
42
43-if(ENABLE_WEBP AND NOT LAF_BACKEND STREQUAL "skia")
44+if(ENABLE_WEBP AND NOT LAF_BACKEND STREQUAL "skia" AND NOT USE_SHARED_WEBP)
45 set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.")
46 set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "Build animation utilities.")
47 set(WEBP_BUILD_CWEBP OFF CACHE BOOL "Build the cwebp command line tool.")