1

While building my android project, cmake runs several instances of clang++.exe that eat up my machine's resources. Is there a way to limit this? Would such a solution lead to longer build times?

Here is a screenshot of my resource map: resource status

I have the following package versions:

android studio: 4.0.1

ndk: 21.3.6528147

cmake:3.10.2

Deto114
  • 11
  • 2
  • See https://stackoverflow.com/questions/51557585/limit-cpu-cores-for-ndkbuild-with-cmake-and-ninja/ – Michael Jul 31 '20 at 06:05
  • I did go through the thread, however the most-voted solution requires a minimum cmake v3.11, which is something I would like to avoid for now. – Deto114 Jul 31 '20 at 20:04
  • I updated my cmake to v3.11 and tried out [this solution](https://stackoverflow.com/a/51567570/14022225) as highlighted by @michael, I am still facing the same problem. – Deto114 Jul 31 '20 at 21:10

1 Answers1

0

Your screenshot indicates you are generating for the Ninja build system... so... If building through the CMake executable, documented here, you would use:

cmake --build . -- -j 8

which would build with up to 8 CPUs in parallel. (Change 8 to however many instances you'd like.)

If just building using Ninja directly, you would use something like:

ninja -j 8

to achieve the same effect.

Shaun
  • 341
  • 3
  • 7
  • Thanks for the comment, is there a way to do this via the `externalNativeBuild{ cmake {...}}` environment? – Deto114 Aug 25 '20 at 00:23
  • There doesn't appear to be a way via `externalNativeBuild`, though I'm not too familiar with development on Android. There may be a way, externally, with some `Ninja` configuration related to [Pools](https://ninja-build.org/manual.html#ref_pool)? – Shaun Sep 28 '20 at 14:28