This is a starter template for a multi lib, multi app project born out of my needs. This template is based on starter project ModernCppStarter, the cmake is loosly based on Introduction to Modern CMake and some cmake modules from cpp-project boilerplate. See ModernCppStarter README for more details about originating concepts.
- As far as possible, all directories are self contained
- Executables are in the “apps” directory, one directory per app
- Libraries are in “libs” directory, one directory per library
- Every app or library directory has one or all of directories viz. “include”, “src”, “tests”
- Each namespace gets own directory inside the above three
- CMake is primary build system(version 3.23), for Bazel see my bazel starter
- Out of source build and dependency management
- Every target (executable or library) CMakeLists.txt is self contained (i.e. does not depend directly on the external structure)
- The main CMakeLists.txt makes all the dependencies available to the apps and libraries
- CPM is used for external dependency download and setup
- Use the “Use this template” button on github to create a new repository with all the content of this starter, modify according to your needs.
- Clone this repo locally and remove/change the remote
# configure build with ninja
cmake -S . -B build -GNinja
# build everything
cmake --build build
# build specific target
cmake --build build --target <name>
# configure with code quality tools namely sanitizers, cppcheck, include what you use (iwyu), codecoverage
cmake -S . -B build -GNinja -DUSE_SANITIZER='Memory;MemoryWithOrigins;Thread;Leak;Address;Undefined' -DUSE_STATIC_ANALYZER='clang-tidy;iwyu;cppcheck' -DENABLE_CODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Coverage
# run codecoverage for tests (e.g. greeter tests)
cmake --build build --target coverage_greeter
# open the code coverage report
open build/coverage_out/index.html