GithubHelp home page GithubHelp logo

tobiasmarciszko / cpp_starter_project Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cpp-best-practices/gui_starter_template

1.0 0.0 0.0 421 KB

A template CMake project to get you started with C++ and tooling

License: The Unlicense

CMake 63.61% C++ 36.39%

cpp_starter_project's Introduction

cpp_starter_project

codecov

Build Status

Build status

CMake

Getting Started

Use the Github template

First, click the green Use this template button near the top of this page. This will take you to Github's 'Generate Repository' page. Fill in a repository name and short description, and click 'Create repository from template'. This will allow you to create a new repository in your Github account, prepopulated with the contents of this project. Now you can clone the project locally and get to work!

$ git clone https://github.com/<user>/<your_new_repo>.git

Remove frameworks you're not going to use

If you know you're not going to use one or more of the optional gui/graphics frameworks (fltk, gtkmm, imgui, etc.), you can remove them with git rm:

$ git rm -r src/<unnecessary_framework>

Dependencies

Necessary Dependencies

  1. A C++ compiler that supports C++17. See cppreference.com to see which features are supported by each compiler. The following compilers should work:
  1. Conan - it's recommended that you install using pip
  2. CMake 3.15+

Optional Dependencies

This project can be made to work with several optional GUI frameworks.

If desired, you should install the following optional dependencies as directed by their documentation, linked here:

The following dependencies can be downloaded automatically by CMake and Conan. All you need to do to install them is to turn on a CMake flag during configuration. If you run into difficulty using them, please refer to their documentation, linked here:

  • NANA
  • SDL
  • IMGUI: This framework depends on SFML, and if you are using Linux, you may need to install several of SFML's dependencies using your package manager. See the SFML build tutorial for specifics.

Build Instructions

Make a build directory

$ mkdir build && cd build

Configure your build

To configure the project and write makefiles, you could use cmake with a bunch of command line options. The easier option is to run cmake interactively, with the Cmake Curses Dialog Command Line tool:

$ ccmake ..

Once ccmake has finished setting up, press 'c' to configure the project, press 'g' to generate, and 'q' to quit.

Build

Once you have selected all the options you would like to use, you can build the project:

$ cmake --build .   # build all targets

Build using an alternate compiler

Conan and CMake use the environment variables CC and CXX to decide which compiler to use. If you don't set these variables yourself, the system default compiler will be used.

Be aware that CMake will detect which compiler was used to build each of the Conan targets. If you build all of your Conan targets with one compiler, and then build your CMake targets with a different compiler, the project may fail to build.

To build using clang, you can use these commands:

$ CC=clang CXX=clang++ ccmake ..
$ CC=clang CXX=clang++ cmake --build .

Troubleshooting

Update Conan

Many problems that users have can be resolved by updating Conan, so if you are having any trouble with this project, you should start by doing that.

To update conan:

$ pip install --user --upgrade conan 

You may need to use pip3 instead of pip in this command, depending on your platform.

Clear Conan cache

If you continue to have trouble with your Conan dependencies, you can try clearing your Conan cache:

$ conan remove -f '*'

The next time you run cmake or cmake --build, your Conan dependencies will be rebuilt. If you aren't using your system's default compiler, don't forget to set the CC, CXX, CMAKE_C_COMPILER, and CMAKE_CXX_COMPILER variables, as described in the 'Build using an alternate compiler' section above.

Identifying misconfiguration of Conan dependencies

If you have a dependency 'A' that requires a specific version of another dependency 'B', and your project is trying to use the wrong version of dependency 'B', Conan will produce warnings about this configuration error when you run CMake. These warnings can easily get lost between a couple hundred or thousand lines of output, depending on the size of your project.

If your project has a Conan configuration error, you can use conan info to find it. conan info displays information about the dependency graph of your project, with colorized output in some terminals.

$ cd build
$ conan info .

In my terminal, the first couple lines of conan info's output show all of the project's configuration warnings in a bright yellow font.

For example, the package spdlog/1.5.0 depends on the package fmt/6.1.2. If you were to modify the file cmake/Conan.cmake so that it requires an earlier version of fmt, such as fmt/6.0.0, and then run:

$ conan remove -f '*'       # clear Conan cache
$ rm -rf build              # clear previous CMake build
$ mkdir build && cd build
$ cmake ..                  # rebuild Conan dependencies
$ conan info .

...the first line of output would be a warning that spdlog needs a more recent version of fmt.

Testing

See Catch2 tutorial

Fuzz testing

See libFuzzer Tutorial

cpp_starter_project's People

Contributors

abeimler avatar adrian5 avatar avitase avatar caellian avatar ddalcino avatar developerpaul123 avatar edhebi avatar genericmadscientist avatar jpakkane avatar kees-jan avatar krzmaz avatar lectem avatar lefticus avatar lesleylai avatar mo-xiaoming avatar patrickelectric avatar paulbendixen avatar saimen avatar valerioformato avatar

Stargazers

 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.