|
1 | 1 | # Overview
|
2 | 2 |
|
3 |
| -Template repository to be used as a base for creating C++ libraries built with CMake. This repository provides: |
4 |
| -* Commonly accepted directory layout: `cmake` for CMake utilities and package config, `include/<libname>` for public headers, `src` for library sources and private headers, `examples` and `tests` for library examples and tests correspondingly. |
| 3 | +Template repository to be used as a base for creating C++ libraries built with CMake. |
| 4 | + |
| 5 | +## This repository provides: |
| 6 | + |
| 7 | +* Commonly accepted directory layout: |
| 8 | + |
| 9 | + - `cmake` for CMake utilities and package config |
| 10 | + - `include/<libname>` for public headers |
| 11 | + - `src` for library sources and private headers |
| 12 | + - `examples` |
| 13 | + - `tests` for library examples and tests correspondingly |
| 14 | + |
5 | 15 | * `CMakeLists.txt` files thoroughly implemented with the following ideas in mind:
|
6 |
| - * user should be able to build library both as subproject (probably fetched with CMake's [FetchContent_MakeAvailable](https://cmake.org/cmake/help/latest/module/FetchContent.html)) and as a stand-alone project |
7 |
| - * user should be able to build examples/tests as part of the library build or as a stand-alone projects |
8 |
| - * multi-configuration CMake generators should be supported |
9 |
| - * package systems (conan, vcpkg and others) should be respected, which means that library `CMakeLists.txt` file should contain only **build requirements**, i.e. should not hardcode any compiler/linker flags unless they are absolutely required to build the library |
10 |
| -* Basic [preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) file `CMakePresets.json` which is a modern way (since CMake 3.19) for specifying build options (instead of hardcoding them in the `CMakeLists.txt` or setting on the command line) |
| 16 | + |
| 17 | + - user should be able to build library both as subproject (probably fetched with CMake's |
| 18 | + [FetchContent_MakeAvailable](https://cmake.org/cmake/help/latest/module/FetchContent.html)) and as a stand-alone project |
| 19 | + - user should be able to build examples/tests as part of the library build or as a stand-alone projects |
| 20 | + - multi-configuration CMake generators should be supported |
| 21 | + - package systems (conan, vcpkg and others) should be respected, which means that library `CMakeLists.txt` file should contain |
| 22 | + only **build requirements**, i.e. should not hardcode any compiler/linker flags unless they are absolutely required to build |
| 23 | + the library |
| 24 | + |
| 25 | +* [CMake Workflow preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) file `CMakePresets.json` which is a |
| 26 | + modern way (since CMake 3.25) for specifying build options (instead of hardcoding them in the `CMakeLists.txt` or setting |
| 27 | + on the command line) |
| 28 | + |
11 | 29 | * My personal `.clang-format` for code-style worth trying
|
12 | 30 |
|
13 |
| -Note, that I prefer [googletest](https://github.com/google/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. |
| 31 | +* And too `.cmake-format.yml` to format the CMake files |
| 32 | + |
| 33 | +Note, that I prefer [googletest](https://github.com/google/googletest) as a testing framework so it's the one used in this |
| 34 | +repository. Still it's not a big deal to replace it with any other of your choice. |
| 35 | + |
| 36 | + |
| 37 | +## Links |
| 38 | + |
| 39 | +* Anton Pantyukhin - [Modern CMake tutorial for C++ library developers](https://medium.com/@pananton/modern-cmake-tutorial-for-c-library-developers-12f3bf57dc87) |
| 40 | +* Dominik Berner - [Organizing CMake presets](https://dominikberner.ch/cmake-presets-best-practices/) |
| 41 | +* Craig Scott -[C++20 Modules, CMake, And Shared Libraries](https://crascit.com/category/cmake/) |
| 42 | +* [cmake-init - CMake project generator](https://github.com/friendlyanon/cmake-init) that creates good `CMakeLists.tx` files |
0 commit comments