# Cmake parallel build

**URL:** <https://discourse.cmake.org/t/cmake-parallel-build/1838>\
**Category:** Code\
**Created:** [September 14, 2020, 12:46pm UTC](https://discourse.cmake.org/t/cmake-parallel-build/1838 "2020-09-14T12:46:12Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![erk](https://discourse.cmake.org/user_avatar/discourse.cmake.org/erk/32/114_2.png) [@erk](https://discourse.cmake.org/u/erk)\
**Post date:** [September 24, 2020, 6:17pm UTC](https://discourse.cmake.org/t/cmake-parallel-build/1838/21 "2020-09-24T18:17:35Z")

</div>

> [@fdk17](#):
>
> From the CMake documentation for `--parallel [<jobs>], -j [<jobs>]` :  
> The [`CMAKE_BUILD_PARALLEL_LEVEL`](https://cmake.org/cmake/help/v3.18/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html#envvar:CMAKE_BUILD_PARALLEL_LEVEL) environment variable, if set, specifies a default parallel level when this option is not given.

You are right as already given here: [Cmake parallel build - #8 by erk](https://discourse.cmake.org/t/cmake-parallel-build/1838/8)  
however @ProTur1 is seeking a _CMake_ variable to be set in CMakeLists.txt not an _environment_ variable.

> [@ProTur1](#):
>
> It doesnt seem to me technically difficult, to set there a variable, which is expanded after `cmake --build` to .e.g. an additional `--parallel N` or `--j N` as I would like to in my case.

I don’t personally know **why** this feature does not exist, may be you can try to implement it and see by yourself.  
My _very personal_ opinion is that I don’t want the provider of a project to enforce a level of parallelism on **my build** , if want to build with full parallelism I use ninja generator. If I want to chose a constrained parallelism I build with `cmake --build --parallel <myChoice>`.  
The level of parallelism I want depends on various thing the developer of the project cannot know:

- Am I building on my dev machine or in CI ?
- Is my dev machine equipped with 4, 8 or 32 cores?
- Is the build machine dedicated to that build or shall this build be a background activity which leaves enough computing power/RAM/disk activities etc… to other processes ?  
…

So I don’t know **why** this feature does not exist but my personal opinion is AFAIK I won’t need it anytime soon.

May be you could explain why, in your point of view this is a desirable/useful feature?

---

<div class="post-metadata">

**Author:** ![ProTur1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Post date:** [September 24, 2020, 10:08pm UTC](https://discourse.cmake.org/t/cmake-parallel-build/1838/22 "2020-09-24T22:08:06Z")

</div>

> [@erk](#):
>
> May be you could explain why, in your point of view this is a desirable/useful feature?

From all the unknowns you mentioned, the cores can also be identified easily. From them, I would like to use only a part of it (although even if fully parallel, the OS scheduler should do its jobs well done as well).

Why it is useful?

- for people who want to compile foreign projects, and don’t have time or don’t want to configure and type manually
- for pushing to a build server, without command arguments for the build
- for convenience
- because it is easily possible to be realized (`cmake` offers anyhow a whole universe of functionality already)

---

<div class="post-metadata">

**Author:** ![t-RED](https://discourse.cmake.org/user_avatar/discourse.cmake.org/t-red/32/2531_2.png) [@t-RED](https://discourse.cmake.org/u/t-RED)\
**Post date:** [June 23, 2022, 1:05pm UTC](https://discourse.cmake.org/t/cmake-parallel-build/1838/23 "2022-06-23T13:05:36Z")

</div>

why not use cmake presets, there a `jobs` preset in cmake build presets here:[cmake build-presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset)

[Previous page](https://discourse.cmake.org/t/cmake-parallel-build/1838.md?page=1)
