From cc9c3c3175365dff0180783e00d835eaa72c2fb0 Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Sat, 20 Apr 2019 22:26:52 +0200 Subject: [PATCH] meson: check for libcap via pkg-config It's possible that setcap is installed, but the libcap headers/libs aren't (e.g. during cross compilation, when you have the program installed for the host, but need the headers of the target). Also removes the need to manually check for the libcap headers. --- libs/gst/helpers/meson.build | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/libs/gst/helpers/meson.build b/libs/gst/helpers/meson.build index 747cc9e849..0f1195493b 100644 --- a/libs/gst/helpers/meson.build +++ b/libs/gst/helpers/meson.build @@ -64,16 +64,8 @@ if have_ptp description : 'getifaddrs() and AF_LINK is available') endif - gst_ptp_have_cap = false - cap_dep = [] - if cc.has_header('sys/capability.h') - cap_dep = cc.find_library('cap', required : false) - if cap_dep.found() and cc.has_function('cap_init', dependencies : cap_dep) - gst_ptp_have_cap = true - endif - endif - - setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false) + setcap_prog = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false) + cap_dep = dependency('libcap', required: false) # user/group to change to in gst-ptp-helper ptp_helper_setuid_user = get_option('ptp-helper-setuid-user') @@ -90,7 +82,7 @@ if have_ptp # how to install gst-ptp-helper with_ptp_helper_permissions = get_option('ptp-helper-permissions') if with_ptp_helper_permissions == 'auto' - if gst_ptp_have_cap and setcap.found() + if setcap_prog.found() and cap_dep.found() with_ptp_helper_permissions = 'capabilities' else with_ptp_helper_permissions = 'setuid-root' @@ -104,8 +96,10 @@ if have_ptp cdata.set('HAVE_PTP_HELPER_SETUID', 1, description : 'Use setuid-root for permissions in PTP helper') elif with_ptp_helper_permissions == 'capabilities' - if not setcap.found() + if not setcap_prog.found() error('capabilities-based ptp-helper-permissions requested, but could not find setcap tool.') + elif not cap_dep.found() + error('capabilities-based ptp-helper-permissions requested, but could not find libcap.') endif cdata.set('HAVE_PTP_HELPER_CAPABILITIES', 1, description : 'Use capabilities for permissions in PTP helper') @@ -122,7 +116,7 @@ if have_ptp meson.add_install_script('ptp_helper_post_install.sh', helpers_install_dir, with_ptp_helper_permissions, - setcap.found() ? setcap.path() : '') + setcap_prog.found() ? setcap_prog.path() : '') endif install_data(['gst_gdb.py', 'glib_gobject_helper.py'],