# kitware/cmake architecture

> Architecture diagram of the GitHub repository kitware/cmake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kitware/cmake
- Repository: https://github.com/kitware/cmake

## Overview

CMake is a cross-platform build-system generator. The principal workflow is that a project author supplies CMake language files and configuration options; CMake configures project state, then emits build files for a selected native build tool. The repository also contains CTest’s test and reporting functionality, CPack’s package generators, and GUI front ends. Paths and capabilities are supported by the supplied tree and README; sampled headers are partial, so internal call wiring beyond the primary workflow is intentionally limited.

Main entry points: [`Source/cmCommands.h`](https://github.com/kitware/cmake/blob/master/Source/cmCommands.h) (CMake language), [`Source/cmGlobalGenerator.h`](https://github.com/kitware/cmake/blob/master/Source/cmGlobalGenerator.h) (Build generators), [`Source/cmcmd.h`](https://github.com/kitware/cmake/blob/master/Source/cmcmd.h) (CMake CLI), [`Source/cmCTest.h`](https://github.com/kitware/cmake/blob/master/Source/cmCTest.h) (CTest runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configure["Configure project"]
  node_cmake_cli["CMake CLI<br/>[cmcmd.h]"]
  node_language["CMake language<br/>[cmCommands.h]"]
  node_state["Project state<br/>[cmState.h]"]
  node_cache[("Configure cache<br/>[cmCacheManager.h]")]
  node_find["Dependency discovery"]
  node_target_model["Target model<br/>[cmTarget.h]"]
end

subgraph group_generate["Build generation"]
  node_generators["Build generators"]
  node_ninja["Ninja generator"]
  node_make["Make generators"]
  node_ide["IDE generators"]
end

subgraph group_test_package["Test and package"]
  node_ctest["CTest runner<br/>[cmCTest.h]"]
  node_test_handler["Test execution"]
  node_coverage["Coverage reporting"]
  node_cpack["CPack packaging<br/>[cmCPackGenerator.h]"]
  node_package_formats["Package formats"]
end

subgraph group_interfaces["User interfaces"]
  node_qt_gui["Qt configure GUI<br/>[QCMake.h]"]
  node_terminal_gui["Terminal configure UI<br/>[cmCursesMainForm.h]"]
end

node_author(("Project author"))
node_build_tool["Native build tool"]

node_author -->|"provides project"| node_cmake_cli
node_cmake_cli -->|"evaluates scripts"| node_language
node_cmake_cli -->|"loads options"| node_cache
node_language -->|"updates state"| node_state
node_language -->|"invokes discovery"| node_find
node_language -->|"defines targets"| node_target_model
node_state -->|"supplies project state"| node_generators
node_cache -->|"persists options"| node_state
node_generators -->|"selects generator"| node_ninja
node_generators -->|"selects generator"| node_make
node_generators -->|"selects generator"| node_ide
node_ninja -->|"writes build files"| node_build_tool
node_make -->|"writes build files"| node_build_tool
node_ide -->|"writes project files"| node_build_tool
node_author -->|"runs tests"| node_ctest
node_ctest -->|"dispatches tests"| node_test_handler
node_ctest -->|"dispatches coverage"| node_coverage
node_author -->|"requests package"| node_cpack
node_cpack -->|"generates package"| node_package_formats
node_author -->|"configures project"| node_qt_gui
node_author -->|"configures project"| node_terminal_gui

click node_cmake_cli "https://github.com/kitware/cmake/blob/master/Source/cmcmd.h"
click node_language "https://github.com/kitware/cmake/blob/master/Source/cmCommands.h"
click node_state "https://github.com/kitware/cmake/blob/master/Source/cmState.h"
click node_cache "https://github.com/kitware/cmake/blob/master/Source/cmCacheManager.h"
click node_find "https://github.com/kitware/cmake/blob/master/Source/cmFindPackageCommand.h"
click node_target_model "https://github.com/kitware/cmake/blob/master/Source/cmTarget.h"
click node_generators "https://github.com/kitware/cmake/blob/master/Source/cmGlobalGenerator.h"
click node_ninja "https://github.com/kitware/cmake/blob/master/Source/cmGlobalNinjaGenerator.h"
click node_make "https://github.com/kitware/cmake/blob/master/Source/cmGlobalUnixMakefileGenerator3.h"
click node_ide "https://github.com/kitware/cmake/blob/master/Source/cmGlobalVisualStudioGenerator.h"
click node_ctest "https://github.com/kitware/cmake/blob/master/Source/cmCTest.h"
click node_test_handler "https://github.com/kitware/cmake/blob/master/Source/CTest/cmCTestTestHandler.h"
click node_coverage "https://github.com/kitware/cmake/blob/master/Source/CTest/cmCTestCoverageHandler.h"
click node_cpack "https://github.com/kitware/cmake/blob/master/Source/CPack/cmCPackGenerator.h"
click node_package_formats "https://github.com/kitware/cmake/blob/master/Source/CPack/cmCPackRPMGenerator.h"
click node_qt_gui "https://github.com/kitware/cmake/blob/master/Source/QtDialog/QCMake.h"
click node_terminal_gui "https://github.com/kitware/cmake/blob/master/Source/CursesDialog/cmCursesMainForm.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cmake_cli,node_language,node_state,node_cache,node_find,node_target_model toneBlue
class node_generators,node_ninja,node_make,node_ide toneAmber
class node_ctest,node_test_handler,node_coverage,node_cpack,node_package_formats toneMint
class node_qt_gui,node_terminal_gui toneRose
class node_author,node_build_tool toneIndigo
```

## Components

### Configure project

- [CMake CLI](https://github.com/kitware/cmake/blob/master/Source/cmcmd.h): `Source/cmcmd.h`
- [CMake language](https://github.com/kitware/cmake/blob/master/Source/cmCommands.h): `Source/cmCommands.h`
- [Project state](https://github.com/kitware/cmake/blob/master/Source/cmState.h): `Source/cmState.h`
- [Configure cache](https://github.com/kitware/cmake/blob/master/Source/cmCacheManager.h): `Source/cmCacheManager.h`
- [Dependency discovery](https://github.com/kitware/cmake/blob/master/Source/cmFindPackageCommand.h): `Source/cmFindPackageCommand.h`
- [Target model](https://github.com/kitware/cmake/blob/master/Source/cmTarget.h): `Source/cmTarget.h`

### Build generation

- [Build generators](https://github.com/kitware/cmake/blob/master/Source/cmGlobalGenerator.h): `Source/cmGlobalGenerator.h`
- [Ninja generator](https://github.com/kitware/cmake/blob/master/Source/cmGlobalNinjaGenerator.h): `Source/cmGlobalNinjaGenerator.h`
- [Make generators](https://github.com/kitware/cmake/blob/master/Source/cmGlobalUnixMakefileGenerator3.h): `Source/cmGlobalUnixMakefileGenerator3.h`
- [IDE generators](https://github.com/kitware/cmake/blob/master/Source/cmGlobalVisualStudioGenerator.h): `Source/cmGlobalVisualStudioGenerator.h`

### Test and package

- [CTest runner](https://github.com/kitware/cmake/blob/master/Source/cmCTest.h): `Source/cmCTest.h`
- [Test execution](https://github.com/kitware/cmake/blob/master/Source/CTest/cmCTestTestHandler.h): `Source/CTest/cmCTestTestHandler.h`
- [Coverage reporting](https://github.com/kitware/cmake/blob/master/Source/CTest/cmCTestCoverageHandler.h): `Source/CTest/cmCTestCoverageHandler.h`
- [CPack packaging](https://github.com/kitware/cmake/blob/master/Source/CPack/cmCPackGenerator.h): `Source/CPack/cmCPackGenerator.h`
- [Package formats](https://github.com/kitware/cmake/blob/master/Source/CPack/cmCPackRPMGenerator.h): `Source/CPack/cmCPackRPMGenerator.h`

### User interfaces

- [Qt configure GUI](https://github.com/kitware/cmake/blob/master/Source/QtDialog/QCMake.h): `Source/QtDialog/QCMake.h`
- [Terminal configure UI](https://github.com/kitware/cmake/blob/master/Source/CursesDialog/cmCursesMainForm.h): `Source/CursesDialog/cmCursesMainForm.h`

### Other components

- **Project author**
- **Native build tool**

## Connections

- Project author → CMake CLI: provides project
- CMake CLI → CMake language: evaluates scripts
- CMake CLI → Configure cache: loads options
- CMake language → Project state: updates state
- CMake language → Dependency discovery: invokes discovery
- CMake language → Target model: defines targets
- Project state → Build generators: supplies project state
- Configure cache → Project state: persists options
- Build generators → Ninja generator: selects generator
- Build generators → Make generators: selects generator
- Build generators → IDE generators: selects generator
- Ninja generator → Native build tool: writes build files
- Make generators → Native build tool: writes build files
- IDE generators → Native build tool: writes project files
- Project author → CTest runner: runs tests
- CTest runner → Test execution: dispatches tests
- CTest runner → Coverage reporting: dispatches coverage
- Project author → CPack packaging: requests package
- CPack packaging → Package formats: generates package
- Project author → Qt configure GUI: configures project
- Project author → Terminal configure UI: configures project
