-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a "system" dependency for zlib #6421
Conversation
It is not limited to macosx/bsd, for example when cross compiling for Android NDK it also have the zlib but no pkg-config file. For example, here is how GLib search for zlib: https://gitlab.gnome.org/GNOME/glib/blob/master/meson.build#L1872. This is the kind of mess I'm trying to solve with #4595. That being said, I guess macosx/freebsd are popular enough to have their special case until we have a fully-fledged solution. |
I wouldn't want to do this for every dependency, but zlib is really popular so having a built-in solution seems better to me. |
I have added several dependencies like this, and would eventually add numerous more, because of the frequent imperfection in packages' pkg-config files and other corner cases. Another choice would be to lean heavily on CMake inside Meson, since CMake has typically already solved the corner cases. |
|
Yup. I've got another series that cleans up a lot of cruft in the dependencies (mostly in the dependencies that have > 1 way to find them) that I think should land before this, but isn't done. Consider this on hold until then. |
There's two more corner-cases that should probably go in here: the library is sometimes called |
411e7dc
to
364e30a
Compare
That code seems to have been (re)moved. I'm assuming (based on .lib) that's for windows? |
@dcbaker it's just a few lines down: # Don't use the bundled ZLib sources until we are sure that we can't find it on
# the system
libz_dep = dependency('zlib', required : false)
if not libz_dep.found()
if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
libz_dep = cc.find_library('z', required : false)
else
libz_dep = cc.find_library('zlib1', required : false)
if not libz_dep.found()
libz_dep = cc.find_library('zlib', required : false)
endif
endif
if not libz_dep.found() or not cc.has_header('zlib.h')
libz_dep = subproject('zlib').get_variable('zlib_dep')
endif
endif |
Okay, added windows, added a test case. lets see what happens. |
05e00e9
to
63b725b
Compare
This comes pre-installed, but currently we don't have a way to detect it without relying on pkg-config or cmake. This is only valid with the apple clang-based compilers, as they do some special magic to get headers.
I've tested this on FreeBSD, and dragonfly's userland is close enough I'm willing to call it good without testing. OpenBSD and NetBSD also have a zlib in their base configurations, but I'm not confident enough to enable those without testing.
63b725b
to
55ff7bd
Compare
55ff7bd
to
b0c219b
Compare
Okay off hold, @xclaesse, does this look good? |
I have not tried to use Zlib from Windows. So this may be just a fluke test result. Here's what I got from VS 2019:
|
OK then disregard my result from VS 2019, thanks |
LGTM. |
In fact, FreeBSD provides |
This adds a system depenedency for zlib, so that platforms that ship zlib as part of the base os (macOS, FreeBSD, and probably other BSDs but I don't have VMs for all of them). This allows zlib to be found without the use of cmake of pkg-config, which is especially helpful on macOS.
This has been updated on top of #6443
Fixes #2654