Controlling how meson handles dependency()

Jeremy Sequoia jeremyhu at
Mon Jun 13 15:08:13 UTC 2022

Hey folks,

I wanted to spend some time to get out an updated version of XQuartz to users to address some bugs in the previous release, and I'm hitting a build time issue I'm hoping folks here can help with.

TL;DR: I want to figure out how to specify how to link zlib because meson is detecting it incorrectly.

I'm using mesa 21.3 right now (since that is that I had in the previous release) and meson 0.62.1.

It looks like we detect zlib via:

dep_zlib = dependency('zlib', version : '>= 1.2.3',
                     fallback : ['zlib', 'zlib_dep'],
                     required : get_option('zlib'))

It looks like dependency() is implemented (in part) using cmake, which is giving me an undesired result when using cmake 3.22.4.  Specifically, it gives me a path specific to zlib that is present inside the SDK that was used to build cmake, not the SDK that I'm using to build mesa.  This difference in SDK is important because cmake is built with the current macOS SDK (which contains arm64 + x86_64 support), but I need to also build mesa for i386 (using an older macOS 10.13 SDK).  With cmake present, dependency() is returning the path to libz.tbd in my current SDK which is missing the i386 slice, leading to link failures.

If I uninstall cmake, meson detects how to compile/link correctly (ie: just use '-lz') with a compile test:
   {"name": "zlib", "version": "1.2.11", "compile_args": [], "link_args": ["-lz"]}

So, I have a few questions:
  1 - Is there a way to override these entries on the meson command line?
  2 - Is there a way to tell dependency() to prefer compile test over cmake?
  3 - Is the incorrect detection here something that is probably a bug in mesa's use of meson, meson itself, or cmake? (ie: where do you suggest I go to investigate this next step)

I have a workaround for now (uninstalling cmake during the mesa build), but I'd certainly like to make this more reliable for others.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the mesa-dev mailing list