Hi,
I am working on a project to build&package 3rd party dependencies for an application, by calling ExternalProject_Add exclusively. This runs in linux vm-s using both Ninja and Unix Makefile generators.
The problem:
- Ninja automagically detects parallelism. Well, in practice it detects the number of host CPUs instead of the ones allocated to the VM → overcommitting and competing for resources → very slow build
- Unix Makefile runs in serial by default
What I tried:
- added parallel level, no effect:
ExternalProject_Add(
CMAKE_ARGS -DCMAKE_BUILD_PARALLEL_LEVEL=${NCORES} -DENV{CMAKE_BUILD_PARALLEL_LEVEL}=${NCORES}
...
)
- also tried to set the job pool for Ninja, by post-adjusting the target, also no effect:
set_property(GLOBAL PROPERTY JOB_POOLS builder_pool=${NCORES})
ExternalProject_Add(${target_name} ...)
set_property(TARGET ${target_name} PROPERTY JOB_POOL_COMPILE builder_pool)
set_property(TARGET ${target_name} PROPERTY JOB_POOL_LINK builder_pool)
So the question is, how can I override the number of cores for the individual builds? I only need to support Unix MakeFile and Ninja generators, so an if (CMAKE_GENERATOR EQUALS “Ninja”) … else … kind of solution is still acceptable for me (but something generic would be OK too ).