介子复制/安装头文件到输出目录并保持文件夹结构
Meson copy/install header files to output directory and keep folder structure
基本上,我希望能够在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上使用meson-build。
我找到了一个可以做我想做的解决方法。
如果有人找到更好的解决方案,需要所有头文件的列表,请随时回答,我会接受它。
现在这是我所做的:
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)
相关文章:
- 如何将更多文件夹添加到c++include路径
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 如何在文档文件夹中创建目录
- "assimp/config.h"找不到,但它在文件夹中
- C++入门 5 版:类消息和文件夹
- 我可以在 Arduino 的库文件夹之外安装库吗?
- 如何按文件扩展名引用文件夹中的文件
- 介子复制/安装头文件到输出目录并保持文件夹结构
- 如何在 CMake 中设置此文件夹结构?
- 创建文件夹结构
- Jetson 工具链文件夹结构和交叉编译时的 libgomp 链接器错误
- CMake 子文件夹结构
- 在Visual Studio C 2015项目中添加带有子文件层层次结构的文件夹
- 当存在许多相互依赖的项目时,Visual C++中的文件夹结构
- 从开发人员的角度来看Linux文件夹结构
- Visual Studio中的嵌套文件夹结构-包括文件
- 文件夹结构-很好的实践
- CUDA和C++具有文件夹结构-通用makefile