/cpp_skeleton

C++ Projekt Skeleton

Primary LanguageCMakeBoost Software License 1.0BSL-1.0

C++ Skeleton Build Status Coverage Status

Your standard C++ project skeleton

Disclaimer

This is buggy and unfinished, use at your own risk!

This project is a fork from Hana's build system, so all of the credit goes to Louis Dione for the great work he is doing. It also steals some ideas from the build systems of Paul Fultz II FIT's library and Eric Niebler's range-v3 library. It is released under the Boost Software license, but note that some of the libraries that are optionally provided might have a different license.

Overview

Setting up a modern C++ project with Continuous Integration is a time-consuming task. The amount of tools available is daunting, and one really wants to use them all: CMake, gh-pages and Doxygen for documentation, Travis-CI for continuous integration, Coveralls for displaying code coverage reports, clang-format for auto-formatting, valgrind, sanitizers, swang, static-analyzer, and many more!

The aim of this project is to give you a fully-functional starting point for your own projects, so that you can skip setting up most of these tools correctly. Every project is different tho, so we expect you to modify your build system over time. This skeleton is just there to give you the fundamentals, anything else is up to you! Send a PR if you find something is missing.

What you get

  • CMake as a meta-build system:
    • debug/release builds,
    • high-optimization for release builds,
    • extensive warnings enabled out-of-the-box,
    • support for running tests and examples with valgrind and AddressSanitizer,
    • support for generating code coverage from tests and examples.
  • Travis-CI is used for unit-testing:
  • Coveralls shows per-line code coverage.
  • Automatic Doxygen documentation generation and deployment to gh-pages.

Getting started

  1. Fork this repository and check-out your fork.
  2. Add your repository to Travis-CI and Coveralls.
  3. Run bootstrap.py script to configure it to your needs.
    • Replace the secure token with your own and create a gh-pages branch that is empty.
  4. Commit your changes to your repository (including the gh-pages branch).
  5. Start working on your project.

CMake configuration options

  • PROJECT_NAME_ENABLE_VALGRIND: Run the unit tests and examples under valgrind if it is found.
  • PROJECT_NAME_ENABLE_ASAN: Run the unit tests and examples using AddressSanitizer.
  • PROJECT_NAME_ENABLE_COVERAGE: Run the unit tests and examples with code coverage instrumentation.
  • PROJECT_NAME_ENABLE_WERROR: Fail and stop if a warning is triggered.
  • PROJECT_NAME_ENABLE_DEBUG_INFORMATION: Includes debug information in the binaries.
  • PROJECT_NAME_ENABLE_ASSERTIONS: Enables assertions.

CMake targets

  • make: Compiles top-level targets.
  • make tests: Compiles the tests.
  • make examples: Compiles the examples.
  • make check: Runs the test and the examples.
  • make doc: Generates the documentation.

Directory structure

The directory structure is as follows:

benchmark/            : Benchmarks (reserved for future usage)
cmake/                : CMake files
include/project_name/ : Project header files
site/                 : website (reserved for future usage)
src/                  : Source files (reserved for future usage)
test/                 : Unit-tests 
.clang-format         : clang-format configuration
.travis.yml           : Travis-CI configuration
.gitignore            : With C++ defaults
CMakeLists.txt        : CMake configuration

What remains to be done