Understanding the CMake build process
CMake’s build process works in two steps, as shown in the following diagram. First, if it’s invoked without any special flags, CMake scans the system for any usable toolchains during the configuration process and then decides what its output should be. The second step, which is when cmake --build
is invoked, is the actual compilation and building process:
Figure 1.3 – CMake’s two-stage build process
The standard output is Unix Makefiles unless the only detected compiler is Microsoft Visual Studio, in which case a Visual Studio solution (.sln
) will be created.
To change the generator, you can pass the -G
option to CMake, like this:
cmake .. -G Ninja
This will generate files to be used with Ninja (https://ninja-build.org/), an alternative build generator. Many generators are available for CMake. A list of the ones that are supported natively can be found on CMake’s website...