Skip to content

Change CMake generated pkgconfig to match meson. - #286

Open
BillyONeal wants to merge 3 commits into
randy408:masterfrom
BillyONeal:cmake-meson-pkgconfig-consistency
Open

Change CMake generated pkgconfig to match meson.#286
BillyONeal wants to merge 3 commits into
randy408:masterfrom
BillyONeal:cmake-meson-pkgconfig-consistency

Conversation

@BillyONeal

Copy link
Copy Markdown

In vcpkg we want to make sure that CMake and pkg-config customers get an experience that works, including transitively. In reviewing microsoft/vcpkg#52891 we discovered that the transitive libjpeg-turbo -> libspng .pc link is broken. In trying to fix that I ran into a transitive problem here.

libspng/CMakeLists.txt

Lines 103 to 107 in adc9439

foreach(libname ${spng_TARGETS})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libspng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endforeach()

installs libspng.pc and libspng_static.pc, but

libspng/meson.build

Lines 82 to 87 in adc9439

pkg = import('pkgconfig')
pkg.generate(spng_lib,
extra_cflags : spng_args,
description : 'PNG decoding and encoding library'
)

installs spng.pc. This seems to be the one libjpeg-turbo is looking to be compatible with.

https://packages.debian.org/sid/amd64/libspng-dev/filelist Looks like Debian is using the meson build, given that they install /usr/lib/x86_64-linux-gnu/pkgconfig/spng.pc.

Also, meson detects whether the .pc should link with libm by probing for existence of the library:

m_dep = cc.find_library('m', required : false)

while CMake just assumes "Windows gets no libm, everyone else does". This change changes everything to match meson.

The problems discussed here and some of the suggested outcomes are from GPT 5.6 Sol.

In vcpkg we want to make sure that CMake and pkg-config customers get an experience that works, including transitively. In reviewing microsoft/vcpkg#52891 we discovered that the transitive libjpeg-turbo -> libspng .pc link is broken. In trying to fix that I ran into a transitive problem here.

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L103-L107

installs `libspng.pc` and `libspng_static.pc`, but

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/meson.build#L82-L87

installs `spng.pc`. This seems to be the one `libjpeg-turbo` is looking to be compatible with.

https://packages.debian.org/sid/amd64/libspng-dev/filelist Looks like Debian is using the meson build, given that they install `/usr/lib/x86_64-linux-gnu/pkgconfig/spng.pc`.

Also, meson detects whether the .pc should link with `libm` by probing for existence of the library:

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/meson.build#L42

while CMake just assumes "Windows gets no libm, everyone else does". This change changes everything to match meson.

The problems discussed here and some of the suggested outcomes are from GPT 5.6 Sol.
BillyONeal added a commit to BillyONeal/vcpkg that referenced this pull request Aug 21, 2026
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.
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.

1 participant