我正在Centos上使用cmake3(版本3.6.1)。在以前的CMake版本中,我可以使用-B
选项指定构建目录:
cmake -GNinja -B build
有了这样,所有的临时文件,如CMakeCache.txt
都存储在构建文件夹中。现在使用cmake3,我不再看到-B
选项了。是否有不同的选项?
我正在Centos上使用cmake3(版本3.6.1)。在以前的CMake版本中,我可以使用-B
选项指定构建目录:
cmake -GNinja -B build
有了这样,所有的临时文件,如CMakeCache.txt
都存储在构建文件夹中。现在使用cmake3,我不再看到-B
选项了。是否有不同的选项?
-B
选项:
然而,这个功能仍然存在。你仍然可以使用cmake [<options>] (<path-to-source> | <path-to-existing-build>)
-B
指定构建目录的位置(当前目录是默认值)。这个选项以及-H
用于指定源目录,是许多CMake版本中两个未记录的命令行选项(参见this答案)。-B
选项的功能,并且仍然广泛使用,CMake在CMake 3.13中将其添加回文档中。最新的documentation描述了一直存在的-B
行为。
cmake [<options>] -S <path-to-source> -B <path-to-build>
Uses
<path-to-build>
as the build tree and<path-to-source>
as the source tree. The specified paths may be absolute or relative to the current working directory. The source tree must contain aCMakeLists.txt
file. The build tree will be created automatically if it does not already exist. For example:$ cmake -S src -B build
-S
选项指定源目录是新的,但未记录的 -H
选项也允许您指定源目录。这个 -H
选项应该在 CMake 3.6 中可用,并且实际上仍然可以在最新版本的 CMake(3.16)中使用。 - Kevin