【发布时间】:2020-10-09 07:38:13
【问题描述】:
我正在尝试使用 ramdisk 作为构建目录来加快构建过程。
我已经创建了 ramdisk:
sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
在 ramdisk 上我创建了构建目录:
mkdir -p /mnt/ramdisk/rust/hello3/build/
然后我将 ramdisk 构建目录符号链接到我要在其中使用此目录的项目:
cd /home/wakatana/rust/hello3
ln -s /mnt/ramdisk/rust/hello3/build/ build
在此之后,我为构建项目做了经典组合:
cd /home/wakatana/rust/hello3/build
cmake ..
make
但是上面的命令不起作用,因为相对路径(cmake ..)被转换为/mnt/ramdisk/rust/hello3而不是/home/wakatana/rust/hello3/(我怀疑这是整个问题)
所以我做了一些修改而不是经典组合(当构建目录没有符号链接时):
cd /home/wakatana/rust/hello3/build
cmake /home/wakatana/rust/hello3
make
但这最终会在make 阶段出现错误:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wakatana/rust/hello3/build
make[2]: *** No rule to make target '../src/lib.rs', needed by 'src/x86_64-unknown-linux-gnu/debug/libtest_lib.a'. Stop.
CMakeFiles/Makefile2:122: recipe for target 'src/CMakeFiles/test-lib_target.dir/all' failed
make[1]: *** [src/CMakeFiles/test-lib_target.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
是否有可能以某种方式告诉 cmake/make 正确处理符号链接?
【问题讨论】:
-
那么为什么不
cd /home/wakatana/rust/hello3 && cmake -S. -B/mnt/ramdisk/rust/hello3/build/ && cmake --build /mnt/ramdisk/rust/hello3/build/? -
这按预期工作。非常感谢你。请将其发布为我可以接受的答案。一个小节点而不是
cmake -S.我必须使用cmake -S . -
呃,那个cmake选项解析。