CMake Two-Step Build Process

Since CMake 3.13 was released in 2018, a more elegant two-step CMake build process is available with the simple syntax

cmake -B ./build

cmake --build ./build

The CMake configure command with the “-B” option generates the build system files in the specified build directory. It’s best to build out-of-source in general, so we specify a separate “./build” directory here.

The cmake –build build command executes the build tool configured for the project, e.g. Make, Ninja, MSBuild, etc.

The “./” can be omitted, we only include it here for clarity. We keep seeing even the largest OEMs using the old-fashioned three-step process. Check your projects’ example and docs to update them to the less-confusing and compact two-step CMake build process.