meson: Use dependency() when possible

This is the preferred way to figure out whether a library is
available, and for the most part we can just adopt it right
away; in a few cases, unfortunately, we're stuck with using
cc.find_library() until further down the road, when all our
target platforms ship with pkg-config enabled versions of the
various libraries.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Andrea Bolognani 2021-05-26 18:46:20 +02:00
parent f5298b8589
commit fe7c07adac

View File

@ -844,6 +844,7 @@ endforeach
# generic build dependencies # generic build dependencies
# FIXME rewrite to use dependency()
acl_dep = cc.find_library('acl', required: false) acl_dep = cc.find_library('acl', required: false)
if acl_dep.found() if acl_dep.found()
conf.set('WITH_LIBACL', 1) conf.set('WITH_LIBACL', 1)
@ -859,12 +860,13 @@ if apparmor_dep.found()
conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles') conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles')
endif endif
# FIXME rewrite to use dependency() once we can use 2.4.48
attr_dep = cc.find_library('attr', required: get_option('attr')) attr_dep = cc.find_library('attr', required: get_option('attr'))
if attr_dep.found() if attr_dep.found()
conf.set('WITH_LIBATTR', 1) conf.set('WITH_LIBATTR', 1)
endif endif
audit_dep = cc.find_library('audit', required: get_option('audit')) audit_dep = dependency('audit', required: get_option('audit'))
if audit_dep.found() if audit_dep.found()
conf.set('WITH_AUDIT', 1) conf.set('WITH_AUDIT', 1)
endif endif
@ -878,7 +880,7 @@ if blkid_dep.found()
conf.set('WITH_BLKID', 1) conf.set('WITH_BLKID', 1)
endif endif
capng_dep = cc.find_library('cap-ng', required: get_option('capng')) capng_dep = dependency('libcap-ng', required: get_option('capng'))
if capng_dep.found() if capng_dep.found()
conf.set('WITH_CAPNG', 1) conf.set('WITH_CAPNG', 1)
endif endif
@ -1071,6 +1073,7 @@ else
intl_dep = dependency('', required: false) intl_dep = dependency('', required: false)
endif endif
# FIXME rewrite to use dependency() once we can use 2.0.14
numactl_dep = cc.find_library('numa', required: get_option('numactl')) numactl_dep = cc.find_library('numa', required: get_option('numactl'))
if numactl_dep.found() if numactl_dep.found()
conf.set('WITH_NUMACTL', 1) conf.set('WITH_NUMACTL', 1)
@ -1160,7 +1163,7 @@ else
sasl_dep = dependency('', required: false) sasl_dep = dependency('', required: false)
endif endif
selinux_dep = cc.find_library('selinux', required: get_option('selinux')) selinux_dep = dependency('libselinux', required: get_option('selinux'))
if selinux_dep.found() if selinux_dep.found()
selinux_mount = get_option('selinux_mount') selinux_mount = get_option('selinux_mount')
if selinux_mount == '' if selinux_mount == ''
@ -1269,7 +1272,7 @@ elif host_machine.system() == 'linux'
elif host_machine.system() in [ 'freebsd', 'darwin' ] elif host_machine.system() in [ 'freebsd', 'darwin' ]
xdr_dep = cc.find_library('c', required: false) xdr_dep = cc.find_library('c', required: false)
else else
xdr_dep = declare_dependency() xdr_dep = dependency('', required: false)
endif endif
yajl_version = '2.0.3' yajl_version = '2.0.3'
@ -1469,16 +1472,16 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
if cc.has_header('libxlutil.h') if cc.has_header('libxlutil.h')
conf.set('WITH_LIBXLUTIL_H', 1) conf.set('WITH_LIBXLUTIL_H', 1)
endif endif
xl_util_dep = cc.find_library('xlutil') xl_util_dep = dependency('xlutil')
xen_store_dep = cc.find_library('xenstore') xen_store_dep = dependency('xenstore')
# xtl_* infrastructure is in libxentoollog since Xen 4.7 previously # xtl_* infrastructure is in libxentoollog since Xen 4.7 previously
# it was in libxenctrl. # it was in libxenctrl.
if libxl_dep.version().version_compare('>=4.7.0') if libxl_dep.version().version_compare('>=4.7.0')
xtl_link_dep = cc.find_library('xentoollog') xtl_link_dep = dependency('xentoollog')
else else
xtl_link_dep = cc.find_library('xenctrl') xtl_link_dep = dependency('xenctrl')
endif endif
if libxl_dep.version().version_compare('>=4.13.0') if libxl_dep.version().version_compare('>=4.13.0')