The only CMake template with Android NDK, LinuxβWindows cross-compilation, and Gradle Managed Devices β out of the box.
Production-ready C++ template for cross-platform projects. Targets C++23/26. Ninja Multi-Config, CPM, clang-tidy, clang-format, pre-commit hooks. Packages with CPack. Tests with doctest β instrumented on Android via Gradle Managed Devices. Zero friction from clone to package on Linux, Windows, Android, and macOS.
# Desktop β full pipeline in one command
cmake --workflow --preset=gcc-full
# Android β configure + build for arm64
cmake --workflow --preset=android-arm64-full
# Linux β Windows ARM64 β cross-compile + package
cmake --workflow --preset=llvm-mingw-aarch64-fullMost CMake starters stop at "it builds on my machine." This one ships to production.
| You need | Most templates | This template |
|---|---|---|
| Android NDK | β Not even mentioned | β
4 presets (arm64, arm32, x64, x86), API 24, c++_shared, Prefab |
| Android instrumentation tests | β | β
AndroidJUnitRunner, Gradle Managed Devices (Pixel 6 ATD), doctest JNI bridge, #23 native GTest strategy |
| Linux β Windows cross-compile | β | β llvm-mingw toolchain: x86_64, i686, aarch64 |
| CMake Presets | Basic or none | β 10+ configure presets, 15+ build presets, workflow presets, schema v10 |
| Packaging | β | β CPack: tar.gz, zip, txz per platform |
| Reproducible CI | Manual Docker | β Docker images + GitHub Actions matrix |
| Code quality | Maybe clang-format | β
clang-tidy, clang-format, .cmake-format.yaml, pre-commit hooks, .editorconfig |
| C++ Standard | 17 | β 23 / 26 |
- Android NDK out of the box β not just a toolchain file. A full Gradle project with
externalNativeBuild,prefab = true, managed virtual devices, andconnectedChecktest harness. Builds.soor.aar. Seeandroid-project/. - Cross-compile from Linux to Windows β llvm-mingw toolchain included in
cmake/toolchains/. Build.exebinaries for x86_64, i686, and aarch64 Windows β no Windows machine needed. - One-command workflows β
cmake --workflow --preset=gcc-fullruns configure β build β test β package. No glue scripts. - Professional CMake architecture β
CMAKE_CURRENT_LIST_DIReverywhere (safe foradd_subdirectory/FetchContent), cross-compilation-awareCMAKE_FIND_ROOT_PATH, build-type-safe flag management. - Honest roadmap β every missing feature is a tracked issue, not a hidden gap. See open issues.
π― Click here: Use this template β Create new repository
Then clone your new repo:
git clone https://github.com/YOUR_USER/YOUR_PROJECT
cd YOUR_PROJECT# GCC β full pipeline
cmake --workflow --preset=gcc-full
# Or step by step:
cmake --preset=gcc
cmake --build --preset=gcc-release
ctest --preset=gcc-release
# Clang
cmake --workflow --preset=clang-full
# MSVC (Windows only)
cmake --workflow --preset=msvc-full# Requires: ANDROID_NDK_HOME or ANDROID_HOME set
cmake --preset=android-arm64
cmake --build --preset=android-arm64
# Run instrumented tests on device/emulator
cd android-project
./gradlew pixel_6_aosp_atd_30DebugAndroidTest
./gradlew connectedCheck# Requires: llvm-mingw installed
cmake --workflow --preset=llvm-mingw-x86_64-full
# β build/llvm-mingw-x86_64/package/cxx_project-*.zip| Platform | Preset | Generator | Test runner | Package |
|---|---|---|---|---|
| Linux (native) | gcc, clang |
Ninja Multi-Config | ctest |
.tar.gz |
| Windows (native) | msvc |
Visual Studio 17 2022 | ctest |
.zip |
| Windows (cross) | llvm-mingw-x86_64, llvm-mingw-i686, llvm-mingw-aarch64 |
Ninja Multi-Config | β (cross-compiled) | .tar.xz |
| Android arm64 | android-arm64 |
Ninja Multi-Config | gradlew connectedCheck |
β |
| Android arm32 | android-arm32 |
Ninja Multi-Config | gradlew connectedCheck |
β |
| Android x64 | android-x64 |
Ninja Multi-Config | gradlew connectedCheck |
β |
| Android x86 | android-x86 |
Ninja Multi-Config | gradlew connectedCheck |
β |
| macOS | clang (native) |
Ninja Multi-Config | ctest |
.tar.gz |
| iOS / macOS Xcode | planned #20 | Xcode | xctest / xcodebuild test |
β |
| WebAssembly | planned #2 | Emscripten | β | β |
| Feature | cmake_template | cpp-best-practices | modern-cpp-template | cmake-init |
|---|---|---|---|---|
| C++ Standard | 23 / 26 | 17 / 20 | 17 | 11+ |
| CMake Presets | β 10+ with workflows | β | β | β |
| Android NDK | β 4 ABI | β | β | β |
| Android instrumented tests | β GMD + doctest JNI | β | β | β |
| Linux β Windows cross | β llvm-mingw (3 arch) | β | β | β |
| WebAssembly | β #2 | β + Pages deploy | β | β |
| Docker / CI | β + Actions matrix | β Docker + Actions | β GitHub Actions | β |
| CPack packaging | β tar.gz / zip / txz | β | β | β |
| Sanitizers | β #9 | β ASan/UBSan | β | β |
| Fuzz testing | β | β libFuzzer | β | β |
| Code coverage | β #10 | β codecov | β codecov | β |
| macOS/iOS (Xcode) | β #20 | Limited | β | β |
| vcpkg | β #3 | β | β | β |
| GitHub Stars | β you are here | 1,700+ | 1,900+ | 900+ |
| Age | ~1 year | 3 years | 5 years | 11 years |
| License | MIT | Unlicense | Unlicense | MIT |
Honest assessment: This template leads in cross-compilation engineering (Android NDK, LinuxβWin, Presets, CPack). It trails in sanitizers, fuzz testing, and code coverage β all actively tracked in the roadmap. It does not include Qt, OpenGL, or JUCE scaffolding β those are well covered by specialized templates.
.
βββ CMakeLists.txt # Root: project(), CPM, code quality, CTest, CPack
βββ CMakePresets.json # 10+ configure, 15+ build, workflow presets
βββ cmake/
β βββ toolchains/ # llvm-mingw.cmake, future ios.cmake
β βββ code_quality/ # clang-tidy, clang-format, cpplint configs
β βββ description/ # package_description.cmake
βββ src/ # Library sources
β βββ CMakeLists.txt
βββ tests/ # doctest-based tests
β βββ CMakeLists.txt # Shared lib on Android, executable on desktop
β βββ doctest_android_jni.cpp # JNI bridge for Android instrumentation
β βββ doctest_example.cpp
βββ android-project/ # Gradle project with AGP, GMD, AndroidJUnitRunner
β βββ app/
β β βββ build.gradle # externalNativeBuild β ../../CMakeLists.txt
β β βββ src/
β β βββ main/ # NativeActivity entry point
β β βββ androidTest/ # Instrumented test wrappers
β βββ build.gradle
β βββ settings.gradle
βββ docker/ # Dockerfiles for CI reproducibility
βββ scripts/ # Build helpers
βββ docs/ # Architecture, presets, Docker guides
βββ tools/ # IWYU mappings, code quality configs
| Document | What it covers |
|---|---|
| Presets & Platforms | All CMake presets, platform support, cross-compilation details |
| Architecture | CMake design decisions, directory structure, PROJECT_IS_TOP_LEVEL pattern |
| Docker Guide | Docker images for CI, local reproducible builds |
| Contributing | How to contribute, code style, pre-commit setup |
| References | Professional CMake, modern CMake, toolchain references |
| Issue: Android native testing strategy | GTest vs doctest, Activity lifecycle, XCTest, CI/CD β research-backed |
I help teams reduce C++ build friction and ship cross-platform products faster.
Services:
- CMake architecture audits and modernisation
- Android NDK toolchain setup and Gradle integration
- CI/CD pipeline design for C++ (GitHub Actions, GitLab CI, Docker)
- Cross-compilation pipelines (LinuxβWindows, LinuxβAndroid, macOSβiOS)
- CPack packaging and distribution
- Team onboarding workshops
Why work with me:
- This template is the public portfolio β it demonstrates real engineering depth in CMake, NDK, cross-compilation, and CI
- I focus exclusively on build engineering β not general software consulting
- Every engagement starts with a concrete deliverable, not a roadmap document
| π Website | e-gleba.github.io |
| π§ Email | i@egleba.ru β fastest response |
| π¬ Discussions | GitHub Discussions |
| πΌ Rate | Up to $150/hr depending on scope |
| π Location | Remote-first, worldwide |
All planned features are tracked as GitHub issues with the enhancement label.
| Priority | Issue | Feature |
|---|---|---|
| π΄ P0 | #20 | macOS/iOS Xcode presets + XCTest |
| π΄ P0 | #9 | Sanitizers (ASan/UBSan/TSan) |
| π‘ P1 | #10 | Code coverage (codecov/CodeQL) |
| π‘ P1 | #2 | WebAssembly (Emscripten) |
| π‘ P1 | #3 | vcpkg compatibility |
| π’ P2 | #5 | C++20 modules |
| π’ P2 | #11 | Steam Runtime / Steam Deck |
| π’ P2 | #8 | Prebuilt / air-gapped dependency mode |
MIT β see license.md.
This is not a "source available" or dual-licensed project. Use it for anything β commercial products, internal tools, or as a base for your own template. Attribution appreciated but not required.
