This is a template for a C++ project using CMake.
There are currently three different templates available:
- branch
main
: This is the most complete template. It contains amain.cpp
file that uses a simple library in thesrc
folder. This library also uses a private sub-library in thesrc
folder. - branch
basic
: This is the most basic template. It contains amain.cpp
file that uses a simple library in thesrc
folder. - branch
testing
: This template has the same structure as themain
branch, but it also implements unit tests using the Catch2 library.
- CMake is required to build the project.
- Boost is required, only for the purpose of showing how to use an external library.
- Install on Ubuntu:
sudo apt install libboost-all-dev
- Install on Mac with brew:
brew install boost
- Install on Windows: Boost Getting Started on Windows
- Install on Ubuntu:
- Catch2 is fetched automatically by CMake when using the
testing
branch, so no need to install it manually.
Git clone the repository and specify the branch you want to use:
git clone <repository_url> -b <branch_name>
In the top-level directory type:
- configure:
cmake -B build
- generate:
cmake --build build
- run:
./build CMakeTemplate
- Basics: https://cliutils.gitlab.io/modern-cmake/chapters/basics.html
- Project structure
- Comprehensive Book: https://crascit.com/professional-cmake/