A small CMake script for setup-free, cross-platform, reproducible C++ dependency management.
CPM.cmake is a lightweight CMake script that provides dependency management for C++ projects. It wraps CMake's FetchContent module to add version control, caching, and a simple API for downloading and building dependencies directly from source. It solves the problem of managing external libraries in CMake projects without requiring external package managers or system-wide installations.
C++ developers and teams using CMake who need a simple, reproducible way to manage project dependencies without the overhead of full-fledged package managers. It's especially useful for projects that prioritize cross-platform compatibility and source-based distribution.
Developers choose CPM.cmake because it integrates seamlessly into existing CMake workflows with minimal setup, ensures reproducible builds through version locking, and avoids the complexity of external package managers. Its simplicity and focus on CMake-native solutions make it a pragmatic choice for dependency management.
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Just add a single CMake script to your project; no separate installation or packaging is required, as highlighted in the 'Setup-Free Integration' feature.
Uses git commits or tags to lock dependency versions, guaranteeing consistent builds across environments, per the 'Version-Controlled Dependencies' section.
Works with all CMake toolchains and generators, ensuring portability across different operating systems and build environments.
With CPM_SOURCE_CACHE, projects can be configured offline once dependencies are cached locally, reducing reliance on internet connectivity.
The CPMAddPackage function provides a concise syntax for adding dependencies from various sources like GitHub, GitLab, or direct URLs, simplifying CMakeLists.txt.
Every new build directory downloads and builds dependencies from scratch, increasing build times; the README admits this as a limitation and recommends caching workarounds.
Many libraries lack CMakeLists that work well as subprojects, requiring manual configuration—acknowledged in the 'Limitations' section as a common issue.
In diamond-shaped dependency graphs, the first added version is used, which can lead to warnings and require manual resolution or package lock files, as noted in the limitations.
Including CPM.cmake sets several CMake policies to NEW, which might break existing code expecting OLD behavior, requiring manual adjustments in some cases.