Skip to content

Repository files navigation

Cpp CMake Project Template

C++23 CMake Conan License Platform

Simple CMake project template for C++, supports macOS, Linux, and Windows.

Tech Stack

  • Package Manager: Conan
  • Language: C++23
  • Build: CMake 4+, Ninja
  • Static analysis & formatting: clang-format, clang-tidy

Note

For Package Manager use VCPKG, please refer to the feature/vcpkg branch.

Prerequisites

  • CMake 4+
  • Conan 2+
  • Ninja
  • clang-format
  • clang-tidy (optional)

Setup

# macOS
brew install conan

# Windows
pip install conan
  • Create a Conan profile for your platform if you haven't done so.
conan profile detect

Build

macOS / Linux

./build.sh           # Debug (default)
./build.sh Release   # Release
./build.sh --clean   # Clean build
./build.sh --format  # Format code
./build.sh --tidy    # Run clang-tidy

Windows (PowerShell)

.\build.ps1                  # Debug (default)
.\build.ps1 -Preset Release  # Release
.\build.ps1 -Clean           # Clean build
.\build.ps1 -Format          # Format code
.\build.ps1 -Tidy            # Run clang-tidy

CMake

# Install dependencies
conan install . --output-folder=build/Debug --build=missing -s build_type=Debug

# Configure
cmake --preset Debug

# Build
cmake --build --preset Debug

Test

macOS / Linux

./run_test.sh

Windows (PowerShell)

.\run_test.ps1

CMake

cd build/Debug
ctest --output-on-failure

TODO

  • Sanitizers (ASan, UBSan, TSan)
  • Code coverage (gcov / llvm-cov)
  • Benchmarking (Google Benchmark)
  • Documentation (Doxygen)
  • Package export (CMake install / Conan create)
  • Pre-commit hooks

About

a simple template for cmake project

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages