CMake build files require CMake

CMake is a meta build system that generates build files such as Makefile, etc. consumed by the build system such as GNU Make, Ninja, etc. corresponding to the CMake Generator selected. The input files for the build system generated by CMake themselves require CMake. They are not directory portable.

The most general approach uses CMake’s build command after configuration like:

cmake -B build
cmake --build build

An equivalent alternative is to directly invoke the build tool like:

cmake -B build -G "Unix Makefiles"
make -C build


cmake -B build -G Ninja
ninja -C build

Even when directory invoking the build tool, observe that editing the CMake script then invoking the build tool directory reconfigures CMake before commencing the build.

Example: Suppose


int main(void) { return 0; }


project(hello LANGUAGES C)

add_executable(main main.c)
  • cmake -G Ninja generates a 17 kB
  • cmake -G "Unix Makefiles" generates 15 kB of three distinct Makefiles.