CMake安装头文件并维护目录层次结构 [英] CMake install header files and maintain directory heirarchy
问题描述
使用cmake 2.8
Using cmake 2.8
在将头文件从源目录复制到目标目录时,我想保持目录层次结构。例如,需要复制的头文件是
abc / 1.h,def / 2.h,它们还应该直接以相同的顺序复制到目标位置(通过CMAKE_INSTALL_PREFIX设置)
I would like to maintain the directory heirarchy while copying the header files from the source to the destination directory. For example, the header file that needs to be copied are abc/1.h, def/2.h and they should also be copied in the same order in the destination directly ( set via CMAKE_INSTALL_PREFIX )
这是我尝试过的方法,但是它只是复制头文件,而不是头文件包含父目录的名称
This is what I have tried, but it just copies the header files and not the header files inclusive parent directory name
set(HEADERS "abc/1.h;def/2.h")
install(FILES ${HEADERS} DESTINATION include)
最终输出应为dest_directory / abc / 1.h和dest_directory / def / 2.h。
The final output should be dest_directory/abc/1.h and dest_directory/def/2.h.
推荐答案
如果目录中有许多文件要安装,则可以考虑使用 install(DIRECTORY)安装目录。
命令流。您可以选择 PATTERN 或 REGEX 选项安装目录中的哪些文件:
If you have many files in the directory for install, you may consider to install the directory with install(DIRECTORY)
command flow. You may select which files in the directory should be installed with PATTERN or REGEX options:
install(DIRECTORY "${CMAKE_SOURCE_DIR}/" # source directory
DESTINATION "include" # target directory
FILES_MATCHING # install only matched files
PATTERN "*.h" # select header files
)
请参见 CMake文档有关 install(DIRECTORY)
。另外,它在源目录的末尾描述了 /的含义。
See CMake documentation for more information about the install(DIRECTORY)
. Also, it describes meaning '/' at the end of source directory.
这篇关于CMake安装头文件并维护目录层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!