From 749aac2578a3c04176c0fb44c8eed02d1f93b1a5 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 21 Aug 2026 01:50:01 +0000 Subject: [PATCH 1/4] [libspng] Install pkg-config on Windows Related: https://github.com/microsoft/vcpkg/pull/52891 Related: https://github.com/randy408/libspng/pull/286 This changes libspng to install pkg-config on all platforms matching that installed by Debian. Also fix the declared licenses to match the SPDX expression. Their README says: >## License > >Code is licensed under the BSD 2-clause "Simplified" License. > >The project contains optimizations and test images from libpng, these are licensed under the [PNG Reference Library License version 2](http://www.libpng.org/pub/png/src/libpng-LICENSE.txt). but they don't have a copy of the license. The content under that license is incorporated into the .c so we have to install the whole thing. --- ports/libspng/libspng-pr-286.diff | 60 +++++++++++++++++++++++++++++++ ports/libspng/portfile.cmake | 9 +++-- ports/libspng/vcpkg.json | 3 +- versions/baseline.json | 2 +- versions/l-/libspng.json | 5 +++ 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 ports/libspng/libspng-pr-286.diff diff --git a/ports/libspng/libspng-pr-286.diff b/ports/libspng/libspng-pr-286.diff new file mode 100644 index 00000000000000..ad6605a96bf581 --- /dev/null +++ b/ports/libspng/libspng-pr-286.diff @@ -0,0 +1,60 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index da1917e..2b25abe 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,10 +17,13 @@ option(BUILD_EXAMPLES "Build examples" ON) + include(GNUInstallDirs) + include(CMakePackageConfigHelpers) + +-if(NOT CMAKE_HOST_WIN32) ++find_library(MATH_LIBRARY_PATH m) ++if(MATH_LIBRARY_PATH) + set(MATH_LIBRARY "m") ++ set(LIBS "-lm") + else() + set(MATH_LIBRARY "") ++ set(LIBS "") + endif() + + if(NOT ENABLE_OPT) +@@ -93,16 +96,13 @@ install( + DESTINATION ${config_install_dir} + ) + +-if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) +- set(prefix ${CMAKE_INSTALL_PREFIX}) +- set(exec_prefix ${CMAKE_INSTALL_PREFIX}) +- set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) +- set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) +- set(LIBS "-lm") ++set(prefix ${CMAKE_INSTALL_PREFIX}) ++set(exec_prefix ${CMAKE_INSTALL_PREFIX}) ++set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) ++set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + +- foreach(libname ${spng_TARGETS}) +- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libspng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc @ONLY) ++foreach(libname ${spng_TARGETS}) ++ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/spng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/${libname}.pc @ONLY) + +- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +- endforeach() +-endif() ++ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${libname}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ++endforeach() +diff --git a/cmake/libspng.pc.in b/cmake/spng.pc.in +similarity index 92% +rename from cmake/libspng.pc.in +rename to cmake/spng.pc.in +index 71e0e47..1904c09 100644 +--- a/cmake/libspng.pc.in ++++ b/cmake/spng.pc.in +@@ -3,7 +3,7 @@ exec_prefix=@exec_prefix@ + libdir=@libdir@ + includedir=@includedir@/ + +-Name: lib@libname@ ++Name: @libname@ + Description: PNG decoding and encoding library + Version: @SPNG_VERSION@ + Requires: zlib diff --git a/ports/libspng/portfile.cmake b/ports/libspng/portfile.cmake index 2105ae10820186..256cddc5154334 100644 --- a/ports/libspng/portfile.cmake +++ b/ports/libspng/portfile.cmake @@ -5,7 +5,8 @@ vcpkg_from_github( SHA512 cd729653599ed97f80d19f3048c1b3bc2ac16f922b3465804b1913bc45d9fc8b28b56bc2121fda36e9d3dcdd12612cced5383313b722a5342b613f8781879f1a HEAD_REF master PATCHES - fix-spngconfig-cmake.patch + fix-spngconfig-cmake.patch # https://github.com/randy408/libspng/pull/262/ + libspng-pr-286.diff # https://github.com/randy408/libspng/pull/286/ ) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SPNG_BUILD_STATIC) @@ -30,4 +31,8 @@ vcpkg_fixup_pkgconfig() file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +vcpkg_install_copyright( + FILE_LIST + "${SOURCE_PATH}/LICENSE" + "${SOURCE_PATH}/spng/spng.c" +) diff --git a/ports/libspng/vcpkg.json b/ports/libspng/vcpkg.json index ce125080115d04..352da121ab1b8c 100644 --- a/ports/libspng/vcpkg.json +++ b/ports/libspng/vcpkg.json @@ -1,9 +1,10 @@ { "name": "libspng", "version": "0.7.4", + "port-version": 1, "description": "Simple, modern libpng alternative", "homepage": "https://github.com/randy408/libspng", - "license": "BSD-2-Clause", + "license": "BSD-2-Clause AND libpng-2.0", "dependencies": [ { "name": "vcpkg-cmake", diff --git a/versions/baseline.json b/versions/baseline.json index 6d8c85ac47a88b..197e3837195109 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5746,7 +5746,7 @@ }, "libspng": { "baseline": "0.7.4", - "port-version": 0 + "port-version": 1 }, "libsquish": { "baseline": "1.15", diff --git a/versions/l-/libspng.json b/versions/l-/libspng.json index 5c77ab884fea96..571d192de67aea 100644 --- a/versions/l-/libspng.json +++ b/versions/l-/libspng.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "565331d447f21f16499baa9fd120b5f45a62b6e1", + "version": "0.7.4", + "port-version": 1 + }, { "git-tree": "ed674df56d8b39d76443c7db3ae893c08394bf9c", "version": "0.7.4", From e96c049c1ae79d73e046df1f9fa8e339db6bd2c8 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 21 Aug 2026 12:59:51 -0700 Subject: [PATCH 2/4] Search CMAKE_C_IMPLICIT_LINK_DIRECTORIES for libm as suggested by @dg0yt --- ports/libspng/libspng-pr-286.diff | 4 ++-- versions/l-/libspng.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/libspng/libspng-pr-286.diff b/ports/libspng/libspng-pr-286.diff index ad6605a96bf581..cd0aa9fc1d22a1 100644 --- a/ports/libspng/libspng-pr-286.diff +++ b/ports/libspng/libspng-pr-286.diff @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index da1917e..2b25abe 100644 +index da1917e..d385e46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,13 @@ option(BUILD_EXAMPLES "Build examples" ON) @@ -7,7 +7,7 @@ index da1917e..2b25abe 100644 include(CMakePackageConfigHelpers) -if(NOT CMAKE_HOST_WIN32) -+find_library(MATH_LIBRARY_PATH m) ++find_library(MATH_LIBRARY_PATH NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +if(MATH_LIBRARY_PATH) set(MATH_LIBRARY "m") + set(LIBS "-lm") diff --git a/versions/l-/libspng.json b/versions/l-/libspng.json index 571d192de67aea..6a6fc49557847e 100644 --- a/versions/l-/libspng.json +++ b/versions/l-/libspng.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "565331d447f21f16499baa9fd120b5f45a62b6e1", + "git-tree": "c8f1411791d9240cb14211ed0674dc9a9d9ba444", "version": "0.7.4", "port-version": 1 }, From 566333f597293248815c56a2ef65b249ed2d2ff3 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Fri, 21 Aug 2026 17:23:21 -0700 Subject: [PATCH 3/4] Add usage. --- ports/libspng/portfile.cmake | 8 +++++++- ports/libspng/{usage => usage.in} | 7 ++++++- versions/l-/libspng.json | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) rename ports/libspng/{usage => usage.in} (50%) diff --git a/ports/libspng/portfile.cmake b/ports/libspng/portfile.cmake index 256cddc5154334..7dcd4e55c80e9b 100644 --- a/ports/libspng/portfile.cmake +++ b/ports/libspng/portfile.cmake @@ -29,7 +29,13 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") vcpkg_copy_pdbs() vcpkg_fixup_pkgconfig() -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(PC_NAME "spng") +else() + set(PC_NAME "spng_static") +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/usage.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY) vcpkg_install_copyright( FILE_LIST diff --git a/ports/libspng/usage b/ports/libspng/usage.in similarity index 50% rename from ports/libspng/usage rename to ports/libspng/usage.in index bc69e6a0448686..fb16d4c44a932c 100644 --- a/ports/libspng/usage +++ b/ports/libspng/usage.in @@ -1,4 +1,9 @@ libspng provides CMake targets: find_package(SPNG CONFIG REQUIRED) - target_link_libraries(main PRIVATE $,spng::spng,spng::spng_static>) \ No newline at end of file + target_link_libraries(main PRIVATE $,spng::spng,spng::spng_static>) + +libspng provides pkg-config modules: + + # PNG decoding and encoding library + @PC_NAME@ diff --git a/versions/l-/libspng.json b/versions/l-/libspng.json index 6a6fc49557847e..003b6a67f748e3 100644 --- a/versions/l-/libspng.json +++ b/versions/l-/libspng.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "c8f1411791d9240cb14211ed0674dc9a9d9ba444", + "git-tree": "352379bea2f44a00bed76067dd65c1e644e898c0", "version": "0.7.4", "port-version": 1 }, From bfda6422d2b39f783c3546119c562396589ee113 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 28 Aug 2026 00:30:59 -0400 Subject: [PATCH 4/4] Force always using one pkgconfig name. Imbue static-ness into the installed header for direct-include customers. --- ports/libspng/portfile.cmake | 22 +++++++++++++++++----- ports/libspng/{usage.in => usage} | 2 +- versions/l-/libspng.json | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) rename ports/libspng/{usage.in => usage} (94%) diff --git a/ports/libspng/portfile.cmake b/ports/libspng/portfile.cmake index 7dcd4e55c80e9b..e43e76bafc1b7a 100644 --- a/ports/libspng/portfile.cmake +++ b/ports/libspng/portfile.cmake @@ -27,15 +27,27 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/spng PACKAGE_NAME spng) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") vcpkg_copy_pdbs() -vcpkg_fixup_pkgconfig() -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(PC_NAME "spng") +if (VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/spng.h" "#define SPNG_H" "#define SPNG_H\n#define SPNG_STATIC") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc" "Name: spng_static" "Name: spng") + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng.pc") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng.pc") + if (NOT VCPKG_BUILD_TYPE) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc" "Name: spng_static" "Name: spng") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng.pc") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng.pc") + endif() else() - set(PC_NAME "spng_static") + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc") + if (NOT VCPKG_BUILD_TYPE) + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc") + endif() endif() -configure_file("${CMAKE_CURRENT_LIST_DIR}/usage.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY) +vcpkg_fixup_pkgconfig() + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") vcpkg_install_copyright( FILE_LIST diff --git a/ports/libspng/usage.in b/ports/libspng/usage similarity index 94% rename from ports/libspng/usage.in rename to ports/libspng/usage index fb16d4c44a932c..c2e168f671f206 100644 --- a/ports/libspng/usage.in +++ b/ports/libspng/usage @@ -6,4 +6,4 @@ libspng provides CMake targets: libspng provides pkg-config modules: # PNG decoding and encoding library - @PC_NAME@ + spng diff --git a/versions/l-/libspng.json b/versions/l-/libspng.json index 003b6a67f748e3..2999beeb66595c 100644 --- a/versions/l-/libspng.json +++ b/versions/l-/libspng.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "352379bea2f44a00bed76067dd65c1e644e898c0", + "git-tree": "c18b7942b3efca64c49cf7598a0099db296728d4", "version": "0.7.4", "port-version": 1 },