When converting custom commands for the ninja build system we
need to make sure that any file dependencies that exist in the build
tree are converted to phony targets. This tells ninja that these
files might not exist when starting the build, but could be generated
during the build.
This is done by tracking all dependencies for custom command targets.
After all have been written out we remove all items from the set
that have been seen as a target, custom command output, an alias,
or a file in the source directory. Anything that is left is considered
to be a file that will be generated as a side effect of another
custom command.
To properly track the usage of dependencies that are generated at
compile time as the side effect of other build steps we need
to make the WriteBuild and WritePhonyBuild commands non static
Extend the cmGlobalGenerator::GenerateBuildCommand virtual method
signature with a "projectDir" parameter specifying the top of the
project build tree for which the build command will be generated.
Populate it from call sites in cmGlobalGenerator::Build where a
fully-generated build tree should be available.
When linking with cmake and vs_link_* the command line
could be too long for cmd.exe, which needs not to be
called in this case. (was not cached by a test)
Introduce rules which don't use the shell and use this
rule when there are no pre or post step.
For free we get a small speedup, because cmd is then
not called.
Also be more accurate when estimating the
command line length.
When MinGW is used slashes are used for dependencies
because ar.exe can't read rsp files with backslashes.
Many thx to Claus Klein for starting working on this.
Implement cmGlobalGenerator::ComputeTargetObjects in the Ninja generator
to pre-compute all the object file names. Use the results during
generation instead of re-computing it later.
Generally these are only required in build statements, as Ninja wants
to be able to chop paths up. But it doesn't hurt to also try to use
them in command line arguments.