[CMake] cmake + ninja how to use several CPU cores?

Brad King brad.king at kitware.com
Mon Jul 29 15:32:04 EDT 2019


On 7/29/19 3:22 PM, Dave Milter wrote:
>> Since then all objects in a target can start compiling independently
>> so long as that target does not depend on any targets with custom
>> commands.

See also https://gitlab.kitware.com/cmake/cmake/issues/17097

> Is any way to tell cmake that add_custom_command is have no side effect,
> and OUTPUT is exactly what it produces?

Even if we had that information we don't know what `main.cpp` includes
until after compiling it, by which point it is too late.  It could have
`#include "anything.txt"` for example.  CMake must add these pessimistic
dependencies to ensure a correct build.

The only way to avoid this is to tell CMake that there are no dependencies
for compiling an object file by moving it to an object library that does
not depend on any of the targets with custom commands.

-Brad


More information about the CMake mailing list