Skip to content

Commit 809e00b

Browse files
committed
build: Avoid including wrong config.h as subpackage
In case the consuming project also uses a config.h we need to hide our config.h file. By using the path to our config.h we avoid this confusion. Obviously, 'src' is a bit too generic, thus move the generated config.h under libnvme. Introduce also a private include path because ccan has '#include "config.h"' in its sources. So we need to present a config.h in the lookup path but it needs to be the one from this project and not the one from the consuming project. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 704a17f commit 809e00b

5 files changed

Lines changed: 18 additions & 15 deletions

File tree

examples/meson.build

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ executable(
99
'telemetry-listen',
1010
['telemetry-listen.c'],
1111
link_with: libnvme,
12-
include_directories: incdir)
12+
include_directories: [incdir, internal_incdir]
13+
)
1314

1415
executable(
1516
'display-columnar',
1617
['display-columnar.c'],
1718
link_with: libnvme,
18-
include_directories: incdir)
19+
include_directories: [incdir, internal_incdir]
20+
)
1921

2022
executable(
2123
'discover-loop',
2224
['discover-loop.c'],
2325
link_with: libnvme,
24-
include_directories: incdir)
26+
include_directories: [incdir, internal_incdir]
27+
)
2528

libnvme/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8+
configure_file(
9+
output: 'config.h',
10+
configuration: conf
11+
)
812

913
want_python = get_option('python')
1014
if want_python != 'false'

meson.build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ configure_file(
133133

134134
################################################################################
135135
add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE',
136-
'-include', 'config.h'], language : 'c')
137-
incdir = include_directories(['ccan', 'src'])
136+
'-include', 'libnvme/config.h'], language : 'c')
137+
incdir = include_directories(['.', 'ccan', 'src'])
138+
internal_incdir = include_directories('libnvme')
138139

139140
################################################################################
140141
sources = []

src/meson.build

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8-
configure_file(
9-
output: 'config.h',
10-
configuration: conf
11-
)
12-
138
sources += [
149
'nvme/cleanup.c',
1510
'nvme/fabrics.c',
@@ -41,7 +36,7 @@ libnvme = library(
4136
link_args: ['-Wl,--version-script=' + version_script_arg],
4237
dependencies: deps,
4338
link_depends: mapfile,
44-
include_directories: incdir,
39+
include_directories: [incdir, internal_incdir],
4540
install: true,
4641
)
4742

test/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ main = executable(
1010
['test.c'],
1111
dependencies: libuuid,
1212
link_with: libnvme,
13-
include_directories: incdir
13+
include_directories: [incdir, internal_incdir]
1414
)
1515

1616
cpp = executable(
1717
'test-cpp',
1818
['cpp.cc'],
1919
link_with: libnvme,
20-
include_directories: incdir
20+
include_directories: [incdir, internal_incdir]
2121
)
2222

2323
register = executable(
2424
'test-register',
2525
['register.c'],
2626
link_with: libnvme,
27-
include_directories: incdir
27+
include_directories: [incdir, internal_incdir]
2828
)
2929

3030
zns = executable(
3131
'test-zns',
3232
['zns.c'],
3333
link_with: libnvme,
34-
include_directories: incdir
34+
include_directories: [incdir, internal_incdir]
3535
)
3636

3737
test('main', main)

0 commit comments

Comments
 (0)