cmake glob include 同时保留目录结构
我是 cmake
的新手,我正在尝试安装 .hpp
文件,同时保留目录结构。
到目前为止,我已
FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/detail/*.hpp"
install (FILES ${files} DESTINATION include)
找到所有文件,但目录层次结构已扁平化。
FWIW 我试图模拟的 bjam
命令是
install headers
: ../include/EnsembleLearning.hpp
[ glob ../include/MyLib/*.hpp ]
[ glob ../include/MyLib/detail/*.hpp ]
: <install-source-root>../include ;
I'm new to cmake
and I'm trying to install .hpp
files while preserving directory structure.
So far I have
FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/MyLib/detail/*.hpp"
install (FILES ${files} DESTINATION include)
All the files get found but the directory hierarchy is flattened.
FWIW The bjam
command I'm trying to emulate is
install headers
: ../include/EnsembleLearning.hpp
[ glob ../include/MyLib/*.hpp ]
[ glob ../include/MyLib/detail/*.hpp ]
: <install-source-root>../include ;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CMake install 命令的 DIRECTORY 变体。此命令将保留复制目录的结构:
如果要复制的目录包含不应安装的子目录,则必须使用 PATTERN EXCLUDE 选项显式排除这些子目录:
You can use the DIRECTORY variant of the CMake install command. This command will preserve the structure of the copied directory:
If the directory to be copied contains subdirectories that should not be installed, you'll have to explicitly exclude those with a PATTERN EXCLUDE option: