CMake: use "Requires:" for .pc generation (fixes static linking)#691
Merged
bk138 merged 1 commit intoLibVNC:masterfrom Mar 15, 2026
Merged
Conversation
Contributor
Author
One (rather, my) use case for this is the VNC client plugin in VLC Media Player, which on Windows/Apple (generally non-Unix) is statically linked to: See also: |
9bb2b9a to
55d9ff6
Compare
Contributor
Author
|
(now fixed my committer identity, sorry for the noise) |
bk138
requested changes
Mar 3, 2026
Instead of trying to translate/parse the INTERFACE link flags from CMake to the .pc file, make use of the more native-to-pkg-config "Requires" and "Requires.private", so that we can refer to the whole dependent .pc pacakge name. This fixes static linking when the dependencies of static libraries are also static, and allows for using pkg-config all the way down. When sasl and zlib are found, Rfb public headers also include headers from these libraries so they are the only ones listed in "Requires". The others can be in "Requires.private". libsystemd and libpng are exclusively libvncserver dependencies, while sasl is exclusively a libvncclient dependency. The rest of the libraries are common dependencies to both. Signed-off-by: Johannes Kauffmann <johanneskauffmann@hotmail.com>
55d9ff6 to
8b89f5e
Compare
Member
|
Thanks for that very nice and clean PR @JohannesKauffmann ! |
Contributor
Author
|
thank you for taking the time to review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of trying to translate/parse the INTERFACE link flags from CMake
to the .pc file, make use of the more native-to-pkg-config "Requires"
and "Requires.private", so that we can refer to the whole dependent .pc
pacakge name.
This fixes static linking when the dependencies of static libraries are
also static, and allows for using pkg-config all the way down.
When sasl and zlib are found, Rfb public headers also include headers
from these libraries so they are the only ones listed in "Requires".
The others can be in "Requires.private".
Additionally, re-order the CMake option()'s such that all the different types are grouped by type (general, dependencies, examples) and rewrite WITH_XCB description to clarify that this concerns an example.
Signed-off-by: Johannes Kauffmann johanneskauffmann@hotmail.com