From de4543d8f86208c5cba0140e1de85a5624a0c8f1 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 13 Jun 2022 11:04:17 +0200 Subject: [PATCH] build: use cc.links() to check for static libcap Fixes: #4144 Signed-off-by: Christian Brauner (Microsoft) --- meson.build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f48694ee5..ace66c0c8 100644 --- a/meson.build +++ b/meson.build @@ -382,7 +382,16 @@ if want_capabilities # Compat with Ubuntu 14.04 which ships libcap w/o .pc file libcap_static = cc.find_library('cap', required: false, static: true) endif - srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static.found()) + + code = ''' +int main(int argc, char *argv[]) { return 0; }; +''' + if libcap_static.found() + libcap_static_linkable = cc.links(code, args: '-static', dependencies: libcap_static) + srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static_linkable) + else + srcconf.set10('HAVE_STATIC_LIBCAP', false) + endif else srcconf.set10('HAVE_LIBCAP', false) srcconf.set10('HAVE_STATIC_LIBCAP', false)