[cmake-developers] Ninja generator on Windows

Peter Kümmel syntheticpp at gmx.net
Sat Feb 4 10:30:11 EST 2012


On 04.02.2012 11:48, Bill Hoffman wrote:
>
>>>
>>> Why does the ninja generator need to use&&?  I am pretty sure the other
>>> CMake generators do not need to use&&.
>>>
>>
>> Most of them come from the working directory: cd foo&&   g++
>> They could be worked around easly by adding a new variable to the rules.
>>
> Seems like there should be a better way to run a command in a directory.
>    Does ninja have a working directory at all?  I guess you are saying
> there is a way to do this with a variable in the rules... Not sure what
> that means, but if it works... :)
>> Others comes from the support of PRE_BUILD, POST_BUILD, and custom
>> target / commands with more than one command. In ninja, contrary to
>> make, when specifying a build statement (e.g. foo.o: foo.c foo.h) you
>> can "attach" only one rule (e.g. one command) and not several like in
>> make.
>>
> Right, so, if there is more than one command, you can turn it into one
> command by creating a small cmake script that runs consecutive
> execute_process calls.
>
>> They have been several discussion thread for adding basic "shell"
>> features like in Ninja:
>> - redirection
>> - environment variable
>> - working directory
>> - chainning
>>
>> There is no patch proposal yet AFAIK.

But now ;)
http://groups.google.com/group/ninja-build/browse_thread/thread/a8d98805d2f06230

The patch adds && support and for long command lines response files are used.

With this patched ninja I can build CMake on Windows!

But it seems the ninja generator is buggy atm. It generates link options
which could not be moved into a response file (/lib).
And it defines obsolete compiler options which produce much warning noise.

With this patch in ninja we don't have to change much in the generator,
only the compiler specific stuff, which we must fix anyway.

Peter


> Sure, so until then, I think the above should be fine to get this
> working on windows.  No one should be depending on redirection or
> chaining in cmake projects.
>
> -Bill



More information about the cmake-developers mailing list