Unified CMake Module Manager
A centralized repository for discovering, selecting, and integrating third-party CMake modules.
CMakeHub is a unified CMake module manager that provides a "central warehouse" for CMake modules. It solves the problem of scattered CMake modules across different GitHub repositories, making it easy to discover, select, and integrate them into your projects.
Important: CMakeHub is not a package manager like vcpkg or Conan. It's a module manager that helps you find and use CMake modules more easily.
- 🔍 Unified Discovery: Browse and search for CMake modules in one place
- 🚀 Simple Integration: Load modules with a single command
- 🔄 Automatic Dependencies: Modules automatically declare and load their dependencies
⚠️ Conflict Detection: Prevents loading incompatible modules- ✅ Version Checking: Ensures compatibility with your CMake and C++ versions
- 💾 Smart Caching: Download once, use everywhere (shared across projects)
- 📄 License Management: Automatically track module licenses for compliance
- ⚙️ Config Penetration: Pass parameters directly to modules
- 🏷️ Version Selection: Specify exact module versions
- 🔎 Module Search: Search modules by name, description, or tags
- 📊 Dependency Visualization: Generate dependency graphs
- 🧹 Cache Management: View and clean module cache
- 🌍 Cross-Platform Filtering: Automatic platform compatibility warnings
- 🔄 Update Management: Easy module updates via cache clearing
- ✅ Compatibility Check: Verify module compatibility before loading
- 💻 Command Line Interface: CLI tool for quick module discovery and management
# Clone CMakeHub
git clone https://github.com/caomengxuan666/CMakeHub.git
cd CMakeHub
# Or add as a submodule
git submodule add https://github.com/caomengxuan666/CMakeHub.git cmake/cmakehub# Install CLI tool from PyPI (requires Python 3.6+)
pip install cmakehub
# Or clone repository and install locally
git clone https://github.com/caomengxuan666/CMakeHub.git
cd CMakeHub
pip install -e .After installation, you can use the CLI tool:
cmakehub --help
cmakehub list
cmakehub search sanitizers# In your CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(MyProject CXX)
# Include CMakeHub
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmakehub/loader.cmake)
# Load modules
cmakehub_use(sanitizers)
cmakehub_use(coverage)
# Now use the modules' features
enable_testing()
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE mylib)# Set cache directory (optional)
set(CMH_CACHE_DIR "$ENV{HOME}/.cmakehub/cache")
# Enable verbose output (optional)
set(CMAKEHUB_VERBOSE ON)
# Set version check mode (STRICT, WARNING, SILENT)
set(CMAKEHUB_VERSION_CHECK_MODE "STRICT")cmakehub_use(sanitizers
ADDRESS_SANITIZER ON
UNDEFINED_SANITIZER ON
)cmakehub_use(cotire VERSION "master")
cmakehub_use(cpm VERSION "0.42.0")# List all available modules
cmakehub_list()
# Search for modules
cmakehub_search(sanitizer)
cmakehub_search(testing)# Check if a module is compatible with your system
cmakehub_check_compatibility(sanitizers)
# List all compatible modules
cmakehub_list_compatible_modules()# View cache information
cmakehub_cache_info()
# Clear specific module cache
cmakehub_cache_clear(sanitizers)
# Clear all cache
cmakehub_cache_clear()# Update specific module (clears cache)
cmakehub_update(sanitizers)
# Update all used modules
cmakehub_update()# Generate dependency graph
cmakehub_dependency_graph(dependencies.dot)
# Convert to PNG (requires Graphviz)
# dot -Tpng dependencies.dot -o dependencies.png# Get detailed information about a module
cmakehub_info(sanitizers)
# Show licenses of all loaded modules
cmakehub_show_licenses()CMakeHub includes a Python CLI tool for quick module discovery and management without needing to write CMake code.
# Install CLI tool
pip install -e .
# Or globally
python setup.py install# List all modules
cmakehub list
# List modules in a category
cmakehub list --category testing
cmakehub list -c code_quality
# Compact output
cmakehub list --compact# Search by keyword
cmakehub search sanitizers
cmakehub search testing
# Case-insensitive search
cmakehub search Sanitizers# Display detailed module information
cmakehub info sanitizers
cmakehub info cotire# Check if a module is compatible with your system
cmakehub check sanitizers
cmakehub check cotire# Show cache statistics
cmakehub cache
# Clear all cache
cmakehub cache --clear
# Clear specific module cache
cmakehub cache --clear sanitizers# Update specific module (clears cache)
cmakehub update sanitizers
# Update all modules
cmakehub update
# Update and download immediately
cmakehub update --download-now
cmakehub update sanitizers --download-now# Generate CMake code for a module
cmakehub use sanitizers
# Specify version
cmakehub use cotire --version master
cmakehub use cotire -v master
# Add options
cmakehub use sanitizers ADDRESS_SANITIZER ON UNDEFINED_SANITIZER ON
# Save to file
cmakehub use sanitizers --output my_project/CMakeLists.txt
# Append to existing file
cmakehub use cotire --append CMakeLists.txt
# Add test
cmakehub use doctest --test# Create a new CMakeHub project
cmakehub init my_project
cd my_projectThis creates a complete project structure:
my_project/
├── CMakeLists.txt
├── cmake/
│ └── hub/
│ └── loader.cmake
├── src/
│ └── main.cpp
├── .gitignore
└── README.md
# Find modules for testing
cmakehub search testing
cmakehub list --category testing
# Check if a module is compatible
cmakehub check sanitizers# Create a new project with CMakeHub
cmakehub init my_app
cd my_app
# Add modules
cmakehub use sanitizers --append CMakeLists.txt
cmakehub use coverage --append CMakeLists.txt# View cache size
cmakehub cache
# Clear outdated modules
cmakehub update --download-now| Feature | CLI | CMake API |
|---|---|---|
| List modules | ✅ cmakehub list |
✅ cmakehub_list() |
| Search modules | ✅ cmakehub search |
✅ cmakehub_search() |
| Get module info | ✅ cmakehub info |
✅ cmakehub_info() |
| Check compatibility | ✅ cmakehub check |
✅ cmakehub_check_compatibility() |
| Cache management | ✅ cmakehub cache |
✅ cmakehub_cache_info() |
| Update modules | ✅ cmakehub update |
✅ cmakehub_update() |
| Load modules | ❌ (use cmakehub use) |
✅ cmakehub_use() |
| Dependency graph | ❌ | ✅ cmakehub_dependency_graph() |
| Generate CMake code | ✅ cmakehub use |
❌ |
| Initialize project | ✅ cmakehub init |
❌ |
CMakeHub includes 48 curated CMake modules organized by category:
- cotire: Precompiled headers and unity builds
- lto_optimization: Link Time Optimization (LTO/IPO)
- precompiled_header: Precompiled header setup
- cpp_standards: C++ standards configuration
- c_standards: C standards configuration
- compile_options: Compiler options management
- sanitizers: ASan, UBSan, TSan, MSan integration
- coverage: Code coverage with gcov/lcov
- coverage_cg: Code coverage from cginternals
- clang_tidy_tools: Clang-Tidy integration
- clang_tidy_cg: Clang-Tidy from cginternals
- cppcheck_cg: Cppcheck integration
- compiler_warnings: Compiler warning helpers
- code_formatter: clang-format integration
- afl_fuzzing: AFL fuzzing instrumentation
- gcov: Gcov coverage tool
- launchers: Create launcher scripts for IDEs
- compiler_info: Get compiler information
- cpm: Lightweight CMake package manager
- conan: Conan package manager integration
- android_toolchain: Android NDK toolchain
- ios_toolchain: iOS/macOS/watchOS/tvOS toolchain
- cuda: CUDA auxiliary functions
- use_folders: Enable IDE folders (MSVC)
- qt_helper: Qt integration helper
- add_gtest: Google Test integration
- doctest: Doctest testing framework
- catch2_cmake: Catch2 testing framework
- find_or_build_gtest: Find or build GTest
- afl_fuzzing: AFL fuzzing
- doxygen_helper: Doxygen documentation helpers
- dependency_graph: Generate dependency graphs
- component_install: Component installation helpers
- runtime_dependencies: Runtime dependencies management
- git_version: Get git revision description
- export_header: Generate template export header
- find_assimp: Find ASSIMP 3D model library
- find_egl: Find EGL library
- find_ffmpeg: Find FFMPEG video library
- find_glesv2: Find OpenGL ES 2.0
- find_glew: Find GLEW OpenGL library
- find_gtk3: Find GTK3 GUI library
- find_gtk4: Find GTK4 GUI library
- find_hidapi: Find HIDAPI USB library
- find_nodejs: Find Node.js
- find_sdl2: Find SDL2 game library
- glsl_shaders: GLSL shader compilation support
- find_or_build_gtest: Find or build GTest
For detailed module documentation, see docs/modules/
Load a CMake module with optional version and parameters.
cmakehub_use(sanitizers)
cmakehub_use(cotire VERSION "master")
cmakehub_use(sanitizers ADDRESS_SANITIZER ON)Load all modules in a category.
cmakehub_use_category(code_quality)List all available modules.
cmakehub_list()Search for modules by name, description, or tags.
cmakehub_search(sanitizer)
cmakehub_search(testing)Display detailed information about a module.
cmakehub_info(sanitizers)Check if a module is compatible with your system.
cmakehub_check_compatibility(sanitizers)List all modules compatible with current CMake version.
cmakehub_list_compatible_modules()Display cache information.
cmakehub_cache_info()Clear cache for specific module or all modules.
cmakehub_cache_clear(sanitizers)
cmakehub_cache_clear() # Clear allGenerate a DOT graph of module dependencies.
cmakehub_dependency_graph(dependencies.dot)Update specific module or all used modules (clears cache).
cmakehub_update(sanitizers)
cmakehub_update() # Update allDisplay licenses of all loaded modules.
cmakehub_show_licenses()See the examples/ directory for complete examples:
examples/basic/: Basic usage with sanitizers and coverageexamples/advanced/: Advanced features demonstration
Run the examples:
cd examples/basic
mkdir build && cd build
cmake ..
cmake --build .
./myapp # Linux/macOS
myapp.exe # WindowsFor advanced examples:
cd examples/advanced
mkdir build && cd build
cmake ..
cmake --build .Run the test suite:
# Run all tests
python tests/run_tests.py
# Run specific test
python tests/run_single_test.py test_loader_basic
python tests/run_single_test.py test_cache
python tests/run_single_test.py test_version_check
python tests/run_single_test.py test_dependencies
python tests/run_single_test.py test_conflicts
# Validate all modules
cmake -P tests/verify_modules.cmake
# Test new features
cmake -P tests/test_new_features.cmake- CMake: 3.19 or higher
- Python: 3.6 or higher (for tests only)
- Internet connection: Required for downloading modules
CMakeHub caches downloaded modules in ~/.cmakehub/cache/ (or %USERPROFILE%/.cmakehub/cache/ on Windows). Cache is shared across projects, so you only download each module once.
Cache structure:
~/.cmakehub/cache/
├── sanitizers/
│ └── master/
│ ├── cmake/
│ │ └── FindSanitizers.cmake
│ └── .cmh_meta.json
└── cotire/
└── master/
├── CMake/
│ └── cotire.cmake
└── .cmh_meta.json
CMakeHub automatically checks module requirements:
- CMake version: Ensures your CMake version meets the module's minimum requirement
- C++ standard: Warns if the module requires a higher C++ standard
- Platform compatibility: Warns if module is not compatible with current platform
Version check modes:
- STRICT (default): Fails on version mismatch
- WARNING: Shows a warning but continues
- SILENT: Disables version checking
Modules can declare dependencies:
{
"name": "module_a",
"dependencies": ["module_b", "module_c"]
}When you load module_a, CMakeHub automatically loads module_b and module_c first.
Modules can declare conflicts:
{
"name": "cpm",
"conflicts": ["conan", "vcpkg"]
}If you try to load cpm and conan together, CMakeHub will show an error.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Note: Each module has its own license. See THIRD_PARTY_LICENSES.md for complete license information or use cmakehub_show_licenses() to view all licenses and ensure compliance.
We welcome contributions! See CONTRIBUTING.md for guidelines.
- v0.1: Initial release with 48 modules
- v0.2: Add more modules, improve documentation
- v1.0: Stable API, web interface
- v1.1: IDE plugins, advanced features
CMakeHub is built on the work of many talented CMake module authors:
- arsenm/sanitizers-cmake
- bilke/cmake-modules
- sakra/cotire
- rpavlik/cmake-modules
- cpm-cmake/CPM.cmake
- conan-io/cmake-conan
- StableCoder/cmake-scripts
- cginternals/cmake-init
- taka-no-me/android-cmake
- leetal/ios-cmake
- larsch/cmake-precompiled-header
- catchorg/Catch2
- doctest/doctest
- And many others!
For complete list, see THIRD_PARTY_LICENSES.md
Made with ❤️ by the CMakeHub community