From: Daniel Wagner Date: Wed, 15 Dec 2021 13:22:02 +0000 (+0100) Subject: build: Use compiler.find_library for libhugetlbfs X-Git-Tag: v2.0-rc0~21^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4464968bcaeb01cf0b42373095208de46153f43b;p=users%2Fsagi%2Fnvme-cli.git build: Use compiler.find_library for libhugetlbfs libhugetlbfs is not detected via dependency() because the library neither provides a pkg-config() nor a cmake helper. Use compiler.find_library to figure out if the library is available. We do not use the has_header feature of compiler.find_library() function as this would update our minimum version for meson to 0.50.0. Instead open code it by using compiler.has_header(). Signed-off-by: Daniel Wagner --- diff --git a/meson.build b/meson.build index 9a9f5d07..df4d4d12 100644 --- a/meson.build +++ b/meson.build @@ -42,9 +42,16 @@ if json_c.found() conf.set('LIBJSONC_14', json_c.version().version_compare('>=0.14'), description: 'Is json-c at least 0.14?') endif -# Check for libhugetlbfs availability -libhugetlbfs = dependency('hugetlbfs', required: false) -conf.set('LIBHUGETLBFS', libhugetlbfs.found(), description: 'Is libhugetlbfs required?') +# Check for libhugetlbfs availability +if cc.has_header(['hugetlbfs.h']) + libhugetlbfs_dep = cc.find_library('hugetlbfs', + required : false) + have_libhugetlbfs = libhugetlbfs_dep.found() +else + libhugetlbfs_dep = [] + have_libhugetlbfs = false +endif +conf.set('LIBHUGETLBFS', have_libhugetlbfs, description: 'Is libhugetlbfs available?') # Check for zlib availability libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep']) @@ -193,7 +200,8 @@ subdir('Documentation') executable( 'nvme', sources, - dependencies: [ libnvme_dep, libuuid, json_c, libz_dep, openssl_dep ], + dependencies: [ libnvme_dep, libuuid, json_c, libz_dep, openssl_dep, + libhugetlbfs_dep ], include_directories: incdir, install: true, install_dir: get_option('sbindir')