[CMake] Ninja + parallel linking

Ben Boeckel ben.boeckel at kitware.com
Fri Jul 8 11:55:45 EDT 2016


On Fri, Jul 08, 2016 at 11:40:38 -0400, Brad King wrote:
> This happens because CMake generates order-only dependencies on the
> compilation rules of each exe/lib's objects to make sure the do not
> compile until linking of dependencies is done.  This makes the build
> semantics match that of other generators where each logical target is
> treated as its own isolated build that is evaluated only when its
> logical target dependencies have been finished.
> 
> This is unfortunately necessary to get correct builds for CMake projects
> in general because we support cases where add_custom_command is used
> in library "foo" to generate a header file that is included during
> compilation in library "bar" that links to "foo", but we have no good
> way to express this dependency besides the ordering dependency of bar
> on foo.
> 
> It is likely possible to detect causes automatically when this is
> not necessary, such as when the transitive closure of a target's
> dependencies contains no custom commands.  A dedicated effort will be
> needed to investigate this further and implement such optimizations
> on the build graph generation.

There's an issue for this already:

    https://gitlab.kitware.com/cmake/cmake/issues/15555

I've brainstormed how to detect when the dependencies can be dropped
(it's on some paper around here somewhere...), but haven't implemented
it yet.

--Ben


More information about the CMake mailing list