问题描述
在使用CMake和Make构建项目时,您可以从构建树的子目录(即,从包含顶层 make code> Makefile )和 make
将(据我所知)在该目录或该目录下构建所有目标。这是因为CMake会为每个包含目标的目录生成一个 Makefile
,因此,当您位于具有目标的目录中时, make
查找用于构建目标的 Makefile
。
When building a project using CMake and Make, you can execute make
from a subdirectory of your build tree (i.e. from a directory below whatever directory contains your top-level Makefile
), and make
will (as far as I can tell) build all targets at or below that directory. This is because CMake generates a Makefile
for every directory that contains targets, so when you're in a directory with targets, make
finds the Makefile
for building those targets.
当CMake生成忍者文件时,它仅生成 one build.ninja
文件,它位于构建树的顶层。因此,从顶级目录以外的其他目录调用 ninja
失败(即使 -f
选项也不起作用因为 ninja
找不到 rules.ninja
文件)。
When CMake generates Ninja files, however, it only generates one build.ninja
file, which is at the top level of the build tree. So calling ninja
from a directory other than the top-level directory fails (even the -f
option doesn't work because ninja
can't find the rules.ninja
file).
是否有任何方法可以模拟在目录中或目录以下构建目标的类似制造行为?据我所知,没有对应于特定目录下及以下的所有目标的Ninja目标。 (可以使用以每个目录命名的伪造目标进行模拟,该目标取决于该目录下和该目录下的所有目标,但是CMake默认情况下不会生成此类目标。)
Is there any way to emulate the "make-like" behavior of building targets at and below a directory? As far as I can tell, there are no Ninja targets that correspond to "all targets at and below a particular directory." (This could be emulated using phony targets named after each directory that depend on all targets at and below that directory, but CMake does not generate such targets by default.)
推荐答案
ninja< DIR> / all
适用于最新版本的Ninja(1.7.2)。版本1.3.4不允许这样做。
ninja <DIR>/all
works with recent versions of Ninja (1.7.2). Version 1.3.4 does not allow this.
我在。但是,CMake在记录了此文件:
I could not find a reference to this on the manual. However, CMake has this documented here:
对于项目的每个子目录子目录,还会生成其他目标:
For each subdirectory sub/dir of the project, additional targets are generated:
- sub / dir / all
取决于子目录所需的所有目标。 - sub / dir / install
运行 - sub / dir / test
运行子目录中的测试步骤(如果有)。 - sub / dir / package
运行子目录中的package步骤(如果有)。
- sub/dir/all
Depends on all targets required by the subdirectory. - sub/dir/install
Runs the install step in the subdirectory, if any. - sub/dir/test
Runs the test step in the subdirectory, if any. - sub/dir/package
Runs the package step in the subdirectory, if any.
这篇关于忍者相当于Make的“从此目录向下构建”功能(使用CMake)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!