cmake
cross-platform build system generator
TLDR
SYNOPSIS
cmake [options] source-dir
DESCRIPTION
cmake is a cross-platform build system generator. It reads platform-independent CMakeLists.txt project descriptions and generates native build files for the user's chosen build tool, including Unix Makefiles, Ninja, Visual Studio solutions, and Xcode projects.The typical workflow involves a configure step that generates build files in an out-of-source build directory, followed by a build step that invokes the native build tool. CMake handles dependency detection, compiler feature checks, and library discovery through its find-module system.CMake is the dominant build system for C and C++ projects, and also supports Fortran, CUDA, and other languages. It includes CTest for test automation and CPack for creating distributable packages.
PARAMETERS
-B dir
Build directory-S dir
Source directory (default: current)-G generator
Build system generator (Unix Makefiles, Ninja, Xcode)-D var=value
Set CMake variable--build dir
Build project--install dir
Install project--preset name
Use configure preset-j N
Parallel build jobs (passed to the underlying build tool).--target target
Build a specific target instead of the default.--verbose
Enable verbose build output.--clean-first
Clean before building.-DCMAKE_INSTALL_PREFIX=path
Set installation prefix directory.-DCMAKE_CXX_COMPILER=compiler
Specify the C++ compiler.-DCMAKE_BUILD_TYPE=type
Build type: Debug, Release, RelWithDebInfo, or MinSizeRel.
CAVEATS
Complex syntax for advanced features. Learning curve steep. Generated files can be large. Cache issues require cleaning. Version differences cause compatibility issues. Some find it overcomplicated for simple projects.
HISTORY
CMake was created by Bill Hoffman and Ken Martin at Kitware in 2000 to address the complexity of cross-platform builds, becoming widely adopted by 2010.
