Code Monkey home page Code Monkey logo

cppprojecttemplate's Introduction

Template For C++ Projects

C++ License Linux Build codecov

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

  • Library, executable and test code separated in distinct folders
  • Use of modern CMake for building and compiling
  • External libraries installed and managed by
    • CPM Package Manager OR
    • Conan Package Manager OR
    • VCPKG Package Manager
  • Unit testing using Catch2 v2
  • General purpose libraries: JSON, spdlog, cxxopts and fmt
  • Continuous integration testing with Github Actions and pre-commit
  • Code coverage reports, including automatic upload to Codecov
  • Code documentation with Doxygen and Github Pages
  • Tooling: Clang-Format, Cmake-Format, Clang-tidy, Sanitizers

Structure

├── CMakeLists.txt
├── app
│   ├── CMakesLists.txt
│   └── main.cc
├── cmake
│   └── cmake modules
├── docs
│   ├── Doxyfile
│   └── html/
├── external
│   ├── CMakesLists.txt
│   ├── ...
├── src
│   ├── CMakesLists.txt
│   ├── my_lib.h
│   └── my_lib.cc
└── tests
    ├── CMakeLists.txt
    └── main.cc

Library code goes into src/, main program code in app/ and tests go in 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): lcov, gcovr
  • Optional: Makefile, Doxygen, Conan, VCPKG

Building

First, clone this repo and do the preliminary work:

git clone --recursive https://github.com/franneck94/CppProjectTemplate
make prepare
  • App Executable
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target main
cd app
./main
  • Unit testing
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --target unit_tests
cd tests
./unit_tests
  • Documentation
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --target docs
  • Code Coverage (Unix only)
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
cmake --build . --config Debug --target coverage

For more info about CMake see here.

cppprojecttemplate's People

Contributors

franneck94 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.