"cmake -E create_symlink" 的奇怪错误
Weird error with "cmake -E create_symlink"
当我更新在 cmake 上配置的项目的源文件并在构建目录中再次启动 make
命令时,我在链接后收到一条奇怪且不是很明确的错误消息。
似乎涉及create_symlink
命令(make VERBOSE=1
):
[100%] Building CXX object CMakeFiles/thing.dir/main.cpp.o
Linking CXX executable thing
/usr/bin/cmake -E cmake_link_script CMakeFiles/thing.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/thing.dir/main.cpp.o -o thing -rdynamic
/usr/bin/cmake -E create_symlink /path/to/stuff/ stufflink
make[2]: *** [thing] Error 1
make[2]: Leaving directory « /home/cromod/bug/build »
make[1]: *** [CMakeFiles/thing.dir/all] Erreur 2
make[1]: Leaving directory « /home/cromod/bug/build »
make: *** [all] Error 2
可执行文件似乎已正确编译和链接,因为我可以毫无问题地使用它。此外,另一个 make 命令使错误消息消失。
这里有一个简单的 cmake 脚本来重现这个案例:
cmake_minimum_required(VERSION 2.8)
project(thing)
add_executable(thing main.cpp)
set(STUFF_PATH "/path/to/stuff/")
add_custom_command(TARGET thing POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${STUFF_PATH} stufflink)
我被迫在 debian 7 / cmake 2.8.9(以及其他平台)上 运行 这个 cmake 脚本:(
为什么 create_symlink
失败了?您知道使用 cmake 2.8 避免此错误的方法吗?
事实上,我在 cmake 2.8 上遇到了 create_symlink
命令的边缘情况。
特定路径 /path/to/stuff
在出现奇怪错误的平台上不存在,因此 stufflink
是损坏的符号 link。
在旧的 cmake 版本 (<3.0.0) 上,当 cmake -E create_symlink ...
试图重写损坏的符号 link 时,它 returns 1 没有任何明确的错误消息。
此错误与在 cmake 的错误跟踪器中发现的问题有关,它们的解决方案(在 cmake 3.0.0 中)也修复了我的情况:
- 0014713: cmake -create-symlink 不会覆盖现有的
悬挂(!)symlinks
- 0014928: cmake -E create_symlink always returns code 0 even when failing to create symlink
因为我被迫 运行 我的 cmake 脚本在几个平台上,我将添加一个环境变量来定义 /path/to/stuff
.
当我更新在 cmake 上配置的项目的源文件并在构建目录中再次启动 make
命令时,我在链接后收到一条奇怪且不是很明确的错误消息。
似乎涉及create_symlink
命令(make VERBOSE=1
):
[100%] Building CXX object CMakeFiles/thing.dir/main.cpp.o
Linking CXX executable thing
/usr/bin/cmake -E cmake_link_script CMakeFiles/thing.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/thing.dir/main.cpp.o -o thing -rdynamic
/usr/bin/cmake -E create_symlink /path/to/stuff/ stufflink
make[2]: *** [thing] Error 1
make[2]: Leaving directory « /home/cromod/bug/build »
make[1]: *** [CMakeFiles/thing.dir/all] Erreur 2
make[1]: Leaving directory « /home/cromod/bug/build »
make: *** [all] Error 2
可执行文件似乎已正确编译和链接,因为我可以毫无问题地使用它。此外,另一个 make 命令使错误消息消失。
这里有一个简单的 cmake 脚本来重现这个案例:
cmake_minimum_required(VERSION 2.8)
project(thing)
add_executable(thing main.cpp)
set(STUFF_PATH "/path/to/stuff/")
add_custom_command(TARGET thing POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${STUFF_PATH} stufflink)
我被迫在 debian 7 / cmake 2.8.9(以及其他平台)上 运行 这个 cmake 脚本:(
为什么 create_symlink
失败了?您知道使用 cmake 2.8 避免此错误的方法吗?
事实上,我在 cmake 2.8 上遇到了 create_symlink
命令的边缘情况。
特定路径 /path/to/stuff
在出现奇怪错误的平台上不存在,因此 stufflink
是损坏的符号 link。
在旧的 cmake 版本 (<3.0.0) 上,当 cmake -E create_symlink ...
试图重写损坏的符号 link 时,它 returns 1 没有任何明确的错误消息。
此错误与在 cmake 的错误跟踪器中发现的问题有关,它们的解决方案(在 cmake 3.0.0 中)也修复了我的情况:
- 0014713: cmake -create-symlink 不会覆盖现有的 悬挂(!)symlinks
- 0014928: cmake -E create_symlink always returns code 0 even when failing to create symlink
因为我被迫 运行 我的 cmake 脚本在几个平台上,我将添加一个环境变量来定义 /path/to/stuff
.