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

Brad King brad.king at kitware.com
Mon Jul 29 13:24:51 EDT 2019


On 7/29/19 11:50 AM, Dave Milter wrote:
> Only source code are generated, so main.cpp -> main.cpp.o doesn't
> depend on anything.
> But generated by cmake build.ninja still require link of extern_lib
> before starting  main.cpp -> main.cpp.o

If there are any custom commands in any targets on which main.cpp's
target depends then CMake must pessimistically assume that the
custom commands may generate a header needed to compile `main.cpp`.
Object libraries can be used to break the dependencies that lead
to the assumption.

CMake 3.9 made this much better than it used to be:

  https://gitlab.kitware.com/cmake/cmake/merge_requests/430

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.

-Brad


More information about the CMake mailing list