Skip to content

maorgershman/cpp-template

Repository files navigation

C++26 Project Template

A clean, modern template for bootstrapping C++26 projects. It is specifically tailored for a seamless IDE experience using VSCode Remote Development (WSL on Windows or Lima on macOS) targeting Ubuntu 24.04+.

Core Features

  • Modern C++26: Configured for GCC 15+ to utilize the latest standard features like std::print.
  • CMake 4.0+: Utilizes modern CMake patterns, requiring at least version 4.0.
  • vcpkg Integration: Dependency management is streamlined via a vcpkg git submodule and a vcpkg.json manifest.
  • VSCode Ready: Includes CMakePresets.json and .vscode/settings.json configured for the Ninja generator, providing out-of-the-box IntelliSense, formatting, and debugging.
  • Strict Compilation: Enforces extensive non-trivial compiler warnings (e.g., -Wshadow, -Wconversion, -Wpedantic).
  • Sanitizers Built-in: Debug builds automatically enforce -Werror and enable AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan).
  • Testing: Pre-configured with Catch2 and CTest for immediate test-driven development.

Prerequisites

  • OS: Ubuntu 24.04 or higher (running natively, or via WSL/Lima).
  • Compiler: GCC >= 15.
  • Build System: CMake >= 4.0 and Ninja.
  • IDE: Visual Studio Code with the C/C++ and CMake Tools extensions installed on the remote host.

Setup Instructions

  1. Connect to Remote: Open VSCode and connect to your remote environment (WSL, Lima, etc).

  2. Setup a new project:

    git clone git@github.com:maorgershman/cpp-template my-project
    cd my-project
    rm -rf .git vcpkg
    git init
    git submodule add git@github.com:microsoft/vcpkg
    git add .
    git commit -m "Initial commit"
  3. Open Folder: Open the my-project folder in VSCode.

  4. Customize: Consider customizing README.md and LICENSE to your project's needs.

  5. Enjoy!

    • The CMake Tools extension will automatically detect the debug preset.
    • Use the Configure, Build, Debug, and Test buttons in the VSCode status bar or sidebar.
    • All dependencies (like Catch2) and sanitizers (ASan, UBSan) are handled automatically through the IDE interface.

Note: The template includes vcpkg as a submodule. Because git clone does not fetch submodules by default, the directory will appear empty after cloning. The setup step above replaces it with a fresh submodule owned by the new repository.

License

This project is licensed under the MIT License.

About

C++26 template with CMake, vcpkg, VSCode, and built-in testing & sanitizers for Ubuntu 24.04+.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages