External project does not use parallel jobs

I have an external project created with ExternalProject_Add, but this target is always being built with only one thread. Why doesn’t cmake pass the jobs flag to the external project build system?

What is the BUILD_COMMAND for the project in question?

The project is built using ninja -j12. But the external project is being built by make (CMAKE_GENERATOR “Unix Makefiles”). Of course passing BUILD_COMMAND ${MAKE} -j12 works. But I want it to be built with same number of jobs as passed on command line.

There’s no way to access that information during a build. Ninja does not include a jobserver either, so make can’t share the job pool.

The best things available are:

  • If using the Makefiles generator and make internally, pass no -j flags and let the environment communicate the job server information.
  • If using Ninja (or any other non-Makefiles generator) is involved, pass explicit -j flags to the ExternalProject’s make command. I would recommend making a cache variable to allow for tuning this count.