相对于我的项目根目录meson.build所在的位置,我的所有源文件都位于src/.
是否可以在 meson.build 中指定这些源文件,而不会强迫我在它们全部加上前缀src/,因为这有点多余?
不需要为源文件添加前缀,因为介子提供了特殊函数:files(),它生成“记住”子目录的文件数组对象。例如,在 root meson.build中你可以有:
subdir('src')
subdir('src_more')
exe = executable('test', sources)
Run Code Online (Sandbox Code Playgroud)
在src/meson.build中:
sources = files('a1.c', 'a2.c')
Run Code Online (Sandbox Code Playgroud)
在src_more/meson.build中:
sources += files('b1.c', 'b2.c')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3426 次 |
| 最近记录: |