GithubHelp home page GithubHelp logo

sysudengle / init-cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jondot/init-cpp

0.0 2.0 0.0 183 KB

A simple template to start quickly a C++ project managed by CMake.

License: MIT License

Python 27.73% CMake 68.14% C++ 4.13%

init-cpp's Introduction

C++ project template

Travis CI Build Status Appveyor Build Status codecov.io Documentation Status

This is a layout to bootstrap a complete C++ project with several modules, test code and various tooling to get on a sane development workflow. The directory layout looks over engineered for so small a source code, but it aims at being able to scale with a lot of files, modules and 3rdparties while avoiding clutter and name conflicts.

The actual source has three modules:

  • projectlib is the business code of a library, with public headers and compilation units. The projectlib directory name is replicated for public headers to keep consistency with system wide deployment through a package.
  • projectrun contains only compilation units and is a business executable.
  • testlib contains only compilation units (yet) and is supposed to hold test code, objects and tools shared by the other modules.

Non system third parties are supposed to be stored or referenced (either via copy, submodule or CMake external project) in the 3rdparty directory. System third parties may be referenced to directly with CMake modules.

Tooling includes:

  • Automatic configuration for YouCompleteMe
  • Code coverage with gcov and lcov
  • Code formatting with clang-format
  • Code checking with clang-tidy
  • Cloud continuous integration
  • Sanitizers builds
  • A trick to prefix every test executable with your own command, with arguments if you want (ex: valgrind --leak-check=full) without using the strange CMake Dart thing.
  • Documentation generation with Doxygen and Sphinx+Breathe.

This project is distributed under the MIT license.

Simple compilation

mkdir build
cd build
cmake ../
make
ctest
./bin/runcppproject

The cmake output will prompt about detected tools and availabe targets to use them.

clang-tidy

To execute clang-tidy on every file compiled by the project, from the build dir :

./run-clang-tidy.py

It will execute clang-tidy with the same -I and -D options from your CMake files. Any additional argument passed to the script is forwarded. Example:

./run-clang-tidy.py -checks=*

Sanitizer builds

To make a sanitizer build, customize cmake/SanitizerBlacklist.txt.in at your will then

cmake ../ -DPROJECT_BUILD_SANITIZER_TYPE=${sanitizer_type}

Where sanitizer_type is either address, memory, thread or undefined.

Prefixing tests

A function called project_add_test has the exact same signature than the built-in add_test. Tests added with it are prefixed before launch with the content of the PROJECT_TEST_COMMANDS_PREFIX variable. Example:

cmake ../ -DPROJECT_TEST_COMMANDS_PREFIX="valgrind --leak-check=full"

init-cpp's People

Contributors

duckie avatar jondot avatar

Watchers

James Cloos avatar monster_dl 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.