Is it possible to do following? I have a cmake project, I can build it using, say, 16 threads. but in this cmake I include some other project which build as a part of the parent project. The child project cannot be build with 16 thread, for some reason, lets say it has heavily templated code and the machine just gets out of memory. This child project is known to finish the build successfully if number of compile jobs limited to 4. How do I achieve maximum build performance without switching the whole project to be built with 4 jobs only? Something that will dynamically change the job pool once child project starts to build to 4 and then will increase it back to 16 once the problematic project was compiled.
Asked
Active
Viewed 260 times
1
-
What about just: Step 1. Build child project with 4 threads. Step 2. Build parent project with 16 threads? – KamilCuk Jun 29 '20 at 11:59
-
like running build twice with different `-j` options and different targets? – kreuzerkrieg Jun 29 '20 at 12:06
-
Yes, that what I have in mind. `cmake --build . --target child --parallel 4` followed by `cmake --build . --target parent --parallel 16`. I _think_ you may define [a new job pool](https://cmake.org/cmake/help/v3.7/prop_gbl/JOB_POOLS.html) and then use [JOB_POOL_COMPILE](https://cmake.org/cmake/help/v3.0/prop_tgt/JOB_POOL_COMPILE.html) to compile on that pool, but I never delved into that. – KamilCuk Jun 29 '20 at 12:21
-
hm... it may do the trick. will try right away – kreuzerkrieg Jun 29 '20 at 12:22
-
@KamilCuk looks like it worked well! Please convert your comment to answer – kreuzerkrieg Jun 29 '20 at 18:17
1 Answers
1
Just build it separately twice:
cmake --build . --target child --parallel 4
# followed by
cmake --build . --target parent --parallel 16
I think alternatively you may create a job pool with 4 workers and assign that job pool to the child target.

KamilCuk
- 120,984
- 8
- 59
- 111