# 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:** 1\
**Showing post:** 12

<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 14, 2020, 5:17pm UTC](https://discourse.cmake.org/t/cmake-parallel-build/1838/12 "2020-09-14T17:17:06Z")

</div>

You do not really answer my question.

- If you do invoke `make` then you may define make options in your environment `MAKEFLAGS=-j5`
- if you do invoke `cmake --build` then you may `CMAKE_BUILD_PARALLEL_LEVEL=5`

In any case this is a user choice so such config ought to stay in user’s hand not in the CMakeLists.txt

You may invoke such parallel build using a `custom_target` if you prefer that:

```cmake
add_custom_target(my_parallel_build 
                      COMMAND ${CMAKE_COMMAND} --build -j 5
                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
                      COMMENT "My parallel build with 5 cores")

```

and then you would invoke:  
`make my_parallel_build`

---

_[View the full topic](https://discourse.cmake.org/t/cmake-parallel-build/1838)._
