[cmake-developers] Supported targets with the ninja generator ?

Nicolas Desprès nicolas.despres at gmail.com
Tue Apr 3 18:52:00 EDT 2012

On Tue, Apr 3, 2012 at 10:03 PM, Alexander Neundorf <neundorf at kde.org> wrote:
> On Tuesday 03 April 2012, Alexander Neundorf wrote:
>> On Tuesday 03 April 2012, Alexander Neundorf wrote:
>> > Hi,
>> >
>> > which "additional" targets are supported with the ninja generator ?
>> >
>> > The "help" target does not seem to be supported. This would be nice.
>> >
>> > With Makefiles, for every target foo there is also a target foo/fast.
>> > This seems to be not supported currently. Is it planned ?

If I remember well the /fast version is to skip dependency checking
right? If we consider that Ninja is fast enough do we need them?

>> >
>> > With Makefiles, there are targets to
>> > - compile a single source file foo.c -> foo.o
>> > - preprocess a single source file foo.c -> foo.i
>> > - assemble (actually compile but do not assemble) a single source file
>> >
>> >          foo.c -> foo.s
>> >
>> > Those also seem not to be supported currently.
>> > Is this planned ? It would be nice.

I think both could be implemented but there is no plan.

ninja foo.o should already work I think.
ninja foo.i and ninja foo.s could be added without to much effort I think.

>> cmGlobalNinjaGenerator.h contains:
>> virtual const char* GetCleanTargetName()         const { return "clean"; }
>> but there actually no "clean" target:
>> tests/build-hello-eclipse-ninja$ ninja clean
>> ninja: ERROR: unknown target 'clean', did you mean 'ninja -t clean'?
>> Maybe it shouldn't return a valid string, since it does not really have a
>> "clean" target ?

I think it will never have a clean target since the clean tool is
quite more powerful and faster in the sense that it uses only the
dependency graph and does not require any logic in the generator.

> And one more comment: a nice feature of the makefile generators is that they
> don't only have one global "clean" target, but you can clean per-directory
> (via make clean in a subdir), and even per target
> (cmake -P CMakeFiles/foo.dir/cmake_clean.cmake).
> Having these per-target clean scripts available would be really nice.

Ninja clean tool support per-target and per-rule cleaning. See:

So for instance if you want to remove all files generated using the
CXX_EXECUTABLE_LINKER rule (which will basically remove all files
produced by a link) you can do: ninja -t clean -r

You can also remove all files generated a given target (i.e. any
output of the dependency graph) by doing: ninja -t clean <target>


More information about the cmake-developers mailing list