Skip to content

Commit

Permalink
[libwebp] Update to 1.3.0, misc changes (#29165)
Browse files Browse the repository at this point in the history
* [libwebp] Update to 1.3.0

* Fix [core] on x64-osx

* Fix features and dependencies

* Cleanup tool installation

* Usage

* Lift restriction for vwebp tool

* [mapnik] Fix libwebp

* [qt5-imageformats] Use libwebp pc files

* Revert "Lift restriction for vwebp tool"

This reverts commit 42e0273.

* [gdal] Use upstream WebP config

* Revert no longer necessary changes to mapnik.

* Remove unnecessary patch that git checkout didn't remove.

---------

Co-authored-by: Billy Robert O'Neal III <[email protected]>
  • Loading branch information
dg0yt and BillyONeal authored Jan 27, 2023
1 parent 6b3a1a2 commit 91dd61b
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 202 deletions.
6 changes: 6 additions & 0 deletions ports/gdal/cmake-project-include.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if(GDAL_USE_WEBP)
find_package(WebP CONFIG REQUIRED)
add_library(WEBP::WebP ALIAS WebP::webp)
set(GDAL_CHECK_PACKAGE_WebP_NAMES WebP CACHE INTERNAL "vcpkg")
set(GDAL_CHECK_PACKAGE_WebP_TARGETS WebP::webp CACHE INTERNAL "vcpkg")
endif()
1 change: 1 addition & 0 deletions ports/gdal/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ vcpkg_cmake_configure(
-DGDAL_CHECK_PACKAGE_QHULL_NAMES=Qhull
"-DGDAL_CHECK_PACKAGE_QHULL_TARGETS=${qhull_target}"
"-DQHULL_LIBRARY=${qhull_target}"
-DCMAKE_PROJECT_INCLUDE="${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake"
OPTIONS_DEBUG
-DBUILD_APPS=OFF
MAYBE_UNUSED_VARIABLES
Expand Down
2 changes: 1 addition & 1 deletion ports/gdal/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gdal",
"version-semver": "3.6.2",
"port-version": 1,
"port-version": 2,
"description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data",
"homepage": "https://gdal.org",
"license": null,
Expand Down
20 changes: 6 additions & 14 deletions ports/libwebp/0002-cmake-config.patch
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
diff --git a/cmake/WebPConfig.cmake.in b/cmake/WebPConfig.cmake.in
index 822fc59..fb31829 100644
index f334739..43f10e0 100644
--- a/cmake/WebPConfig.cmake.in
+++ b/cmake/WebPConfig.cmake.in
@@ -5,7 +5,19 @@ set(WEBP_VERSION ${WebP_VERSION})
@@ -12,5 +12,12 @@ include ("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

+include(CMakeFindDependencyMacro)
+find_dependency(Threads)
include ("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

-set(WebP_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
+get_filename_component(_vcpkg_libwebp_root "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
+set(WebP_INCLUDE_DIRS "${_vcpkg_libwebp_root}/include")
set(WebP_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set(WEBP_INCLUDE_DIRS ${WebP_INCLUDE_DIRS})
-set(WebP_LIBRARIES "@INSTALLED_LIBRARIES@")
+set(WebP_LIBRARIES "")
+include(SelectLibraryConfigurations)
+foreach(_vcpkg_libwebp_lib IN ITEMS @INSTALLED_LIBRARIES@)
+ string(REPLACE "libwebpmux" "webpmux" _vcpkg_libwebp_lib "${_vcpkg_libwebp_lib}") # offical OUTPUT_NAME
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_RELEASE NAMES ${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${_vcpkg_libwebp_root}/lib" NO_DEFAULT_PATH)
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_DEBUG NAMES ${_vcpkg_libwebp_lib}d ${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${_vcpkg_libwebp_root}/debug/lib" NO_DEFAULT_PATH)
+foreach(_vcpkg_libwebp_lib IN ITEMS @INSTALLED_LIBRARIES@ sharpyuv)
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_RELEASE NAMES ${_vcpkg_libwebp_lib} lib${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${VCPKG_IMPORT_PREFIX}/lib" NO_DEFAULT_PATH)
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_DEBUG NAMES ${_vcpkg_libwebp_lib}d lib${_vcpkg_libwebp_lib}d ${_vcpkg_libwebp_lib} lib${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${VCPKG_IMPORT_PREFIX}/debug/lib" NO_DEFAULT_PATH)
+ select_library_configurations(_vcpkg_${_vcpkg_libwebp_lib})
+ list(APPEND WebP_LIBRARIES ${_vcpkg_${_vcpkg_libwebp_lib}_LIBRARIES})
+endforeach()
set(WEBP_LIBRARIES "${WebP_LIBRARIES}")
+unset(_vcpkg_libwebp_root)
13 changes: 0 additions & 13 deletions ports/libwebp/0003-fix-tool-dependencies.patch

This file was deleted.

38 changes: 23 additions & 15 deletions ports/libwebp/0008-sdl.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91a4ba8..10a3f4d 100644
index 0a5af42..636eef7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -624,11 +624,12 @@ endif()
@@ -635,16 +635,22 @@ if(WEBP_BUILD_EXTRAS)
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL_INCLUDE_DIR})
set(WEBP_HAVE_SDL 1)
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
+ target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H)
+ if(WIN32)
+ target_link_libraries(vwebp_sdl dxguid winmm)
+ endif()
endif()
endif()

if(WEBP_BUILD_WEBP_JS)
# wasm2js does not support SIMD.
Expand All @@ -11,27 +20,26 @@ index 91a4ba8..10a3f4d 100644
# JavaScript version
add_executable(webp_js ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
- target_link_libraries(webp_js webpdecoder SDL)
- target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries(webp_js webpdecoder ${SDL_LIBRARY})
+ target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${SDL_INCLUDE_DIR})
target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_include_directories(webp_js PRIVATE ${SDL_INCLUDE_DIR})
set(WEBP_HAVE_SDL 1)
set_target_properties(
webp_js
@@ -641,14 +642,14 @@ if(WEBP_BUILD_WEBP_JS)
@@ -653,12 +659,15 @@ if(WEBP_BUILD_WEBP_JS)
-sEXPORTED_RUNTIME_METHODS=cwrap")
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
+ target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_JUST_SDL_H)
endif()

# WASM version
add_executable(webp_wasm ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
- target_link_libraries(webp_wasm webpdecoder SDL)
- target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries(webp_wasm webpdecoder ${SDL_LIBRARY})
+ target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${SDL_INCLUDE_DIR})
target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_include_directories(webp_wasm PRIVATE ${SDL_INCLUDE_DIR})
+ target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_JUST_SDL_H)
set_target_properties(
webp_wasm
PROPERTIES LINK_FLAGS "-s WASM=1 \
-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \
-s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
- target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
+ target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL WEBP_HAVE_JUST_SDL_H)

target_compile_definitions(webpdspdecode PUBLIC EMSCRIPTEN)
endif()
PROPERTIES LINK_FLAGS "-sWASM=1 \
13 changes: 0 additions & 13 deletions ports/libwebp/0009-glut.patch

This file was deleted.

73 changes: 16 additions & 57 deletions ports/libwebp/0010-fix_build.patch
Original file line number Diff line number Diff line change
@@ -1,62 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 43742c7f7..44b035ebb 100644
index 636eef7..80361f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -248,6 +248,9 @@ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
if(MSVC)
# avoid security warnings for e.g., fopen() used in the examples.
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ if(BUILD_SHARED_LIBS)
+ add_definitions("-DWEBP_DLL")
+ endif()
else()
add_definitions(-Wall)
@@ -452,6 +452,7 @@ endif()
if(WEBP_BUILD_ANIM_UTILS
OR WEBP_BUILD_CWEBP
OR WEBP_BUILD_DWEBP
+ OR WEBP_BUILD_EXTRAS
OR WEBP_BUILD_GIF2WEBP
OR WEBP_BUILD_IMG2WEBP
OR WEBP_BUILD_VWEBP
@@ -488,6 +489,8 @@ if(WEBP_BUILD_ANIM_UTILS
TARGET exampleutil imageioutil imagedec imageenc
PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/src)
+ target_include_directories(imagedec PRIVATE ${WEBP_DEP_IMG_INCLUDE_DIRS})
+ target_include_directories(imageenc PRIVATE ${WEBP_DEP_IMG_INCLUDE_DIRS})
endif()
@@ -635,8 +638,12 @@ if(WEBP_BUILD_EXTRAS)
# webp_quality
add_executable(webp_quality ${WEBP_QUALITY_SRCS})
target_link_libraries(webp_quality exampleutil imagedec extras)
+ if(BUILD_SHARED_LIBS)
+ target_link_libraries(webp_quality webpdspdecode)
+ endif()
target_include_directories(webp_quality
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR})

# vwebp_sdl
@@ -651,6 +658,10 @@ if(WEBP_BUILD_EXTRAS)
${SDL_INCLUDE_DIR})
set(WEBP_HAVE_SDL 1)
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
+ if (MSVC)
+ target_link_libraries(vwebp_sdl dxguid winmm)
+ endif()
+ target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H)
endif()
endif()

@@ -669,7 +680,7 @@ if(WEBP_BUILD_WEBP_JS)
-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \
-s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
- target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
+ target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL WEBP_HAVE_JUST_SDL_H)
endif()

# WASM version
diff --git a/src/webp/types.h b/src/webp/types.h
index 47f7f2b00..a7a706590 100644
--- a/src/webp/types.h
+++ b/src/webp/types.h
@@ -39,7 +39,9 @@ typedef long long int int64_t;
#ifndef WEBP_EXTERN
// This explicitly marks library functions and allows for changing the
// signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(_MSC_VER) && defined(WEBP_DLL)
+# define WEBP_EXTERN extern __declspec(dllexport)
+# elif defined(__GNUC__) && __GNUC__ >= 4
# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
# else
# define WEBP_EXTERN extern
if(WEBP_BUILD_DWEBP)
66 changes: 30 additions & 36 deletions ports/libwebp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO webmproject/libwebp
REF v1.2.4
SHA512 85c7d2bd1697ed6f18d565056d0105edd63697f144d2c935e9c0563ff09f4acc56d4ac509668f920e8d5dc3c74b53a42f65265fc758fed173cb2168c4d6a551c
REF "v${VERSION}"
SHA512 96f73ba6caee4e65535721ca80faa976f51930eb6693e4499593e896f15269dfb756defabe7afbefb3bd2ef90afc0c95e3ba49d8020bc18589c34e9e680d955a
HEAD_REF master
PATCHES
0002-cmake-config.patch
0003-fix-tool-dependencies.patch
0007-fix-arm-build.patch
0008-sdl.patch
0009-glut.patch
0010-fix_build.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
anim WEBP_BUILD_ANIM_UTILS
cwebp WEBP_BUILD_CWEBP
dwebp WEBP_BUILD_DWEBP
extras WEBP_BUILD_EXTRAS
gif2webp WEBP_BUILD_GIF2WEBP
img2webp WEBP_BUILD_IMG2WEBP
vwebp WEBP_BUILD_VWEBP
vwebp-sdl WEBP_HAVE_SDL
info WEBP_BUILD_WEBPINFO
libwebpmux WEBP_BUILD_LIBWEBPMUX
mux WEBP_BUILD_WEBPMUX
extras WEBP_BUILD_EXTRAS
nearlossless WEBP_NEAR_LOSSLESS
simd WEBP_ENABLE_SIMD
cwebp WEBP_BUILD_CWEBP
dwebp WEBP_BUILD_DWEBP
swap16bitcsp WEBP_ENABLE_SWAP_16BIT_CSP
unicode WEBP_UNICODE
libwebpmux WEBP_BUILD_LIBWEBPMUX
vwebp WEBP_BUILD_VWEBP
vwebp-sdl CMAKE_REQUIRE_FIND_PACKAGE_SDL
INVERTED_FEATURES
vwebp-sdl CMAKE_DISABLE_FIND_PACKAGE_SDL
)

if(VCPKG_TARGET_IS_OSX)
if("vwebp" IN_LIST FEATURES OR "extras" IN_LIST FEATURES)
message(FATAL_ERROR "Due to GLUT Framework problems with CMake, at the moment it's not possible to build VWebP or extras on Mac!")
endif()
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DWEBP_BUILD_ANIM_UTILS=OFF
-DWEBP_BUILD_CWEBP=OFF
-DWEBP_BUILD_DWEBP=OFF
-DWEBP_BUILD_EXTRAS=OFF
-DWEBP_BUILD_GIF2WEBP=OFF
-DWEBP_BUILD_IMG2WEBP=OFF
-DWEBP_BUILD_VWEBP=OFF
-DWEBP_BUILD_WEBPINFO=OFF
-DWEBP_BUILD_WEBPMUX=OFF
MAYBE_UNUSED_VARIABLES
CMAKE_DISABLE_FIND_PACKAGE_SDL
CMAKE_REQUIRE_FIND_PACKAGE_SDL
)

vcpkg_cmake_install()
Expand All @@ -54,28 +61,15 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_fixup_pkgconfig()

set(BIN_NAMES get_disto gif2webp img2webp vwebp vwebp_sdl webpinfo webpmux webp_quality cwebp dwebp)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/webp/")
foreach(tool ${BIN_NAMES})
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/bin/${tool}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/${tool}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
endif()

vcpkg_list(SET BIN_NAMES)
foreach(tool IN ITEMS get_disto gif2webp img2webp vwebp vwebp_sdl webpinfo webpmux webp_quality cwebp dwebp)
if(EXISTS "${CURRENT_PACKAGES_DIR}/bin/${tool}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/${tool}${VCPKG_TARGET_EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/webp/${tool}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
vcpkg_list(APPEND BIN_NAMES "${tool}")
endif()
endforeach()
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/webp")

#No tools
file(GLOB_RECURSE RESULT "${CURRENT_PACKAGES_DIR}/tools/")
list(LENGTH RESULT RES_LEN)
if(RES_LEN EQUAL 0)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/")
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
if(NOT BIN_NAMES STREQUAL "")
vcpkg_copy_tools(TOOL_NAMES ${BIN_NAMES} AUTO_CLEAN)
endif()

file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
9 changes: 9 additions & 0 deletions ports/libwebp/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
libwebp provides CMake targets:

find_package(WebP CONFIG REQUIRED)
# basic usage
target_link_libraries(main PRIVATE WebP::webp WebP::webpdecoder WebP::webpdemux)
# for manipulating the WebP graphics format container (port feature libwebpmux)
target_link_libraries(main PRIVATE WebP::libwebpmux)
# for sharp RGB to YUV conversion
target_link_libraries(main PRIVATE WebP::sharpyuv)
Loading

0 comments on commit 91dd61b

Please sign in to comment.