Skip to content

Latest commit

Β 

History

History
128 lines (86 loc) Β· 2.45 KB

File metadata and controls

128 lines (86 loc) Β· 2.45 KB

mcppdev

mcppdev is a simple, modern C++23 development skeleton.
It serves as a reference template for setting up a C++ project that uses C++20/23 Modules, Google Test, and Google Benchmark, all orchestrated by a modern CMake configuration.

The goal of this repository is to provide a minimal but correct example of how a modern C++ project can be structured today.


πŸš€ Features

  • C++23 Standard
    Configured for the latest standard (e.g. <print>, std::println).

  • C++ Modules
    Demonstrates how to define, compile, and import custom C++ modules (.cppm) using CMake’s CXX_MODULES file set.

  • Dependency Management
    Uses CMake FetchContent to automatically download and build dependencies.

  • Testing
    Integrated Google Test setup.

  • Benchmarking
    Integrated Google Benchmark setup.


πŸ“‚ Project Structure

.
β”œβ”€β”€ benchmarks/          # Google Benchmark code
β”‚   └── benchmark.cpp
β”œβ”€β”€ src/                 # Main source code and C++ Modules
β”‚   β”œβ”€β”€ cppmhello.cppm   # Example C++ module
β”‚   └── main.cpp         # Main entry point
β”œβ”€β”€ tests/               # Unit tests
β”‚   └── test.cpp
β”œβ”€β”€ CMakeLists.txt       # CMake build configuration
└── build.sh             # Build helper script

πŸ›  Prerequisites

To build this project, you need tools with C++23 and Modules support:

  • CMake: 3.30 or newer
  • Compiler (one of):
    • Clang 16+
    • GCC 14+
    • MSVC (Visual Studio 2022)
  • Build System:
    • Ninja (recommended)
    • Make

⚠️ Note: C++ Modules support is still evolving.
Exact compiler and CMake versions matter, especially when mixing modules with testing and benchmarking.


▢️ Building

Using the helper script

./build.sh

Manual build (recommended)

cmake -S . -B build -G Ninja
cmake --build build

▢️ Running the Application

After a successful build, run the main executable:

./build/run_main

Example Output

Hello mcppdev
Hello module mcppdev

This confirms that:

  • The main executable was built correctly
  • The C++ module (cppmhello.cppm) was successfully compiled and imported

πŸ§ͺ Running Tests

After building, run:

ctest --test-dir build

or

./build/run_tests

πŸ“Š Running Benchmarks

./build/run_benchmarks

πŸ“„ License

MIT