gpt4 book ai didi

cmake - 将 cmake 更改为二进制目录

转载 作者:行者123 更新时间:2023-12-01 10:14:51 27 4
gpt4 key购买 nike

假设我有一个项目,我已经在 .build 目录中运行了 CMake:

project/
.build/
.src

目前我必须这样做才能运行构建:

cd .build
make

我希望能够从我的项目的根目录运行 make,或许可以使用

make -f ./build/Makefile

但它不起作用。我收到这样的错误

make[1]: CMakeFiles/Makefile2: No such file or directory
make[1]: *** No rule to make target `CMakeFiles/Makefile2'. Stop.
make: *** [all] Error 2

这是因为 CMake 生成的 Makefile 假定其工作目录与其所在的位置 (.build) 相同。

是否可以让 CMake 生成一个 makefile,以便 makefile 将工作目录更改到它所在的位置?

最佳答案

你只需要告诉make你的基本目录在哪里,不需要改变cmake。

make -C your_build_directory

关于cmake - 将 cmake 更改为二进制目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2061053/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com