# How to get the number of build jobs ?

**URL:** https://discourse.cmake.org/t/how-to-get-the-number-of-build-jobs/8687
**Category:** Usage
**Created:** [August 7, 2023, 7:52am UTC](https://discourse.cmake.org/t/how-to-get-the-number-of-build-jobs/8687 "2023-08-07T07:52:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nim65s](https://discourse.cmake.org/user_avatar/discourse.cmake.org/nim65s/32/3687_2.png) [@nim65s](https://discourse.cmake.org/u/nim65s)
#### Post date: [August 7, 2023, 7:52am UTC](https://discourse.cmake.org/t/how-to-get-the-number-of-build-jobs/8687/1 "2023-08-07T07:52:38Z")

</div>

Hi,

I can see that `cmake --build . -j N` and `export CMAKE_BUILD_PARALLEL_LEVEL=N` will pass this number to the generator.

Is there a way to get this number in a variable in a CMakeLists.txt or something ?

My current use case is that I have an `ExternalProject_Add()` with basically a `BUILD_COMMAND` containing a `make`, and I would like to add `-jN` there.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [August 7, 2023, 11:31am UTC](https://discourse.cmake.org/t/how-to-get-the-number-of-build-jobs/8687/2 "2023-08-07T11:31:58Z")

</div>

> [@nim65s](#):
>
> Is there a way to get this number in a variable in a CMakeLists.txt or something ?

No; this is a build-time thing. If what you wanted were possible, CMake would need to reconfigure the project anytime `ninja -jN` is passed in case it is different.

One possible solution is something like [this](https://gitlab.kitware.com/paraview/common-superbuild/-/blob/5c3ff860ff739168dffd32b063a4a18def2d7586/cmake/SuperbuildExternalProject.cmake#L25) (follow where the variable is used). Note that there is infrastructure this is riding on, but you should be able to do this in your `BUILD_COMMAND` bits directly.
