# pr0g/cmake-examples

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/pr0g-cmake-examples).**

1,231 stars · 66 forks · CMake · MIT

## Links

- GitHub: https://github.com/pr0g/cmake-examples
- awesome-repositories: https://awesome-repositories.com/repository/pr0g-cmake-examples.md

## Topics

`cmake` `cmake-examples` `cmake-scripts` `cmakelists`

## Description

This project provides a collection of minimal, modern configuration templates designed to demonstrate industry-standard practices for managing C and C++ build workflows. It serves as a practical guide for developers to implement build automation, dependency management, and project structuring using the CMake build system.

The repository distinguishes itself by offering modular examples that cover complex build requirements, such as hierarchical project organization and the integration of external third-party source code. It emphasizes the use of target-based dependency graphs and interface-based library exporting to ensure that include paths, compiler flags, and preprocessor definitions propagate correctly across components.

The examples encompass a broad range of capabilities, including cross-platform build environment configuration, automated installation of binaries and headers, and the generation of compilation databases for external analysis tools. It also addresses common development tasks like managing multiple build configurations, handling system-level dependencies, and configuring header-only libraries.

The documentation provides a structured approach to standardizing project layouts and automating build sequences to ensure consistent results across different operating systems.

## Tags

### DevOps & Infrastructure

- [CMake Integrations](https://awesome-repositories.com/f/devops-infrastructure/cicd-pipeline-automation/core-build-engines/build-systems/cmake-integrations.md) — Defines project structures, compiler flags, and build targets using standardized CMake scripts.
- [Build Systems](https://awesome-repositories.com/f/devops-infrastructure/cicd-pipeline-automation/core-build-engines/build-systems.md) — Provides a collection of minimal, modern configuration templates for managing complex build systems and dependency graphs.
- [Cross-Platform Installers](https://awesome-repositories.com/f/devops-infrastructure/distribution-packaging/software-distribution/native-installers/cross-platform-installers.md) — Packages compiled binaries and headers into standard directory structures for cross-platform installation.

### Development Tools & Productivity

- [Build Automation](https://awesome-repositories.com/f/development-tools-productivity/workflow-automation-tools/build-task-automation/build-automation.md) — Provides standardized configuration and build sequences to streamline C++ development lifecycles. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/core/README.md))
- [Compilation Database Generators](https://awesome-repositories.com/f/development-tools-productivity/compilers-toolchains/cross-compilation-tooling/android-ndk-configurations/compilation-database-generators.md) — Produces standardized JSON files mapping source files to compiler commands for integration with external code analysis tools.
- [Build Definition Languages](https://awesome-repositories.com/f/development-tools-productivity/build-definition-languages.md) — Uses domain-specific languages to declaratively define software build processes and project structures.
- [Dependency Graph Runners](https://awesome-repositories.com/f/development-tools-productivity/dependency-graph-runners.md) — Builds directed acyclic graphs of components where properties propagate automatically to dependent targets.
- [Build Artifact Isolation](https://awesome-repositories.com/f/development-tools-productivity/build-tooling/build-orchestration-logic/build-orchestration-configuration/build-configuration-systems/build-output-directories/build-artifact-isolation.md) — Separates source code from generated build artifacts to keep project directories clean and support multiple build configurations.
- [Package Dependency Managers](https://awesome-repositories.com/f/development-tools-productivity/package-dependency-managers.md) — Downloads and incorporates external project source code directly into the build process to simplify dependency management. ([source](https://github.com/pr0g/cmake-examples#readme))
- [Source Fetchers](https://awesome-repositories.com/f/development-tools-productivity/workspace-management/project-workspaces/external-dependency-graph-integrators/source-fetchers.md) — Downloads and integrates third-party source code during the configuration phase to ensure dependencies are compiled within the same environment.
- [Build Configurations](https://awesome-repositories.com/f/development-tools-productivity/build-tooling/build-orchestration-logic/build-orchestration-configuration/build-configuration-systems/build-configurations.md) — Supports multiple build configurations like Debug and Release to manage environment-specific build parameters. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/core/README.md))
- [Header-Only Libraries](https://awesome-repositories.com/f/development-tools-productivity/header-only-libraries.md) — Defines interface requirements and compiler flags for libraries consisting solely of header files to ensure correct propagation. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/more))

### Software Engineering & Architecture

- [Library Dependency Managers](https://awesome-repositories.com/f/software-engineering-architecture/library-compatibility-managers/library-dependency-managers.md) — Automates the integration, fetching, and configuration of third-party C++ library dependencies. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/core))
- [Library Interfaces](https://awesome-repositories.com/f/software-engineering-architecture/library-interfaces.md) — Defines public-facing requirements for libraries to ensure downstream consumers receive correct include paths and preprocessor definitions.
- [Project Organization](https://awesome-repositories.com/f/software-engineering-architecture/project-management-governance/repository-maintenance/project-organization.md) — Provides modular templates and hierarchical project structures to improve maintainability and separation of concerns in C++ projects.

### Part of an Awesome List

- [Build Systems](https://awesome-repositories.com/f/awesome-lists/devtools/build-systems.md) — Practical examples for various CMake scenarios.
- [Project Templates](https://awesome-repositories.com/f/awesome-lists/devtools/project-templates.md) — Collection of simple, modern project examples.

### Programming Languages & Runtimes

- [External Library Integrations](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/external-library-integrations.md) — Downloads and incorporates third-party source code directly into the build process so external libraries are compiled alongside the main project. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/more/fetch-content))
- [Preprocessors](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/systems-languages/c/preprocessors.md) — Passes custom macros to the compiler during the generation phase to enable conditional compilation logic. ([source](https://github.com/pr0g/cmake-examples#readme))

### Web Development

- [Dependency Management](https://awesome-repositories.com/f/web-development/third-party-integrations/dependency-management.md) — Provides automated systems for tracking and integrating third-party source code dependencies into the build process. ([source](https://github.com/pr0g/cmake-examples/blob/main/examples/more))
