Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pkgconfig CMake compatibility & switch to pkgconf #693

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thrimbor
Copy link
Member

The last two commits are from #631, with only the commit title updated. They make it possible for CMake to find the libraries to link against via pkg-config.

These two commits had the problem that they fix CMake, but by doing so are breaking direct usage of nxdk-pkg-config (and probably meson) because the emitted linker arguments are in ld syntax, while we rely on the syntax of link.exe.

This PR circumvents this issue by switching from whatever pkg-config the host OS provides to explicitly requiring pkgconf (which is the default pkg-config implementation on Arch, Alpine and probably others anyway).
pkgconf provides a --msvc-syntax parameter that can be used to get the required link.exe-style linker parameters. This would add an additional .lib suffix to the library paths (resulting in things like libjpeg.lib.lib), so I added a small sed command to fix that.

--define-variable=NXDK_DIR=${NXDK_DIR} \
--define-prefix \
--static \
"$@"
"$@" | sed 's/\.lib\.lib/\.lib/g'
Copy link
Member

@JayFoxRox JayFoxRox Jan 10, 2025

Choose a reason for hiding this comment

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

I'm not sure I follow the PR description.

I thought the .lib.lib only happens when using --msvc-syntax, but now --msvc-syntax is absent?
(Also, why does it produce .lib.lib? This feels like a bug - was it reported?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought the .lib.lib only happens when using --msvc-syntax, but now --msvc-syntax is absent?

It does, but passing in --msvc-syntax is up to the user. Generally, a user will want to specify it for the linker (which follows link.exe parameter syntax), but not for the compiler (which follows gcc/clang syntax), and not for CMake (which expects ld syntax).

(Also, why does it produce .lib.lib? This feels like a bug - was it reported?)

Not a bug, it matches freedesktop's pkg-config implementation.
To convert the ld to link.exe syntax, the -l is stripped and a .lib added (for example, on my host system pkg-config libpng --libs produces -lpng16, whereas with --msvc-syntax I get png16.lib instead, because with MSVC libraries by convention have a .lib ending).
We already have our parameters end in .lib, with the one added by pkgconf we get .lib.lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants