A complete starter project for C++ projects built with CMake.
Key Features • Project Documentation • Getting Started • Contributing • Credits •
Have you ever found yourself spending countless hours trying to figure out how to start a professional C++ project with unit tests, a robust dev workflow, change logs, code coverage, linting, formatting...? The C++ ecosystem is getting better but is still very far away from other ecosystems such as JavaScript, or even Rust. It's certainly easy to use CMake, a compiler and vscode to start a hello world project, but as soon as you start having multiple modules, with third party dependencies, testing, coverage, and other development things that a professional quality project needs, you start wasting hours and hours troubleshooting and configuring until you make it work.
Waste your time no more!
This starter project solves most of your problems, using the best practices for C++ development and modern CMake and allows you to get started in minutes rather than days.
CMake
as the build system with or without presets- cross-platform portability on Linux, OS X and Windows
- multiple compilers: clang, g++ and MSVC
- modular structure with each module self-contained in a subdirectory within the project
CMake
build helpers to facilitate declaration of library, exe, test modules, for the end-to-end lifecycle including doc generation, test, packaging etc...- unit testing targets, with by default Google Test as the framework (other frameworks are also possible)
- code coverage with clang or g++
- zero-touch valgrind, clang-tidy, clang-format, google sanitizers, etc
- development can be done locally or in a dev container with vscode
- faster rebuilds with
ccache
empowered caching CMake
package management withCPM
We have detailed guides for setting up an efficient development environment, the development process, project structure, etc. Take a look at the project's github pages here.
It is strongly recommended that you take some time to browse the project documentation to familiarize yourself with its structure and development workflows.
For the impatient, or the already experts, below is a short tutorial video for how to start from asap to make your own project.
In this step, we'll clean up the freshly created repo and prepare it for being customized.
In this step, we'll go into Visual Studio Code to do some heavier customizations while tracking our changes in git.
For this final tutorial, we will ad an executable module to implement the famous "Hello World!". You can see how simple it is and how fast it is to hit the ground running with asap and start focusing on what matters the most: coding.
Take some time to explore the different build targets in the project, and the documentation to add tests, documentation etc.
If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request. When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.
By contributing your code, you agree to license your contribution under the terms of the BSD-3-Clause or a more permissive license. All files are released with the BSD-3-Clause license.
Read the developer guides.
- For every PR there should be an accompanying issue which the PR solves
- The PR itself should only contain code which is the solution for the given issue
- If you are a first time contributor check if there is a suitable issue for you
- Swift Navigation for their cmake common tools project, an excellent starting point for several of the features in this starter project,
- The multitude of other open-source projects used to implement this project or to get inspiration - credits in the source code or the documentation as appropriate