Need help with cpp_starter_project?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

946 Stars 266 Forks The Unlicense 170 Commits 30 Opened issues


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

Services available


Need anything else?

Contributors list



Build Status

Build status


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

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/


Note about install commands: - for Windows, we use choco. - for MacOS, we use brew. - In case of an error in cmake, make sure that the dependencies are on the PATH.

Necessary Dependencies

  1. A C++ compiler that supports C++17. See to see which features are supported by each compiler. The following compilers should work:
  • gcc 7+

    Install command

    • Debian/Ubuntu:

      sudo apt install build-essential
    • Windows:

      choco install mingw -y
    • MacOS:

      brew install gcc

  • clang 6+

    Install command

    • Debian/Ubuntu:

      bash -c "$(wget -O -"
    • Windows:

      Visual Studio 2019 ships with LLVM (see the Visual Studio section). However, to install LLVM separately:

      choco install llvm -y

      llvm-utils for using external LLVM with Visual Studio generator:

      git clone
      cd llvm-utils/VS2017
    • MacOS:

      brew install llvm

  • Visual Studio 2019 or higher

    Install command + Environment setup

    On Windows, you need to install Visual Studio 2019 because of the SDK and libraries that ship with it.

    Visual Studio IDE - 2019 Community (installs Clang too):

    choco install -y visualstudio2019community --package-parameters "add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional --passive --locale en-US"

    Put MSVC compiler, Clang compiler, and vcvarsall.bat on the path:

        choco install vswhere -y
    # change to x86 for 32bit
    $clpath = vswhere -products * -latest -prerelease -find **/Hostx64/x64/*
    $clangpath = vswhere -products * -latest -prerelease -find **/Llvm/bin/*
    $vcvarsallpath =  vswhere -products * -latest -prerelease -find **/Auxiliary/Build/*
    $path = [System.Environment]::GetEnvironmentVariable("PATH", "User")
    [Environment]::SetEnvironmentVariable("Path", $path + ";$clpath" + ";$clangpath" + ";$vcvarsallpath", "User")

  1. Conan
    Install Command
- Via pip -

    pip install --user conan
  • Windows:

      choco install conan -y
  • MacOS:

      brew install conan

  1. CMake 3.15+
    Install Command
- Debian/Ubuntu:

    sudo apt-get install cmake
  • Windows:

      choco install cmake -y
  • MacOS:

      brew install cmake

Optional Dependencies

C++ Tools

  • Doxygen

    Install Command

    • Debian/Ubuntu:

      sudo apt-get install doxygen
      sudo apt-get install graphviz
    • Windows:

      choco install doxygen.install -y
      choco install graphviz -y
    • MacOS:

      brew install doxygen
      brew install graphviz

  • ccache

    Install Command

    • Debian/Ubuntu:

      sudo apt-get install ccache
    • Windows:

      choco install ccache -y
    • MacOS:

      brew install ccache

  • Cppcheck

    Install Command

    • Debian/Ubuntu:

      sudo apt-get install cppcheck
    • Windows:

      choco install cppcheck -y
    • MacOS:

      brew install cppcheck

  • include-what-you-use

    Install Command

    Follow instructions here:

GUI libraries

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

Build directory

Make a build directory:

mkdir build

Specify the compiler using environment variables

By default (if you don't set environment variables

), the system default compiler will be used.

Conan and CMake use the environment variables CC and CXX to decide which compiler to use. So to avoid the conflict issues only specify the compilers using these variables.

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.

Commands for setting the compilers
  • Debian/Ubuntu/MacOS:

    Set your desired compiler (clang, gcc, etc):

    • Temporarily (only for the current shell)

      Run one of the followings in the terminal:

      • clang

          CC=clang CXX=clang++
      • gcc

          CC=gcc CXX=g++
    • Permanent:

      Open ~/.bashrc using your text editor:

        gedit ~/.bashrc

      Add CC and CXX to point to the compilers:

        export CC=clang
        export CXX=clang++

      Save and close the file.

  • Windows:

    • Permanent:

      Run one of the followings in PowerShell:

      • Visual Studio generator and compiler (cl)

          [Environment]::SetEnvironmentVariable("CC", "cl.exe", "User")
          [Environment]::SetEnvironmentVariable("CXX", "cl.exe", "User")

        Set the architecture using vsvarsall:

          vsvarsall.bat x64
      • clang

          [Environment]::SetEnvironmentVariable("CC", "clang.exe", "User")
          [Environment]::SetEnvironmentVariable("CXX", "clang++.exe", "User")
      • gcc

          [Environment]::SetEnvironmentVariable("CC", "gcc.exe", "User")
          [Environment]::SetEnvironmentVariable("CXX", "g++.exe", "User")
  • Temporarily (only for the current shell):


Configure your build

To configure the project and write makefiles, you could use

with a bunch of command line options. The easier option is to run cmake interactively:

Configure via cmake-gui:

1) Open cmake-gui from the project directory:

cmake-gui .
2) Set the build directory:


3) Configure the generator:

In cmake-gui, from the upper menu select


Warning: if you have set

always choose the
use default native compilers
option. This picks
. Don't change the compiler at this stage!
Windows - MinGW Makefiles

Choose MinGW Makefiles as the generator:

Windows - Visual Studio generator and compiler

You should have already set C and CXX to cl.exe.

Choose "Visual Studio 16 2019" as the generator:

Windows - Visual Studio generator and Clang Compiler

You should have already set C and CXX to clang.exe and clang++.exe.

Choose "Visual Studio 16 2019" as the generator. To tell Visual studio to use clang-cl.exe:

  • If you use the LLVM that is shipped with Visual Studio: write ClangCl under "optional toolset to use".
  • If you use an external LLVM: write LLVM_v142 under "optional toolset to use".

4) Choose the Cmake options and then generate:


Configure via ccmake:

with the Cmake Curses Dialog Command Line tool:

ccmake -S . -B ./build


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


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

cmake --build ./build

For Visual Studio, give the build configuration (Release, RelWithDeb, Debug, etc) like the following:

cmake --build ./build -- /p:configuration=Release


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

instead of
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 --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, CMAKECCOMPILER, and CMAKECXXCOMPILER 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

depends on the package
. If you were to modify the file
so that it requires an earlier version of
, such as
, 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

needs a more recent version of


See Catch2 tutorial

Fuzz testing

See libFuzzer Tutorial

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.