Fix search path for LZO headers

LZO expects its headers to be included as <lzo/something.h>, but its
pkg-config file specifies only "Cflags: -I${includedir}/lzo".  This
happens to work if ${includedir} is already on the header search path,
e.g. it's /usr/include.  However, if lzo2 is in an unusual location and
we're depending on pkg-config to tell us where it is, we'll end up looking
for ${includedir}/lzo/lzo/lzo2a.h and failing the build:

    util/cairo-script/cairo-script-file.c:45:10: fatal error: 'lzo/lzo2a.h' file not found

Work around the broken pkg-config include path.

Reported to LZO upstream on 2025-03-13.
This commit is contained in:
Benjamin Gilbert 2025-03-13 21:03:02 -06:00
parent c8d89d6e5c
commit 3c1135fe84

View file

@ -203,6 +203,18 @@ endif
lzo_dep = dependency('lzo2', required: get_option('lzo'))
if lzo_dep.found()
conf.set('HAVE_LZO', 1)
# LZO <= 2.10 expects its headers to be included as <lzo/something.h>, but
# its pkg-config file specifies -I${includedir}/lzo, so the compiler won't
# find the headers if LZO is installed outside the default include paths.
# Add the correct include path.
lzo_includedir = lzo_dep.get_variable('includedir', default_value: '')
if lzo_includedir != ''
# LZO is not being built as a sibling Meson subproject
lzo_dep = declare_dependency(
compile_args: '-I' + lzo_includedir,
dependencies: lzo_dep,
)
endif
endif
dl_dep = cc.find_library('dl', required: false)