Coder Social home page Coder Social logo

evolvedhq / cookiecutter-cpp-clion Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 151 KB

An unashamedly CLion-friendly cookiecutter template for C++2a, TDD with Catch2 and code coverage.

License: GNU General Public License v3.0

CMake 0.17% C++ 99.83%
cookiecutter-template cookiecutter-cpp clion clion-ide cpp

cookiecutter-cpp-clion's Introduction

Template for TDD in Modern C++

This is a cookiecutter template for a simple C++ project supporting TDD, and optimised for the CLion IDE. This template uses Catch2 as the unit test framework of choice, and is intended to give you a very efficient and highly repeatable way of very quickly getting started with micro-experimentation in C++.

Features of this template

The template is designed for use with CLion, far less so as a standalone CMake-based project:

  • Includes a current release of Catch2 as the unit test framework
  • Generates a header, a "production" source file and an empty test
  • Generates a CMake build designed to work "out of the box" in CLion
  • Has a launcher pre-configured for running the tests inside CLion
  • Generates coverage data by default, for coverage views in CLion

Pre-requisites

You'll need to have cookiecutter installed. This is a Python tool - on most platforms, install using:

$ pip3 install cookiecutter

There are some pre-requisites for CLion too. This assumes you have an up-to-date clang and libc++ install, and that you have configured the clang toolchain in File | Settings | Build, Execution, Deployment | Toolchains. We recommend using the option for bundled LLDB too.

When we say "up to date", we currently mean "will support the -std=c++2a" option. These assumptions are fixed into the CMake build.

We also assume that if you want to show code coverage in CLion - and it's a nice thing to have when doing TDD - then you have congigured the llvm-cov and llvm-profdata paths in the panel File | Settings | Build, Execution, Deployment | Coverage. If so - when the project is opened in CLion - you should be able to run the All Tests target with coverage without further config.

Generating your project

Start by invoking cookiecutter. This can be done locally - handy if you're working disconnected:

$ cookiecutter <path-to-this-template>

or directly from the GitHub URL where the template lives:

$ cookiecutter https://github.com/EvolvedHQ/cookiecutter-kata-catch

This template is intended to be very simple, so cookiecutter will prompt you for only one parameter when you are creating your project:

project_name [cpptdd]:

We don't enforce it, but we'd recommend a single, lowercase word for this - the generated artifacts are far neater.

If you want to, you can always add any extra tools you need (static analyzers, sanitizers etc) into the CMake file yourself after generating - it's a minimal starting point for simple experimentation.

Next steps

Your newly generated project has its own README.md, which has the next steps for compiling, linking and running the tests. There are also some useful resources linked in there on TDD, software craft and code katas to try out.

Happy coding !

cookiecutter-cpp-clion's People

Contributors

50ohm avatar klutz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.