This is a minimal project starter for modern CMake and C++20. You can just clone/fork this repository and start writing your code.
This project defines a simple C++ library and a main executable that uses the library. The project is organized as follows:
lib/
: Contains the source code of the library.app/
: Contains the source code of the main executable.test/
: Contains the source code of the tests.
Additionally, dependencies can be imported using the CPM.cmake library. For example, to import the GoogleTest library, you can add the following lines to the CMakeLists.txt
file:
include(cmake/CPM.cmake)
CPMAddPackage(
GITHUB_REPOSITORY google/googletest
VERSION 1.14.0
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt ON"
EXCLUDE_FROM_ALL
SYSTEM
)
To build the code you can use the following commands:
cmake -S . -B build
cmake --build build
You can also use the CMake presets to build the code:
cmake -S . -B build --preset=default
cmake --build build --preset=Release
This project is inspired by the following projects:
- Add CMake install configuration
- Generate doxygen documentation