# CppProjectTemplate **Repository Path**: NiceBlueChai/CppProjectTemplate ## Basic Information - **Project Name**: CppProjectTemplate - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-06-03 - **Last Updated**: 2025-07-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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). ## References [Clang-Format Style Options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) [Clang-Format Style Options [zh]](https://www.cnblogs.com/PaulpauL/p/5929753.html)