]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
build: Use compiler.find_library for libhugetlbfs
authorDaniel Wagner <dwagner@suse.de>
Wed, 15 Dec 2021 13:22:02 +0000 (14:22 +0100)
committerDaniel Wagner <dwagner@suse.de>
Thu, 16 Dec 2021 08:17:22 +0000 (09:17 +0100)
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 <dwagner@suse.de>
meson.build

index 9a9f5d07b14229fb1a3dfebfa34086955f3ef76a..df4d4d1239fc6fa341415cd780b7c251449f12a2 100644 (file)
@@ -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')