cmake boilerplate for a C++ project. Originally a fork of cpp starter project.
NOTE 1: This project is meant specifically for C++, it will likely take a lot of work to adapt it for use with C (or any other language).
NOTE 2: The minimum required standard is C++17 (default since GCC 11 and Clang 16).
- A C++ compiler
- cmake
Run the following commands to get started, more info available in the wiki.
git clone "https://github.com/Microsoft/vcpkg.git"
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
./vcpkg/vcpkg install
cmake --preset make # Check `cmake --list-presets` for other preset options
cmake --build build
Tests are enabled by default in debug mode and disabled by default in release.
They can be explicitly controlled with -DBUILD_TESTING
.
./build/bin/cpp_init_test
#or
ctest --test-dir build/tests
This command will build (if not built) and run the tests then print a coverage report.
Coverage uses lcov
. If lcov
is not installed it tries to use nix
to run
lcov
. If neither is found an error is thrown. Disable coverage with
-DENABLE_COVERAGE=NO
(off by default in release mode).
cmake --build build -t coverage