From a469702fe1bbf93e6bf0e9f7929ab81d96a09bdb Mon Sep 17 00:00:00 2001 From: Osyotr Date: Thu, 14 Nov 2024 14:10:41 +0300 Subject: [PATCH] [libpng] Update to 1.6.44, add feature tools (#42058) Co-authored-by: Kai Pastor --- ports/libpng/fix-export-targets.patch | 17 -------------- ports/libpng/fix-msa-support-for-mips.patch | 2 +- ports/libpng/fix-tools-static.patch | 16 +++++++++++++ ports/libpng/libpng-config.cmake | 12 ++++++++++ ports/libpng/portfile.cmake | 25 +++++++++++++++++---- ports/libpng/usage | 6 ++--- ports/libpng/vcpkg.json | 7 ++++-- versions/baseline.json | 4 ++-- versions/l-/libpng.json | 5 +++++ 9 files changed, 65 insertions(+), 29 deletions(-) delete mode 100644 ports/libpng/fix-export-targets.patch create mode 100644 ports/libpng/fix-tools-static.patch create mode 100644 ports/libpng/libpng-config.cmake diff --git a/ports/libpng/fix-export-targets.patch b/ports/libpng/fix-export-targets.patch deleted file mode 100644 index 1cf66784bc..0000000000 --- a/ports/libpng/fix-export-targets.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index eaba327..dbd31d7 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -1126,6 +1126,12 @@ if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) - install(EXPORT libpng - DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpng - FILE libpng${PNGLIB_ABI_VERSION}.cmake) -+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libpng-config.cmake" " -+ include(CMakeFindDependencyMacro) -+ find_dependency(ZLIB) -+ include(\"\${CMAKE_CURRENT_LIST_DIR}/libpng${PNGLIB_ABI_VERSION}.cmake\") -+ ") -+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libpng-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/libpng") - endif() - - # TODO: Create MSVC import lib for MinGW-compiled shared lib. diff --git a/ports/libpng/fix-msa-support-for-mips.patch b/ports/libpng/fix-msa-support-for-mips.patch index 648de85d81..7b6e6d18b6 100644 --- a/ports/libpng/fix-msa-support-for-mips.patch +++ b/ports/libpng/fix-msa-support-for-mips.patch @@ -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) diff --git a/ports/libpng/fix-tools-static.patch b/ports/libpng/fix-tools-static.patch new file mode 100644 index 0000000000..74ff71dd7b --- /dev/null +++ b/ports/libpng/fix-tools-static.patch @@ -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 $ $) # in vcpkg there's only one + set(PNG_BIN_TARGETS pngfix) + + add_executable(png-fix-itxt ${png_fix_itxt_sources}) diff --git a/ports/libpng/libpng-config.cmake b/ports/libpng/libpng-config.cmake new file mode 100644 index 0000000000..a2644487d4 --- /dev/null +++ b/ports/libpng/libpng-config.cmake @@ -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() diff --git a/ports/libpng/portfile.cmake b/ports/libpng/portfile.cmake index 24eb37e4b9..f653b153d6 100644 --- a/ports/libpng/portfile.cmake +++ b/ports/libpng/portfile.cmake @@ -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}") @@ -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") @@ -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) @@ -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") diff --git a/ports/libpng/usage b/ports/libpng/usage index 19203399c6..628d844ed9 100644 --- a/ports/libpng/usage +++ b/ports/libpng/usage @@ -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) diff --git a/ports/libpng/vcpkg.json b/ports/libpng/vcpkg.json index 10c54485a0..39f2b49951 100644 --- a/ports/libpng/vcpkg.json +++ b/ports/libpng/vcpkg.json @@ -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", @@ -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" } } } diff --git a/versions/baseline.json b/versions/baseline.json index 0a61365589..59746aea0d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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", diff --git a/versions/l-/libpng.json b/versions/l-/libpng.json index f6b5ac36b5..26a79377e5 100644 --- a/versions/l-/libpng.json +++ b/versions/l-/libpng.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "bda480fe3c3cef1113fe8bfdecda127a5b3b2a77", + "version": "1.6.44", + "port-version": 0 + }, { "git-tree": "9c7fd06f1cdd1dfc08b35ca9d6b0ba470cdd2470", "version": "1.6.43",