Coder Social home page Coder Social logo

mattclarke / cpp-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matthew-d-jones/cpp-template

0.0 1.0 0.0 52 KB

Template for a C++ project, with Conan for dependency management and some boilerplate for my favourite libraries

License: BSD 2-Clause "Simplified" License

CMake 91.64% C++ 8.36%

cpp-template's Introduction

Template C++ Project

This aims to be a good starting point for cross-platform, modern C++ projects using CMake.

Features:

  • CMake boilerplate to
    • build an executable which depends on some external libraries.
    • set compiler flags to be strict about warnings.
    • make documentation using doxygen.
    • make use of link-time optimisation if available.
    • make use of a faster linker if available.
  • Dependency management using Conan.
  • A little example code/boilerplate for libraries I use very frequently:

Some things this template lacks which I may add in the future:

  • Continuous integration configuration
  • Code coverage configuration
  • Static code analysis configuration
  • Code formatting configuration

Requirements

The only requirements to be manually installed on the system are Python, pip, CMake and a C++ compiler.

Conan requires Python and pip installed on the system, then:

pip install conan

That should be it, Conan will be run automatically by CMake to download the dependencies.

Edit conanfile.txt to add/remove dependencies. If the library you want to use is on https://conan.io/center/ then simply add it under [requires] in conanfile.txt and to the list of libraries to link in CMakeLists.txt. If the library is not in conan center then you'll need to learn about Conan remotes and possibly making your own Conan package recipe, see https://docs.conan.io/en/latest/introduction.html

Build

As usual for a CMake project. For example, make a build directory (preferably somewhere outside the source directory) and do

cmake path/to/source/directory
cmake --build . -- -j8

or, better, with Ninja

cmake -GNinja path/to/source/directory
ninja

or, if you must ;), on Windows

cmake -G "Visual Studio 15 2017 Win64" path\to\source\directory
cmake --build . -- -maxcpucount:8

Run

From the build directory

./bin/TemplateProject --help

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.