Bug report
Line 802 of meson.build says:
we can't use cc.has_function() on dependencies since they might be
internal, so check headers instead
However, the zstd block just below does exactly what this comment warns
against, but with cc.has_header_symbol() instead of cc.has_function():
foreach sym : ['ZSTD_compressStream', 'ZSTD_minCLevel']
if cc.has_header_symbol(
'zstd.h',
sym,
dependencies: zstd_dep,
)
cc.has_header_symbol() has the same limitation as cc.has_function():
it rejects internal dependencies in the dependencies: kwarg. This
fails with:
meson.build:347:10: ERROR: Dependencies must be external dependencies
To reproduce
Use zstd via a subproject fallback (i.e. dependency('libzstd', ...)
resolves through fallback:/wrap, not pkg-config/cmake), for example
when zstd isn't installed system-wide and libarchive is built as a
subproject with zstd=enabled.
Environment
- Meson 1.12.0
- libarchive 3.8.9
Suggested fix
Replace the has_header_symbol() calls with a version check, since
Dependency.version() works for both internal and external
dependencies (see liblzma handling a few lines above for a similar
pattern already in this file):
zstd_version = zstd_dep.version()
if zstd_version == 'unknown' or zstd_version.version_compare('>=1.0.0')
cdata.set('HAVE_ZSTD_compressStream', 1)
endif
if zstd_version == 'unknown' or zstd_version.version_compare('>=1.4.0')
cdata.set('HAVE_ZSTD_minCLevel', 1)
endif
I've tested this patch locally and it resolves the issue while keeping
zstd statically linked via a subproject.
Bug report
Line 802 of meson.build says:
However, the zstd block just below does exactly what this comment warns
against, but with
cc.has_header_symbol()instead ofcc.has_function():cc.has_header_symbol()has the same limitation ascc.has_function():it rejects internal dependencies in the
dependencies:kwarg. Thisfails with:
To reproduce
Use zstd via a subproject fallback (i.e.
dependency('libzstd', ...)resolves through
fallback:/wrap, not pkg-config/cmake), for examplewhen zstd isn't installed system-wide and libarchive is built as a
subproject with
zstd=enabled.Environment
Suggested fix
Replace the
has_header_symbol()calls with a version check, sinceDependency.version()works for both internal and externaldependencies (see
liblzmahandling a few lines above for a similarpattern already in this file):
I've tested this patch locally and it resolves the issue while keeping
zstd statically linked via a subproject.