CMake Flags & Options
Cross-platform build system generator.All CMake pages
- cmake --build build --target NAME: build only one targetcmake --build build --target NAME builds one target and its dependencies; since CMake 3.15, -t takes several. Use --target help to list them, clean to clean.
- cmake -DCMAKE_BUILD_TYPE=Release: set Debug or Release buildscmake -DCMAKE_BUILD_TYPE=Release picks the configuration for single-config generators like Ninja. Multi-config generators ignore it: use --config Release.
- cmake -G: choose the generator (Ninja, Unix Makefiles, Visual Studio)cmake -G selects the build system: Ninja, Unix Makefiles, Visual Studio, Xcode. Names are case-sensitive and a build directory cannot switch generators later.
- cmake -S . -B build: set the source and build directoriescmake -S . -B build configures a project from the source directory into a separate build directory; cmake --build build then compiles it. Since CMake 3.13.