让cmake从源代码构建而不包含脚本? [英] Getting cmake to build out of source without wrapping scripts?

查看:181
本文介绍了让cmake从源代码构建而不包含脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让cmake建立一个目录'build',如 project / build ,其中CMakeLists.txt在 project /

I'm trying to get cmake to build into a directory 'build', as in project/build, where the CMakeLists.txt is in project/.

我知道我可以做:

mkdir build
cd build
cmake ../

但这是麻烦。我可以把它放在一个脚本并调用它,但然后提供不同的参数cmake(如-GMSYS Makefiles),或者我需要在每个平台上编辑这个文件是不愉快的。

but that is cumbersome. I could put it in a script and call it, but then it's unpleasant to provide different arguments to cmake (like -G "MSYS Makefiles"), or I would need to edit this file on each platform.

我最好在主CMakeLists.txt中做类似SET(CMAKE_OUTPUT_DIR build)的东西。请告诉我这是可能的,如果是,如何?

Preferably I would do something like SET(CMAKE_OUTPUT_DIR build) in the main CMakeLists.txt. Please tell me that this is possible, and if so, how? Or some other out of source build method that makes it easy to specify different arguments?

推荐答案

您可以使用未记录的CMake选项 -H -B 以指定源和二进制目录 cmake

You can use the undocumented CMake options -H and -B to specify the source and binary directory upon invoking cmake:

cmake -H. -Bbuild -G "MSYS Makefiles"

这将查找 CMakeLists。 txt ,并在其中创建 build 文件夹(如果它还不存在)。

This will look for the CMakeLists.txt in the current folder and create a build folder (if it does not yet exist) in it.

这篇关于让cmake从源代码构建而不包含脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆