基本上,我希望能够在功能install_subdir和install_headers之间混合使用。
我想将所有头文件从项目源目录复制到其他目录,并且仍然保持子目录结构。
资源
MyProject
|-- folder1
| |-- file11.h
| |-- file11.cpp
| |-- file12.h
| `-- file12.cpp
`-- folder2
`-- file21.h
目的地
MyProject
|-- folder1
| |-- file11.h
| |-- file12.h
`-- folder2
`-- file21.h
我试过的是复制源目录并排除所有cpp文件,只使用预期的install_headers()
功能,但都无法解决。
我对所做的事情及其原因添加了评论。也许有人知道发生了什么:
project('MyProject', 'cpp')
test_src = [ 'src/MyProject/folder1/file11.cpp'
'src/MyProject/folder1/file12.cpp']
# Passing files seems to be preferred but exclude_files only takes list of strings
# test_src = files([ 'src/MyProject/folder1/file11.cpp'
# 'src/MyProject/folder1/file12.cpp'])
test_hdr = files([ 'src/MyProject/folder1/file11.h',
'src/MyProject/folder1/file12.h',
'src/MyProject/folder2/file21.h'])
base_dir = meson.current_source_dir()
static_library('MyProject', name_prefix: '', name_suffix : 'lib',
sources: test_src,
install: true,
install_dir: base_dir + '/build/lib')
# Produces flat hierarchy
install_headers(test_hdr, install_dir: base_dir + '/build/include')
# Also copies all cpp files into destination folder
install_subdir('src/MyProject', install_dir: base_dir + '/build/include', exclude_files: '*.cpp')
# Same result as wildcard exclusion
install_subdir('src/MyProject', install_dir: base_dir + '/build/include', exclude_files: test_src)
有人对此有解决方案吗?
如果有任何方法的必要,我将提供我的源代码和标头的完整列表。
我目前正在通过shell命令复制文件,但是最好将其包含在安装/构建过程中。
//编辑:
我在Windows上使用介子构建。
我找到了解决我想要的方法。
如果有人找到更好的解决方案,需要所有头文件的列表,请随时回答,我会接受的。
现在这是我所做的:
project('MyProject', 'cpp')
test_src = files([ 'src/MyProject/folder1/file11.cpp',
'src/MyProject/folder1/file12.cpp' ])
# Note that i'm omitting the base folder here since exclude_files searches relative to the subdir path
# Also, forward slash doesnt work. You have to use double backslash
test_src_exclude = [ 'folder1\\file11.cpp',
'folder1\\file12.cpp' ]
dir_base = meson.current_source_dir()
dir_install = join_paths(dir_base, 'build/meson-out/MyProject')
dir_install_hdr = join_paths(dir_install, 'include')
static_library('MyProject', name_prefix: '', name_suffix : 'lib',
sources: test_src,
install: true,
install_dir: dir_install)
install_subdir( 'src/MyProject',
install_dir: dir_install_hdr,
strip_directory: true,
exclude_files: text_src_exclude)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句