Skip to content

[libspng] Install pkg-config on Windows - #53510

Merged
Billy O'Neal (BillyONeal) merged 5 commits into
microsoft:masterfrom
BillyONeal:libspng-pkgconfig
Aug 28, 2026
Merged

Billy O'Neal (BillyONeal) merged 5 commits into
microsoft:masterfrom
BillyONeal:libspng-pkgconfig

Conversation

@BillyONeal

Copy link
Copy Markdown
Member

Related: #52891
Related: randy408/libspng#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.

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.

Related: microsoft#52891
Related: randy408/libspng#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.
Comment thread ports/libspng/libspng-pr-286.diff Outdated
- 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which names did this install, and which names does it install now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kai Pastor (@dg0yt) libspng has two build systems. A meson one and a CMake one. The meson one installs spng.pc, which is also the name used in the Debian package and expected by libjpeg-turbo. This CMake one installs libspng.pc or libspng_static.pc. This PR resolves the conflict in favor of their meson build system on the grounds that that is what I see downstream customers expecting.

@BillyONeal

Billy O'Neal (BillyONeal) commented Aug 21, 2026 •

Copy link
Copy Markdown
Member Author

GPT 5.6 Sol reports (lest you think I would exempt myself):

  • The new pkg-config generation still derives the module filename from the CMake target name. On static triplets the only target is spng_static, so libspng-pr-286.diff installs spng_static.pc, not the canonical spng.pc expected by libjpeg-turbo and installed by libspng's Meson build. Please make the static package expose module spng while retaining the correct static library link name.

I agree this is suboptimal but appears to be an explicit decision upstream has made so I think my hands are tied. The meson build system we are trying to match does not have the contrivance to build both static and dynamic in the same build like the CMake one has.

  • The custom usage documents only CMake. Since this PR adds a supported pkg-config integration, add the spng module to the usage text after correcting its static-triplet name.

Stand by...

@BillyONeal

Copy link
Copy Markdown
Member Author

I agree this is suboptimal but appears to be an explicit decision upstream has made so I think my hands are tied. The meson build system we are trying to match does not have the contrivance to build both static and dynamic in the same build like the CMake one has.

On the other hand Debian is only ever installing the dynamic one. Maybe we should fix it up to always not have _static since that becomes obnoxious for downstreams.

@dg0yt

Kai Pastor (dg0yt) commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

We could simply always install the "official basename" (spng) as a proxy for the actual name (libspng...), forwarding to the actual name via Requires:.

But in the end upstream needs to cleanup.

Comment thread ports/libspng/usage.in Outdated
libspng provides pkg-config modules:

# PNG decoding and encoding library
@PC_NAME@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is the harmful pattern:
The instruction seen in static triplets is a recipe for failure in dynamic triplets.

There is really no other reasonable way: always install a basename file, at least as a proxy for the actual _static file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was on the fence about going this far because it seems to explicitly regard what upstream is doing but there's an argument that upstream's behavior is unreasonable.

@BillyONeal

Copy link
Copy Markdown
Member Author

GPT also reported:

  • On Windows static triplets, spng_static.pc does not publish SPNG_STATIC, so pkg-config consumers compile against dllimport declarations and fail to link. Match upstream Meson's static compile flags by adding -DSPNG_STATIC to Cflags.
  • Static installations expose only spng_static.pc; consumers requesting the canonical spng module cannot find it. Install spng.pc for both linkage modes while retaining spng_static in Libs when appropriate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


vcpkg_copy_pdbs()

if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future maintenance, it would be nice to jot down what finding / error led to this fix. To my understanding, it is that libspng upstream is inconsistent with the naming of its pkg-config files: in meson it's always spng but in cmake it can be libspng or libspng_static`. And that this inconsistency causes pain for downstream consumers, so you unify them here.

though the PR also captures this, so the info is there. No blockers.

@BillyONeal
Billy O'Neal (BillyONeal) merged commit 7ed6d1a into microsoft:master Aug 28, 2026
16 checks passed
@BillyONeal
Billy O'Neal (BillyONeal) deleted the libspng-pkgconfig branch August 28, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants