CMake安装命令中的正则表达式 [英] Regular expression in CMake install command
本文介绍了CMake安装命令中的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含混合源(.cpp)和标头(.h和.hpp)文件的文件夹。我该如何在CMake install命令中编写一个正则表达式,以便仅将头文件安装到特定目标位置?
I have a folder with mixed source (.cpp) and header (.h and .hpp) files. How do I write a regex expression in the CMake install command for installing only header files into a specific destination?
我在一个示例中搜索了如何使用正则表达式的示例
My search for an example on how to use a regex expression in the CMake install command did not succeed.
推荐答案
来自安装文档:
FILES_MATCHING选项可以在第一个match选项之前给出,以禁用
安装任何表达式都不匹配的文件(但不包括目录)。
The FILES_MATCHING option may be given before the first match option to disable installation of files (but not directories) not matched by any expression.
用法
Usage
cmake_minimum_required(VERSION 2.8)
project(foo)
install(
DIRECTORY
"./src"
DESTINATION
"include/foo"
FILES_MATCHING
PATTERN
"*.hpp"
)
示例
Example
> cmake -H. -B_builds -DCMAKE_INSTALL_PREFIX=`pwd`/_install
> cmake --build _builds/ --target install
> find src/ -type f
src/a.hpp
src/a.cpp
src/B/b.hpp
src/B/b.cpp
仅安装 *。hpp
文件:
> find _install/ -type f
_install/include/foo/src/a.hpp
_install/include/foo/src/B/b.hpp
这篇关于CMake安装命令中的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文