Giter VIP home page Giter VIP logo

cpp_project_template's Introduction

C++ Project Template

When setting out on a new project in C++ there are a few configuration steps which need to be completed prior to actually getting down to writing code. This repository is going to be a C++ project template that already has the following components:

  • Directory Structure
  • Make Build (CMake)
  • Unit Test Framework (Google Test)
  • API Documentation (Doxygen)

Feel free to fork this repository and tailor it to suit you.

Procedure

  1. Download Bash script to create new C++ projects
    curl -O https://raw.githubusercontent.com/TimothyHelton/cpp_project_template/master/new_cpp_project.sh
    chmod u+x new_cpp_project.sh
  2. Create new C++ project
    ./new_cpp_project.sh NewProjectName
  3. In the project top level CMakeLists.txt:
    1. Line 2: Change the variable MyProject to the name of your project.
      project(NewProject)
      • This variable will be used in a couple of different places.
        • MyProject_run: will be the main executable name
        • MyProject_lib: will be the project library name
    2. Line 4: Set the version of C++ to use. For example, let's set up the NewProject to use C++ 11.
      set(CMAKE_CXX_STANDARD 11)
  4. Update project name and description in the Doxyfile located in the docs directory.
    1. Update line PROJECT_NAME
      1. This name will appear on each documentation page.
    2. Update line PROJECT_NUMBER
      1. This is the version number of your project.
    3. Update line PROJECT_BRIEF
      1. Any text entered here will also appear on each documentation page. Try not to make this one too long.
  5. Reload the top CMake file.

CLION IDE Specific Instructions

I started using an IDE from JET Brains tailored for Python called PyCharm and thought it helped me write better code. I'd been wanting to learn C++ and decided to give JET Brains C/C++ IDE called CLion a try. The code completion, interactive suggestions, debugger, introspection tools, and built-in test execution are very handy. There are a couple extra details to set when using this IDE.

  1. The IDE allows you to mark directories with their desired purpose. To mark a directory right click on the directory name in the Project window and select Mark Directory as from the drop-down menu.
    1. Mark the src directory as Project Sources and Headers
    2. Mark the tests/lib/googletest directory as Library Files
  2. Setup the Run/Debug Configuration by selecting Edit Configurations... from the pull-down menu from the run button (green triangle) in the upper right corner.
    1. Update Doxygen Build to execute the unit test suite.
      1. Select Doxygen from the Application menu on the left.
      2. Choose the executable for Doxygen to be Unit_Tests_run.
    2. Create a Google Test configuration
      1. In the upper left corner select the plus symbol.
      2. Chose Google Test from the drop-down menu.
      3. Set Name to Unit Tests.
      4. Set Target to Unit_Tests_run.

Wrap Up

That should be all it takes to start writing code. If you find any issues or bugs with this repository please file an issue on GitHub.

Hope you find this template useful and enjoy learning C++!

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.