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

Nicolas Desprès nicolas.despres at gmail.com
Thu Apr 5 16:45:12 EDT 2012


On Thu, Apr 5, 2012 at 9:44 PM, David Cole <david.cole at kitware.com> wrote:
> 2012/4/5 Alexander Neundorf <neundorf at kde.org>:
>> On Thursday 05 April 2012, Nicolas Desprès wrote:
>>> 2012/4/4 Alexander Neundorf <neundorf at kde.org>:
>>> > On Wednesday 04 April 2012, Nicolas Desprès wrote:
>>> >> 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?
>>> >
>>> > I thought the same, but I wanted to raise the question nevertheless.
>>> >
>>> >> >> > 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.
>>> >
>>> > Doesn't look like it:
>>> >
>>> > ~/src/CMake/build dir/build-Ninja$ ninja cmake.o
>>> > ninja: ERROR: unknown target 'cmake.o', did you mean 'cmake'?
>>> > ~/src/CMake/build dir/build-Ninja$ ninja Source/cmake.o
>>> > ninja: ERROR: unknown target 'Source/cmake.o'
>>> > ~/src/CMake/build dir/build-Ninja$
>>>
>>> Well we can get the list of all available target (i.e. all output file
>>> in the graph) by doing: ninja -t targets all (see the manual for all
>>> options supported by the target tool)
>>>
>>> $ ninja -t targets all | grep cmake.cxx.o
>>> Source/CMakeFiles/CMakeLib.dir/cmake.cxx.o: CXX_COMPILER
>>> Source/CMakeFiles/ccmake.dir/CursesDialog/ccmake.cxx.o: CXX_COMPILER
>>>
>>> So you will have to do:
>>> $ ninja Source/CMakeFiles/CMakeLib.dir/cmake.cxx.o
>>
>> Hmm, this may be ok for doing it manually, but not for doing it in the project
>> generator in Eclipse. I can't hardcode guessing how the object file will be
>> named, it should be one of the targets known to cmake (at least it would be
>> nice).
>>
>>
>> ...
>>> >> >> 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.
>>> >
>>> > I didn't check where GetCleanTargetName() is used, but this sounds like
>>> > for ninja it currently does not return what one would expect.
>>>
>>> I don't know what it should return then.
>>
>> I don't know either, but it sounds wrong. I mean, I can't do "ninja clean",
>> which is what GetCleanTargetName() returns.
>> Returning an empty string would seem appropriate to me (but I have no idea
>> where this function is used otherwise).
>>
>> Alex
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>
> It's only used here:
>
> davidcole at host : CMake (next)
> $ git grep GetCleanTargetName
> ChangeLog.txt:    ENH: add GetCleanTargetName() which returns "clean" for
> Source/cmExtraEclipseCDT4Generator.cxx:  if (generator->GetCleanTargetName())
> Source/cmExtraEclipseCDT4Generator.cxx:    cleanTarget =
> generator->GetCleanTargetName();
> Source/cmGlobalGenerator.h:  virtual const char* GetCleanTargetName()
>       const { return 0; }
> Source/cmGlobalNinjaGenerator.h:  virtual const char*
> GetCleanTargetName()         const { return "clean"; }
> Source/cmGlobalUnixMakefileGenerator3.h:  const char*
> GetCleanTargetName()         const { return "clean"; }
>
> If there is no "clean" target then GetCleanTargetName should return 0
> as the parent class cmGlobalGenerator does by default. If there is no
> "clean" target, then do not override GetCleanTargetName.
>
> It would be very simple to add a "clean" target that simply executes
> "ninja -t clean" as a custom command, if the ninja generator guys
> think that's a reasonable idea to keep things similar to the Makefiles
> generator.

Sounds reasonnable.

-- 
Nicolas Desprès



More information about the cmake-developers mailing list