CMake build parallel

CMake environment variable CMAKE_BUILD_PARALLEL_LEVEL can be manually set to control default number of build parallel threads. Parallel builds are virtually always desired to save build and rebuild time. As a starting point, perhaps set CMAKE_BUILD_PARALLEL_LEVEL environment variable to be equal to the number of physical or logical CPU cores by setting it in the user profile:

# Linux
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)

# macOS
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.physicalcpu)

# Windows, in environment variable settings
CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS%

# BSD
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu)

If the computer runs out of RAM, reduce the specific command parallelism with the cmake --build --parallel N command line option. For Ninja build systems, specific targets can control the number of workers with job pools.