Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/franneck94/cppprojecttemplate

C++ project template with unit-tests, documentation, ci-testing and workflows.
https://github.com/franneck94/cppprojecttemplate

catch2 clang clang-format clang-tidy cmake cmakelists codecov conan coverage doxygen github-actions github-pages logging make msvc sanitizer testing vscode

Last synced: about 18 hours ago
JSON representation

C++ project template with unit-tests, documentation, ci-testing and workflows.

Awesome Lists containing this project

README

        

# Template For C++ Projects

![C++](https://img.shields.io/badge/C%2B%2B-11%2F14%2F17%2F20%2F23-blue)
![License](https://img.shields.io/github/license/franneck94/CppProjectTemplate)
![Linux Build](https://github.com/franneck94/CppProjectTemplate/workflows/Ubuntu%20CI%20Test/badge.svg)

**This is the final project of my Udemy Course**.
See here to get the full discount to all of my Udemy Courses: [Link](https://github.com/franneck94/YoutubeVideos/blob/main/EnglishCourses.md)

This is a template for modern C++ projects.
What you get is:

- Library, executable and test code separated in distinct folders
- Use of modern CMake for building and compiling
- External libraries installed and managed by
- [CPM](https://github.com/cpm-cmake/CPM.cmake) Package Manager **OR**
- [Conan](https://conan.io/) Package Manager **OR**
- [VCPKG](https://github.com/microsoft/vcpkg) Package Manager
- Unit testing using [Catch2](https://github.com/catchorg/Catch2) v2
- General purpose libraries: [JSON](https://github.com/nlohmann/json), [spdlog](https://github.com/gabime/spdlog), [cxxopts](https://github.com/jarro2783/cxxopts) and [fmt](https://github.com/fmtlib/fmt)
- Continuous integration testing with Github Actions and [pre-commit](https://pre-commit.com/)
- Code documentation with [Doxygen](https://doxygen.nl/) and [Github Pages](https://franneck94.github.io/CppProjectTemplate/)
- Tooling: Clang-Format, Cmake-Format, Clang-tidy, Sanitizers

## Structure

``` text
├── CMakeLists.txt
├── app
│ ├── CMakesLists.txt
│ └── main.cc
├── cmake
│ └── cmake modules
├── docs
│ ├── Doxyfile
│ └── html/
├── external
│ ├── CMakesLists.txt
│ ├── ...
├── src
│ ├── CMakesLists.txt
│ ├── foo/...
│ └── bar/...
└── tests
├── CMakeLists.txt
└── test_*.cc
```

Library code goes into [src/](src/), main program code in [app/](app) and tests go in [tests/](tests/).

## Software Requirements

- CMake 3.21+
- GNU Makefile
- Doxygen
- Conan or VCPKG
- MSVC 2017 (or higher), G++9 (or higher), Clang++9 (or higher)
- Optional: Code Coverage (only on GNU|Clang): gcovr
- Optional: Makefile, Doxygen, Conan, VCPKG

## Building

First, clone this repo and do the preliminary work:

```shell
git clone --recursive https://github.com/franneck94/CppProjectTemplate
mkdir build
```

- App Executable

```shell
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target main
cd app
./main
```

- Unit testing

```shell
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE="Debug"
cmake --build build --config Debug
cd build
ctest .
```

- Documentation

```shell
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --target docs
```

- Code Coverage (Unix only)

```shell
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=On
cmake --build build --config Debug --target coverage -j4
cd build
ctest .
```

For more info about CMake see [here](./README_cmake.md).