CMake无法在Windows 10上遵循符号链接 [英] CMake cannot follow symlinks on Windows 10
问题描述
在我的CMakeLists.txt中,我试图安装一个包含符号链接的文件夹。之前,它在Windows 7上运行良好,但是切换到Windows 10后,它坏了。通过缩小问题的范围,我发现Windows 10上的符号链接可能是根本原因。
我写了一小段cmake来对其进行测试:
In my CMakeLists.txt I am trying to install a folder which contains symlinks. It works well on windows 7 before, but after switching to windows 10 it is broken. By narrowing down the problem I figured out the symlink on windows 10 might be the root cause. I wrote a small piece of cmake to test it:
file(GLOB all_files *)
foreach(each_file ${all_files})
if (IS_SYMLINK ${each_file})
get_filename_component(each_file_real_path ${each_file} REALPATH)
endif()
endforeach()
如果我在带有符号链接的文件夹内的cmake脚本上运行,则 IS_SYMLINK
正常工作,但 get_filename_component(REALPATH)
始终返回相同的输入路径,而不是实际路径。
If I run above cmake scripts inside a folder with symlinks inside, the IS_SYMLINK
works correctly but get_filename_component(REALPATH)
always return the same input path instead of the real path.
有什么办法可以解决或解决它?谢谢!
Is there any way to fix or work around it? Thanks!
推荐答案
请考虑使符号链接更深一层,指向更高一级的目录。如果目录符号链接位于您所指的位置,那么Cmake不会有问题。
Consider making the symlink one level deeper, pointing at a directory one level higher. Cmake won't have a problem if the directory-symlink is up a level from where you're pointing.
这只是一种解决方法。此时cmake仍然存在一个确定的错误。
This is just a workaround. There's still a definitive bug in cmake at this point.
这篇关于CMake无法在Windows 10上遵循符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!