Skip to content

Commit

Permalink
[libpng] Update to 1.6.44, add feature tools (#42058)
Browse files Browse the repository at this point in the history
Co-authored-by: Kai Pastor <[email protected]>
  • Loading branch information
Osyotr and dg0yt authored Nov 14, 2024
1 parent 91302ce commit a469702
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 29 deletions.
17 changes: 0 additions & 17 deletions ports/libpng/fix-export-targets.patch

This file was deleted.

2 changes: 1 addition & 1 deletion ports/libpng/fix-msa-support-for-mips.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ index 3857b82..4c68989 100644
@@ -221,8 +221,8 @@ endif()

# Set definitions and sources for MIPS.
if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
- set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
- set(PNG_MIPS_MSA "on"
+ set(PNG_MIPS_MSA_POSSIBLE_VALUES on off check)
Expand Down
16 changes: 16 additions & 0 deletions ports/libpng/fix-tools-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3857b82..4c68989 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -963,9 +963,9 @@
FILES ${PNGSUITE_PNGS})
endif()

-if(PNG_SHARED AND PNG_TOOLS)
+if(PNG_TOOLS)
add_executable(pngfix ${pngfix_sources})
- target_link_libraries(pngfix PRIVATE png_shared)
+ target_link_libraries(pngfix PRIVATE $<TARGET_NAME_IF_EXISTS:png_shared> $<TARGET_NAME_IF_EXISTS:png_static>) # in vcpkg there's only one
set(PNG_BIN_TARGETS pngfix)

add_executable(png-fix-itxt ${png_fix_itxt_sources})
12 changes: 12 additions & 0 deletions ports/libpng/libpng-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage)
message(WARNING "find_package(libpng) is deprecated.\n${usage}")

include(CMakeFindDependencyMacro)
find_dependency(PNG CONFIG)

if(NOT TARGET png_shared)
add_library(png_shared ALIAS PNG::PNG)
endif()
if(NOT TARGET png_static)
add_library(png_static ALIAS PNG::PNG)
endif()
25 changes: 21 additions & 4 deletions ports/libpng/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if ("apng" IN_LIST FEATURES)
vcpkg_download_distfile(LIBPNG_APNG_PATCH_ARCHIVE
URLS "https://downloads.sourceforge.net/project/libpng-apng/libpng16/${VERSION}/${LIBPNG_APNG_PATCH_NAME}.gz"
FILENAME "${LIBPNG_APNG_PATCH_NAME}.gz"
SHA512 a724f7de486920cb119818f7172fb589bc2c3c1cc1f81bb5c4da0609ab108ef9ef7406cf689a20bc4e8da69647847f550ed497b3fa99a10539e9a0abf492c053
SHA512 ea89018a02ed171b82af9644ec2ff658c8a288e99b5470c7a3fd142c6fa95bbe19cd34c4fae654bc8783b41c3eb3b2d15b486bda3b0307ec3090e99f34465e20
)
set(LIBPNG_APNG_PATCH_PATH "${CURRENT_BUILDTREES_DIR}/src/${LIBPNG_APNG_PATCH_NAME}")
if (NOT EXISTS "${LIBPNG_APNG_PATCH_PATH}")
Expand All @@ -30,20 +30,28 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO glennrp/libpng
REF v${VERSION}
SHA512 3bb2a7b73113be42b09c2116e6c6f5a7ddb4e2ab06e0b13e10b7314acdccc4bb624ff602e16140c0484f6cde80efa190296226be3da195c6926819f07c723c12
SHA512 c023bc7dcf3d0ea045a63204f2266b2c53b601b99d7c5f5a7b547bc9a48b205a277f699eefa47f136483f495175b226527097cd447d6b0fbceb029eb43638f63
HEAD_REF master
PATCHES
"${LIBPNG_APNG_PATCH_PATH}"
cmake.patch
fix-export-targets.patch
libm.patch
pkgconfig.patch
fix-msa-support-for-mips.patch
fix-tools-static.patch
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PNG_SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" PNG_STATIC)

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools PNG_TOOLS
INVERTED_FEATURES
tools SKIP_INSTALL_PROGRAMS
)

vcpkg_list(SET LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION)
if(VCPKG_TARGET_IS_IOS)
vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_HARDWARE_OPTIMIZATIONS=OFF")
Expand Down Expand Up @@ -77,18 +85,22 @@ vcpkg_cmake_configure(
-DPNG_SHARED=${PNG_SHARED}
-DPNG_FRAMEWORK=OFF
-DPNG_TESTS=OFF
-DSKIP_INSTALL_PROGRAMS=ON
-DSKIP_INSTALL_EXECUTABLES=ON
-DSKIP_INSTALL_FILES=OFF
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
MAYBE_UNUSED_VARIABLES
PNG_ARM_NEON
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME png CONFIG_PATH lib/cmake/PNG)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/libpng)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/png")

# unofficial legacy usage
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/libpng-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

vcpkg_fixup_pkgconfig()
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
if(NOT VCPKG_BUILD_TYPE)
Expand All @@ -103,6 +115,11 @@ endif()
file(INSTALL "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/pkgconfig" RENAME "libpng.pc")

vcpkg_copy_pdbs()

if(PNG_TOOLS)
vcpkg_copy_tools(TOOL_NAMES "pngfix" "png-fix-itxt" AUTO_CLEAN)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
6 changes: 3 additions & 3 deletions ports/libpng/usage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The package libpng is compatible with built-in CMake targets:
libpng provides CMake targets:

find_package(PNG REQUIRED)
target_link_libraries(main PRIVATE PNG::PNG)
find_package(PNG REQUIRED)
target_link_libraries(main PRIVATE PNG::PNG)
7 changes: 5 additions & 2 deletions ports/libpng/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "libpng",
"version": "1.6.43",
"port-version": 3,
"version": "1.6.44",
"description": "libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files",
"homepage": "https://github.com/glennrp/libpng",
"license": "libpng-2.0",
Expand All @@ -24,6 +23,10 @@
"features": {
"apng": {
"description": "This is backward compatible with the regular libpng, both in library usage and format"
},
"tools": {
"description": "Build the libpng tools",
"supports": "!android & !ios"
}
}
}
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4969,8 +4969,8 @@
"port-version": 1
},
"libpng": {
"baseline": "1.6.43",
"port-version": 3
"baseline": "1.6.44",
"port-version": 0
},
"libpopt": {
"baseline": "1.16",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libpng.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bda480fe3c3cef1113fe8bfdecda127a5b3b2a77",
"version": "1.6.44",
"port-version": 0
},
{
"git-tree": "9c7fd06f1cdd1dfc08b35ca9d6b0ba470cdd2470",
"version": "1.6.43",
Expand Down

0 comments on commit a469702

Please sign in to comment.