CMake 在安装过程中遵循符号链接
简短问题: 是否可以将 CMake 设置为在安装期间复制文件时遵循符号链接,如果可以,如何完成?
详细信息:我正在使用 CMake 来构建和安装 LLVM。在我的 LLVM 源代码树中的 include 目录中,我有一个指向另一个针对 LLVM 开发的子项目的符号链接。一切似乎都正常,除了我注意到当我运行“cmake install”时,它复制了包含目录而不遵循符号链接。我遇到的问题是我的符号链接有一个相对路径(因为它位于 git 存储库内)。因此,当复制符号链接(而不是跟随并复制内容)时,它们不再指向正确的文件。例如我有 dsa -> ../../llvm-poolalloc/include/dsa/ 我想在安装时复制此链接的内容,而不仅仅是复制链接。但我还没有找到执行此操作的 cmake 标志。
我意识到这可能不是构建我的项目的理想方式,但我正在使用已经存在的东西,最好不必更改太多目录结构,因为与我一起工作的其他人期望它就这样。所以我认为能够跟踪符号链接可能会解决我的问题,而不必重组整个构建系统。但我愿意接受其他建议,以更好的方式来完成我正在尝试做的事情。
请注意,我正在 Linux (Ubuntu 10.04) 中工作并使用 LLVM 2.6(我是从源代码与 llvm-gcc 一起编译的)。我也使用 CMake 版本 2.8。
编辑:
以下是与安装指令关联的 CMakeLists.txt 文件的源代码:
install(DIRECTORY include
DESTINATION .
PATTERN ".svn" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "*.in" EXCLUDE
PATTERN "*.tmp" EXCLUDE
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include
DESTINATION .
)
包含目录的目录列表是:
dsa -> ../../llvm-poolalloc/include/dsa/
llvm
llvm-c
poolalloc -> ../../llvm-poolalloc/include/poolalloc
我想要的是 dsa
和 poolalloc 目录被复制,而不仅仅是复制符号链接。我不在符号链接中使用绝对路径的原因是我将它们签入了 git 存储库。因此,当他们从存储库中签出时,我的绝对路径将与从事该项目的其他人不同。
Short question:
Is it possible to set CMake to follow symlinks when copying files during an install, and if so how is this done?
Details: I am using CMake to build and install LLVM. In my LLVM source tree in the include directory I have a symbolic link to another subproject that is being developed against LLVM. Everything seems to work, except that I noticed that when I ran "cmake install" that it copied the include directory without following the symlinks. The problem that I have is that my symlinks have a relative path (because it is inside a git repo). So when the symlinks are copied (instead of followed and copying the contents) they no longer point to the correct files. For example I have dsa -> ../../llvm-poolalloc/include/dsa/
I would like to copy the contents of this link when I do the install rather than just copying the link. But I did not find a cmake flag for doing this yet.
I realize that this is probably not the idea way to structure my project, but I am working with something that's already in place and it would be preferable to not have to change too much of the directory structures because other people I am working with expect it to be this way. So I think that being able to follow symlinks might solve my problem without having to restructure the whole build system. But I am open to other suggestions for better ways to accomplish what I am trying to do.
Note that I am working in Linux (Ubuntu 10.04) and using LLVM 2.6 (that I am compiling from source along with llvm-gcc). Also I am using CMake version 2.8.
Edit:
Here is the source code from the CMakeLists.txt file that is associated with the install instruction:
install(DIRECTORY include
DESTINATION .
PATTERN ".svn" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "*.in" EXCLUDE
PATTERN "*.tmp" EXCLUDE
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include
DESTINATION .
)
the directory listing for the include directory is:
dsa -> ../../llvm-poolalloc/include/dsa/
llvm
llvm-c
poolalloc -> ../../llvm-poolalloc/include/poolalloc
What I want is for the dsa
and poolalloc
directories to be copied rather than just copying the symbolic links. The reason that I don't use absolute paths in the symbolic links is that I have them checked into a git repo. So my absolute path would differ from someone else working on the project when they do a checkout from the repo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,让我们试试这个:
如果没有帮助,您可以尝试不安装包含目录本身(这是符号链接),而是安装它的内容。但在你的情况下,你需要想出智能正则表达式:
最后,使符号链接绝对。
Hmm, let's try this:
If it wouldn't help, you can try to install not the include dir itself (which is symlink), but it's contents. But in your case you would need to came up with smart regex:
Finally, make the symlink absolute.