{"id":45388939,"url":"https://github.com/ramsafin/modern-cpp-project-template","last_synced_at":"2026-02-21T18:15:59.764Z","repository":{"id":300831615,"uuid":"1007293397","full_name":"ramsafin/modern-cpp-project-template","owner":"ramsafin","description":"Modern C++ project template","archived":false,"fork":false,"pushed_at":"2026-02-01T09:46:35.000Z","size":191,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-01T19:59:18.801Z","etag":null,"topics":["clang","clang-format","clang-tidy","clangd","cmake","cmake-presets","coverage","cpp","cppcheck","gcc","github-actions","google-benchmark","google-test","sanitizer","template","vscode"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ramsafin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-23T19:08:13.000Z","updated_at":"2026-02-01T09:46:39.000Z","dependencies_parsed_at":"2025-07-16T00:58:01.666Z","dependency_job_id":"4825ee13-5336-4e2c-b481-545a0769887b","html_url":"https://github.com/ramsafin/modern-cpp-project-template","commit_stats":null,"previous_names":["ramsafin/modern-cpp-project-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/ramsafin/modern-cpp-project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsafin%2Fmodern-cpp-project-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsafin%2Fmodern-cpp-project-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsafin%2Fmodern-cpp-project-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsafin%2Fmodern-cpp-project-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramsafin","download_url":"https://codeload.github.com/ramsafin/modern-cpp-project-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsafin%2Fmodern-cpp-project-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29689665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","clang-format","clang-tidy","clangd","cmake","cmake-presets","coverage","cpp","cppcheck","gcc","github-actions","google-benchmark","google-test","sanitizer","template","vscode"],"created_at":"2026-02-21T18:15:59.175Z","updated_at":"2026-02-21T18:15:59.759Z","avatar_url":"https://github.com/ramsafin.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modern C++ Project Template\n\n\u003e ⚡A clean starter for modern C++20 projects with CMake Presets, testing, benchmarking, sanitizers, coverage, and developer tooling.\n\n[![CI](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/ci.yml/badge.svg)](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/ramsafin/modern-cpp-project-template/graph/badge.svg?token=946M7LEQA2)](https://codecov.io/gh/ramsafin/modern-cpp-project-template)\n[![Clang-Format](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/clang-format.yml/badge.svg)](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/clang-format.yml)\n[![Clang-Tidy](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/clang-tidy.yml/badge.svg)](https://github.com/ramsafin/modern-cpp-project-template/actions/workflows/clang-tidy.yml)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n\n## Table of Contents\n\n- [Features](#features)\n- [Project Structure](#project-structure)\n- [Prerequisites](#prerequisites)\n- [Build Presets](#build-presets)\n- [Workflow Presets](#workflow-presets)\n- [Building and Testing](#building-and-testing)\n- [Sanitizers](#sanitizers)\n- [Benchmarking](#benchmarking)\n- [Coverage](#coverage)\n- [Developer Tooling](#developer-tooling)\n- [Installation](#installation)\n- [Package](#packaging)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Modern C++20+**: fully enabled C++20 with support for upgrading to C++23\n- **CMake Presets**: reproducible, platform‑agnostic builds via `CMakePresets.json`\n- **Testing**: integrated with GoogleTest using `gtest_discover_tests()`\n- **Benchmarking**: optional benchmarks with Google Benchmark\n- **Sanitizers**: ASan and UBSan runtime checks\n- **Coverage**: `gcovr`-powered HTML reports\n- **Developer Tooling**: `clang-format`, `clang-tidy`, `cppcheck` custom targets\n- **Installation**: provides `find_package(...)` integration with proper exports\n- **CI-Ready**: GitHub Actions for builds, linting, testing, and formatting\n\n## Project Structure\n\n```text\nmodern-cpp-project-template/\n├── .github/workflows/   # CI pipelines for GitHub Actions\n├── .vscode/             # VS Code workspace settings\n├── app/                 # Optional demo application\n├── benchmarks/          # Google Benchmark performance tests\n├── cmake/               # Custom CMake modules (Options, Flags, Helpers, etc.)\n├── include/             # Public library headers\n├── src/                 # Library source files\n├── tests/               # Unit tests (GoogleTest)\n├── .clang-format        # Formatting rules\n├── .clang-tidy          # Static analysis configuration\n├── .clangd              # Clangd language server settings\n├── .editorconfig        # Editor consistency rules\n├── .gitignore           # Git ignore patterns\n├── CMakeLists.txt       # Top-level build configuration\n├── CMakePresets.json    # Build, test, and workflow presets\n├── LICENSE              # Apache 2.0 license\n└── README.md            # Project documentation\n```\n\n## Prerequisites\n\nBefore building the project, make sure the following tools are installed on your system:\n- **CMake ≥ 3.23** (tested with 3.28+)\n- **C++ Compiler**: GCC ≥ 10 or Clang ≥ 12\n- **Ninja** (optional; recommended), or your generator of choice\n- **gcovr** (for code coverage reports)\n- **clang-format**, **clang-tidy**, **cppcheck** (optional diagnostics)\n\n\u003e Tools not found are skipped with a warning; features gated by CMake option.\n\n## Build Presets\n\nThis project uses [**CMake Presets**](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) to simplify configuration.\n\n| **Preset**          | **Notes**                                              |\n| :------------------ |:------------------------------------------------------ |\n| `Debug`             | Debugging with no optimizations                        |\n| `Release`           | Optimized builds without debug symbols                 |\n| `RelWithDebInfo`    | Optimized build with debug symbols (**recommended**)   |\n| `Sanitize`          | Builds with runtime checks enabled (ASan/UBSan)        |\n| `Coverage`          | Builds instrumented for coverage reporting             |\n| `Release-Bench`     | Builds Release + benchmarks                            |\n\nList available presets:\n```bash\ncmake --list-presets\n```\n\n## Workflow Presets\n\n| **Preset**          | **Notes**                                           |\n| :------------------ |:--------------------------------------------------- |\n| `check-sanitize`    | `Sanitize` → build → run tests                      |\n| `coverage-report`   | `Coverage` → build → run tests → *(generate report) |\n| `dist`              | `RelWithDebInfo` → build → package via `CPack`      |\n\nList available workflow presets:\n```bash\ncmake --workflow --list-presets\n```\n\nRun workflows with:\n```bash\ncmake --workflow --preset check-sanitize\n```\n\n## Building and Testing\n\nConfigure and build:\n```bash\ncmake --preset gcc-RelWithDebInfo\ncmake --build --preset gcc-RelWithDebInfo\n```\n\nRun unit tests:\n```bash\nctest --preset gcc-RelWithDebInfo\n```\n\n## Sanitizers\n\n```bash\ncmake --preset gcc-Sanitize\ncmake --build --preset gcc-Sanitize\nctest --preset gcc-Sanitize\n```\n\nor run the workflow:\n\n```bash\ncmake --workflow --preset check-sanitize\n```\n\n## Benchmarking\n\n```bash\ncmake --preset gcc-Release-Bench\ncmake --build --preset gcc-Release-Bench --target benchmarks\n./build/gcc-Release-Bench/benchmarks/benchmarks\n```\n\n## Coverage\n\n```bash\ncmake --preset gcc-Coverage\ncmake --build --preset gcc-Coverage\nctest --preset gcc-Coverage\ncmake --build --preset gcc-Coverage --target coverage\n```\n\nor run the workflow:\n```bash\ncmake --workflow --preset coverage-report\ncmake --build --preset gcc-Coverage --target coverage\n```\n\n\u003e Find the report in `build/gcc-Coverage/coverage.xml`\n\n## Developer Tooling\n\n### Code Formatting\n\nFormat all C++ files using `.clang-format`.\n\nCheck formatting:\n```bash\ncmake --preset gcc-RelWithDebInfo\ncmake --build --preset gcc-RelWithDebInfo --target format-check\n```\n\nReformat everything:\n```bash\ncmake --build --preset gcc-RelWithDebInfo --target format\n```\n\n\u003e Use a pre-commit hook to automatically check formatting before each commit.\n\n### Static Analysis\n\nRun `clang-tidy` analysis:\n```bash\ncmake --preset gcc-RelWithDebInfo\ncmake --build --preset gcc-RelWithDebInfo --target clang-tidy\n```\n\n\u003e Configurable via `.clang-tidy`, with selective checks enabled.\n\nRun `cppcheck` analysis:\n```bash\ncmake --preset gcc-RelWithDebInfo\ncmake --build --preset gcc-RelWithDebInfo --target cppcheck\n```\n\n## Installation\n\n```bash\ncmake --preset gcc-RelWithDebInfo\ncmake --build --preset gcc-RelWithDebInfo\ncmake --install build/gcc-RelWithDebInfo --prefix install  # or /usr/local\n```\n\n- This installs the library to the `install/` directory.\n- You can also install system-wide with `--prefix /usr/local` (requires `sudo`).\n\n\nAfter installation, consume the library like this in another CMake project:\n```bash\nfind_package(modern_cpp REQUIRED)\nadd_executable(my_app ...)\ntarget_link_libraries(my_app PRIVATE modern_cpp::library)\n```\n\nMake sure CMake knows where to find the installed package:\n```bash\ncmake -DCMAKE_PREFIX_PATH=/path/to/install ..\n```\n\n## Packaging\n\nOnce you’ve built your release­‐type binaries (e.g. `RelWithDebInfo`), you can produce `.tar.gz` and `.zip` archives via CPack:\n\nUse package presets:\n```bash\ncmake --preset gcc-Release\ncmake --build --preset gcc-Release\ncpack --preset package-gcc-Release\n```\n\nor workflow preset:\n```bash\ncmake --workflow --preset gcc-Release-dist\n```\n\n\u003e This generates `.tar.gz` and `.zip` archives in `build/gcc-Release`.\n\n## Contributing\n\nPull requests are welcome. Please ensure:\n- Code passes all tests\n- Code is formatted and clang-tidy clean\n- Commits follow clear, atomic changes\n\n## License\n\nThis project is licensed under the **Apache License 2.0**.\n\nYou are free to use, modify, distribute, and include this code in commercial or open-source projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsafin%2Fmodern-cpp-project-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framsafin%2Fmodern-cpp-project-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsafin%2Fmodern-cpp-project-template/lists"}