Skip to content

Commit fab8f5e

Browse files
author
Martin Belanger
committed
libnvme/meson: rearrange the config.h dependencies
Explicitly add 'config_dep' to 'deps' to ensure that config.h is generated before building libnvme. When defining 'c_args', use the '-include' option directly instead of hiding it in 'config_h_arg'. This makes the meson.build file clearer. Since '-include' is used to include config.h, there is no need to add 'internal_incdir' to the include path via '-I' (i.e. with 'include_directories' argument). Note: using '-include' is the Meson-recommended way to include generated headers. The '-I' option (via 'include_directories') should be reserved for static headers. Signed-off-by: Martin Belanger <[email protected]>
1 parent 7daa1e9 commit fab8f5e

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

libnvme/internal/meson.build

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ config_dep = declare_dependency(
2020
include_directories : internal_incdir,
2121
sources: config_h)
2222

23-
config_h_path = meson.current_build_dir() / 'config.h'
24-
config_h_arg = [ '-include', config_h_path ]
23+
if meson.version().version_compare('>=1.4.0')
24+
config_h_path = config_h.full_path()
25+
else
26+
config_h_path = meson.current_build_dir() / 'config.h'
27+
endif

libnvme/src/meson.build

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ deps = [
3333
libdbus_dep,
3434
liburing_dep,
3535
openssl_dep,
36+
config_dep,
3637
]
3738

3839
source_dir = meson.current_source_dir()
@@ -46,8 +47,10 @@ libnvme = library(
4647
link_args: ['-Wl,--version-script=' + version_script_arg],
4748
dependencies: deps,
4849
link_depends: mapfile,
49-
c_args: config_h_arg,
50-
include_directories: [incdir, internal_incdir],
50+
c_args: [
51+
'-include', config_h_path,
52+
],
53+
include_directories: [incdir, ],
5154
install: true,
5255
link_with: libccan,
5356
)
@@ -75,8 +78,10 @@ libnvme_test = library(
7578
'nvme-test', # produces libnvme-test.so
7679
sources,
7780
dependencies: deps,
78-
c_args: config_h_arg,
79-
include_directories: [incdir, internal_incdir],
81+
c_args: [
82+
'-include', config_h_path,
83+
],
84+
include_directories: [incdir, ],
8085
install: false,
8186
link_with: libccan,
8287
)

0 commit comments

Comments
 (0)