3

Relative to my project root where meson.build is located, all of my source files are under src/.

Is it possible to specify these source files in meson.build in a way that wouldn't force me to prefix them all with src/, given that that's somewhat redundant?

4

3 回答 3

1

不需要为源文件添加前缀,因为介子提供了特殊功能:files(),它生成“记住”子目录的文件数组对象。例如,在根meson.build中,您可以拥有:

subdir('src')
subdir('src_more')
exe = executable('test', sources)

src/meson.build

sources = files('a1.c', 'a2.c')

src_more/meson.build

sources += files('b1.c', 'b2.c')
于 2019-07-12T13:22:29.950 回答
1

你真的应该放一个meson.build文件src/并在那里创建列表。

于 2019-03-30T17:09:07.550 回答
0

您实际上可以使用foreach语句“构建”一组文件:

raw_sources = [
    'foo.cpp',
    'foomanager.cpp',
    'foofactory.cpp'
]
sources = []

foreach file : raw_sources
    full_path = join_paths('src', file)
    sources += files(full_path)
endforeach

现在包含具有所需前缀的文件。

于 2019-03-30T17:45:41.347 回答