Skip to the content.

CMake Parallel Build with All Cores

Recently, while trying to compile Traffic Server, came across very poor performance issues, turns out the build was only taking one core, and so in order to use all the cores on the system, we can use -j or --parallel to specify the number of jobs to run in parallel.

Example

cmake --build build -j $(nproc --all)

# or

cmake --build build --parallel $(nproc --all)

Note: This will use up all the cores/threads on the system, which may mean the system becomes very slow, and laggy. So, one may choose to free up a CPU by using following command.

cmake --build build --parallel $(($(nproc --all) - 1))

Source(s):

Reference: CMake - Documentation