-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
modules/pkg-config: Add support for Cflags.private
#14829
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
base: master
Are you sure you want to change the base?
Conversation
It's not necessary as we have "common/44 pkgconfig-gen" already.
Port commit fde514c to test cases/common/44 pkgconfig-gen.
986c21b to
8f62ce3
Compare
Cflags.private are compiler flags which are retrieved by pkg-config when static linking is requested. Currently, not all pkg-config implementations support Cflags.private; FreeDesktop.Org's pkg-config doesn't support it [1], but pkgconf does. Fixes mesonbuild#14749 [1] https://gitlab.freedesktop.org/pkg-config/pkg-config/-/issues/38
8f62ce3 to
54a8b38
Compare
|
How does it work to get those private cflags from pkgconf? Should we also make Meson use them somewhere? I would like to see a unit test for that. Sorry if it's there and I missed it. |
|
Note that usually projects do not build both shared and static libraries on windows, because it requires compiling everything twice and that capability has only been added recently in Meson. That means that in the case you build only the static library, it is fine to add e.g. |
|
Hi @xclaesse!
Well, Meson doesn't read
MSYS2 distributes both the shared library and the static library in a single package (and it usually builds the library twice for that). However the package ships one dependency('foo') # follow default_library
dependency('foo', static: false) # shared library
dependency('foo', static: true) # static librarySee for example the file list in https://packages.msys2.org/packages/mingw-w64-ucrt-x86_64-libepoxy. Fedora mingw packages do the same: |
You still need to tell pkgconf if you want static or not. We usually pass --static arg for libs but I'm not sure we do for cflags. In either case, we should have a unit test for it |
I'm pretty sure they do that by configuring meson twice and keeping only one of the .pc file generated. For glib I would be surprised if that even works because the macro is not in the .pc file but in generated header file. |
You're right, meson doesn't pass meson/mesonbuild/dependencies/pkgconfig.py Lines 159 to 189 in 3429a2b
|
|
AFAICT there's no reason we don't other than no one's written the code. pkg-config and pkgconf both accept that (and those are the only two pkg-config implementations we really claim to support) |
| requires : 'glib-2.0', # Not really, but only here to test that this works. | ||
| requires_private : ['gio-2.0', 'gobject-2.0'], | ||
| libraries_private : [lib, '-lz'], | ||
| cflags_private: '-DSIMPLE_STATIC', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of adding the flag? It's a shared library, so it doesnt have any purpose, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's just a check that setting cflags_private doesn't crash Meson. Not much, I know 🙂 The test could be extended but we have to detect pkconf vs pkg-config
Fixes #14749