[cmake-developers] [PATCH] Ninja: Optionally skip library dependencies for object targets
Brad King
brad.king at kitware.com
Tue Mar 15 10:06:12 EDT 2016
On 03/14/2016 07:39 PM, Matthias Männich wrote:
> increase build parallelism by omitting dependencies of object file
> targets to the libraries they will be linked with in a later step.
Nice. I like the idea of doing that, but I think it can be made
automatic and safe without an explicit option with a bit more work.
Let's see how far we can get without resorting to an explicit option.
It would be nice to avoid an option because then every project can
benefit immediately and we do not have to worry about accidentally
breaking dependencies by activating the option incorrectly.
The only reason we make object compilations order-only depend on
target-level dependencies is to support generated header files and
other custom command outputs. For example:
add_custom_command(OUTPUT foo.h ...)
add_library(foo foo.c foo.h)
add_library(bar bar.c)
target_link_libraries(bar foo)
The order-only dependency of `bar.c.o` on the target `foo` is just
in case `bar.c` needs to include `foo.h`. It is a conservative
approach and does generate many unneeded dependencies in practice.
With a bit of analysis the Ninja generator could detect when `foo`
has no custom commands and does not have a target-level dependency
on other targets with custom commands. Then dependencies on `foo`
from compilations in `bar` could be omitted automatically.
Thanks,
-Brad
More information about the cmake-developers
mailing list