Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tessapower/template-cmake-project

A template CMake project for C++.
https://github.com/tessapower/template-cmake-project

cmake cpp template

Last synced: about 7 hours ago
JSON representation

A template CMake project for C++.

Awesome Lists containing this project

README

        

# Template CMake Project

This is my standard template CMake project to use for C++ projects. I created
this so I don't need to always start from scratch each time I create a new C++
project. This template consists of a library `my_lib` and a basic entry point,
`my_app.cpp`, that makes use of it. All functionality is contained within
`my_lib` to make it easy to test. Tests for `my_lib` functionality are found in
the `tests` directory.

### Directory Structure

```text
.
├── app
│ ├── CMakeLists.txt
│ └── my_app.cpp
├── cmake-build-debug
├── CMakeLists.txt
├── include
│ └── my_lib
│ └── my_lib.h
├── README.md
├── src
│ ├── CMakeLists.txt
│ └── my_lib
│ └── my_lib.cpp
└── tests
├── addition_tests.cpp
├── CMakeLists.txt
└── subtraction_tests.cpp
```

Each directory (except for `include`) contains a `CMakeLists.txt` that takes
care of structuring and linking its files together to be used by the rest of
the project. The `CMakeLists.txt` in the root directory takes care of including
these subdirectories as part of the project.

The structure and layout was derived from
"[An Introduction to Modern CMake](https://cliutils.gitlab.io/modern-cmake/)".

- CMake Version: `3.25`
- C++ Standard: `C++20`
- Testing Framework: `GoogleTest`

### Build Configurations

- `my_app`: run the main program
- `All Ctest`: run the tests for `my_lib` (using _GoogleTest_)
- Most of the other build configurations are not necessary for small projects,
but are created by CTest by default.

Feel free to use :)