Template repository to be used as a base for creating C++ libraries built with CMake. This repository provides:
- Commonly accepted directory layout:
cmakefor CMake utilities and package config,include/<libname>for public headers,srcfor library sources and private headers,examplesandtestsfor library examples and tests correspondingly. CMakeLists.txtfiles thoroughly implemented with the following ideas in mind:- user should be able to build library both as subproject (probably fetched with CMake's FetchContent_MakeAvailable) and as a stand-alone project
- user should be able to build examples/tests as part of the library build or as a stand-alone projects
- multi-configuration CMake generators should be supported
- package systems (conan, vcpkg and others) should be respected, which means that library
CMakeLists.txtfile should contain only build requirements, i.e. should not hardcode any compiler/linker flags unless they are absolutely required to build the library
- Basic preset file
CMakePresets.jsonwhich is a modern way (since CMake 3.19) for specifying build options (instead of hardcoding them in theCMakeLists.txtor setting on the command line) - My personal
.clang-formatfor code-style worth trying
Note, that I prefer googletest as a testing framework so it's the one used in this repository. Still it's not a big deal to replace it with any other of your choice.