diff --git a/.gitmodules b/.gitmodules index e07ff32710..3cdf660ac1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -38,3 +38,7 @@ path = src/stc/lexilla url = https://github.com/wxWidgets/lexilla.git branch = wx +[submodule "3rdparty/libwebp"] + path = 3rdparty/libwebp + url = https://github.com/wxWidgets/libwebp.git + branch = wx diff --git a/3rdparty/libwebp b/3rdparty/libwebp new file mode 160000 index 0000000000..406ef4e955 --- /dev/null +++ b/3rdparty/libwebp @@ -0,0 +1 @@ +Subproject commit 406ef4e95591e6e0083a8f8e084a0936535f8b44 diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 53615a14f3..db8f1f53cb 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -359,14 +359,6 @@ if(wxUSE_LIBLZMA) endif() endif() -if(wxUSE_LIBWEBP) - find_package(WebP) # TODO: select specific components as soon as upstream-supplied WebPConfig.cmake supports it - if (NOT ${WebP_FOUND}) - message(WARNING "libwebp not found, WebP file format will not be supported") - wx_option_force_value(wxUSE_LIBWEBP OFF) - endif() -endif() - if (wxUSE_WEBREQUEST) if(wxUSE_WEBREQUEST_CURL) find_package(CURL) diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 04d830d7de..6db5447d96 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -21,7 +21,7 @@ endif() # Define third party libraries set(LIBS_THIRDPARTY regex zlib expat) if(wxUSE_GUI) - list(APPEND LIBS_THIRDPARTY jpeg png tiff nanosvg) + list(APPEND LIBS_THIRDPARTY jpeg png tiff nanosvg webp) endif() foreach(LIB IN LISTS LIBS_THIRDPARTY) include(${LIB}.cmake) diff --git a/build/cmake/lib/webp.cmake b/build/cmake/lib/webp.cmake new file mode 100644 index 0000000000..690ec2c587 --- /dev/null +++ b/build/cmake/lib/webp.cmake @@ -0,0 +1,53 @@ +############################################################################# +# Name: build/cmake/lib/webp.cmake +# Purpose: Use external or internal libwebp +# Author: +# Created: 2025-01-31 +# Copyright: (c) 2025 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +if(wxUSE_LIBWEBP STREQUAL "builtin") + set(WEBP_ROOT "${wxSOURCE_DIR}/3rdparty/libwebp") + set(WEBP_BUILD_ROOT "${CMAKE_CURRENT_BINARY_DIR}/webp-build") + + # static library + set(WEBP_LINK_STATIC ON) + # disable tools + set(WEBP_BUILD_ANIM_UTILS OFF) + set(WEBP_BUILD_CWEBP OFF) + set(WEBP_BUILD_DWEBP OFF) + set(WEBP_BUILD_GIF2WEBP OFF) + set(WEBP_BUILD_IMG2WEBP OFF) + set(WEBP_BUILD_VWEBP OFF) + set(WEBP_BUILD_WEBPINFO OFF) + set(WEBP_BUILD_WEBPMUX OFF) + set(WEBP_BUILD_EXTRAS OFF) + set(WEBP_BUILD_WEBP_JS OFF) + set(WEBP_BUILD_FUZZTEST OFF) + + add_subdirectory("${WEBP_ROOT}" "${WEBP_BUILD_ROOT}" EXCLUDE_FROM_ALL) + + mark_as_advanced(WEBP_BITTRACE) + mark_as_advanced(WEBP_BUILD_LIBWEBPMUX) + mark_as_advanced(WEBP_ENABLE_SIMD) + mark_as_advanced(WEBP_ENABLE_SWAP_16BIT_CSP) + mark_as_advanced(WEBP_ENABLE_WUNUSED_RESULT) + mark_as_advanced(WEBP_LINK_STATIC) + mark_as_advanced(WEBP_NEAR_LOSSLESS) + mark_as_advanced(WEBP_UNICODE) + mark_as_advanced(WEBP_USE_THREAD) + + get_property(webpTargets DIRECTORY "${WEBP_ROOT}" PROPERTY BUILDSYSTEM_TARGETS) + foreach(target_name IN LISTS webpTargets) + set_target_properties(${target_name} PROPERTIES + FOLDER "Third Party Libraries/WebP" + OUTPUT_NAME "${target_name}" + ) + endforeach() + + set(WebP_LIBRARIES webp webpdemux) + +elseif(wxUSE_LIBWEBP) + find_package(WebP REQUIRED) +endif() diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 5443c1d781..d34f093b78 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -129,8 +129,7 @@ wx_add_thirdparty_library(wxUSE_EXPAT EXPAT "use expat for XML parsing" DEFAULT_ wx_add_thirdparty_library(wxUSE_LIBJPEG JPEG "use libjpeg (JPEG file format)") wx_add_thirdparty_library(wxUSE_LIBPNG PNG "use libpng (PNG image format)") wx_add_thirdparty_library(wxUSE_LIBTIFF TIFF "use libtiff (TIFF file format)") -wx_option(wxUSE_LIBWEBP "use libwebp (WebP file format)" OFF) -set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBWEBP "use libwebp (WebP file format)") +wx_add_thirdparty_library(wxUSE_LIBWEBP WebP "use libwebp (WebP file format)") wx_add_thirdparty_library(wxUSE_NANOSVG NanoSVG "use NanoSVG for rasterizing SVG" DEFAULT builtin) wx_option(wxUSE_LIBLZMA "use LZMA compression" OFF) set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBLZMA "use liblzma for LZMA compression")