22
33[ ![ License] [ license-badge ]] [ license-link ]
44
5- Modern CMake template for C++ header-only libraries with common infrastructure.
5+ Modern CMake template for C++ header-only libraries with comprehensive infrastructure.
66
77[ license-badge ] : https://img.shields.io/badge/license-BSL%201.0-blue.svg
88[ license-link ] : https://github.com/stlab/cpp-library/blob/main/LICENSE
@@ -11,10 +11,11 @@ Modern CMake template for C++ header-only libraries with common infrastructure.
1111
1212` cpp-library ` provides a standardized CMake infrastructure template for header-only C++ libraries. It eliminates boilerplate and provides consistent patterns for:
1313
14- - ** Library Setup** : INTERFACE targets with proper installation
15- - ** Testing** : Integrated doctest with CTest
14+ - ** Library Setup** : INTERFACE targets with proper installation and package config
15+ - ** Testing** : Integrated doctest with CTest and compile-fail test support
1616- ** Documentation** : Doxygen with doxygen-awesome-css theme
17- - ** Development Tools** : clangd integration, CMakePresets.json
17+ - ** Development Tools** : clangd integration, CMakePresets.json, clang-tidy support
18+ - ** CI/CD** : GitHub Actions workflows with multi-platform testing
1819- ** Dependency Management** : CPM.cmake integration
1920
2021## Usage
@@ -38,11 +39,10 @@ cpp_library_setup(
3839 DESCRIPTION "${PROJECT_DESCRIPTION}"
3940 NAMESPACE your_namespace
4041 HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/your_namespace/your_header.hpp
41- EXAMPLES your_example
42+ EXAMPLES your_example your_example_fail
4243 TESTS your_tests
4344 DOCS_EXCLUDE_SYMBOLS "your_namespace::implementation"
4445)
45-
4646```
4747
4848### Prerequisites
@@ -73,21 +73,25 @@ cpp_library_setup(
7373 [DOCS_EXCLUDE_SYMBOLS symbols] # Symbols to exclude from docs
7474 [REQUIRES_CPP_VERSION 17|20|23] # C++ version (default: 17)
7575 [ADDITIONAL_DEPS dep_list] # Extra CPM dependencies
76+
77+ # Optional flags
7678 [CUSTOM_INSTALL] # Skip default installation
7779 [NO_PRESETS] # Skip CMakePresets.json generation
80+ [NO_CI] # Skip CI generation (enabled by default)
81+ [FORCE_INIT] # Force regeneration of template files
7882)
7983```
8084
8185## Features
8286
8387### Automated Infrastructure
8488
85- - ** CMakePresets.json** : Generates standard presets (default, test, docs)
89+ - ** CMakePresets.json** : Generates standard presets (default, test, docs, clang-tidy, init )
8690- ** Installation** : Modern CMake package config with FILE_SET headers
87- - ** Testing** : doctest integration with CTest
91+ - ** Testing** : doctest integration with CTest and compile-fail test support
8892- ** Documentation** : Doxygen with doxygen-awesome-css theme
8993- ** Development** : clangd compile_commands.json symlink
90- - ** Compile-fail tests ** : Automatic detection for examples with ` _fail ` suffix
94+ - ** CI/CD ** : GitHub Actions workflows with multi-platform testing and documentation deployment
9195
9296### Smart Defaults
9397
@@ -97,12 +101,45 @@ cpp_library_setup(
97101- ** Build isolation** with separate build directories
98102- ** Two-mode operation** : Full infrastructure when top-level, lightweight when consumed
99103
104+ ### Testing Features
105+
106+ - ** [email protected] ** for unit testing
107+ - ** Compile-fail tests** : Automatic detection for examples with ` _fail ` suffix
108+ - ** CTest integration** : Proper test registration and labeling
109+ - ** Multi-directory support** : Checks both ` tests/ ` directories
110+
111+ ### Documentation Features
112+
113+ - ** Doxygen integration** with modern configuration
114+ - ** [email protected] ** theme for beautiful output
115+ - ** Symbol exclusion** support for implementation details
116+ - ** GitHub Pages deployment** via CI
117+ - ** Custom Doxyfile support** (falls back to template)
118+
119+ ### Development Tools
120+
121+ - ** clang-tidy integration** via CMakePresets.json
122+ - ** clangd support** with compile_commands.json symlink
123+ - ** CMakePresets.json** with multiple configurations:
124+ - ` default ` : Release build
125+ - ` test ` : Debug build with testing
126+ - ` docs ` : Documentation generation
127+ - ` clang-tidy ` : Static analysis
128+ - ` init ` : Template regeneration
129+
130+ ### CI/CD Features
131+
132+ - ** Multi-platform testing** : Ubuntu, macOS, Windows
133+ - ** Multi-compiler support** : GCC, Clang, MSVC
134+ - ** Static analysis** : clang-tidy integration
135+ - ** Documentation deployment** : Automatic GitHub Pages deployment
136+ - ** Template generation** : CI workflow generation
137+
100138### Dependency Management
101139
102140- ** CPM.cmake** integration for seamless fetching
103141- ** Automatic caching** via CPM's built-in mechanisms
104- - ** [email protected] ** for testing
105- - ** [email protected] ** for documentation
142+ - ** Version pinning** for reliable builds
106143- ** Git tag versioning** for reliable updates
107144
108145## Example Projects
@@ -140,8 +177,46 @@ cpp_library_setup(
140177 TESTS enum_ops_tests
141178 DOCS_EXCLUDE_SYMBOLS "stlab::implementation"
142179)
143-
144180```
181+
182+ ## Quick Start
183+
184+ 1 . ** Initialize a new project** :
185+ ``` bash
186+ # Clone or create your project
187+ mkdir my-library && cd my-library
188+
189+ # Create basic structure
190+ mkdir -p include/your_namespace examples tests cmake
191+
192+ # Add CPM.cmake
193+ curl -L https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake -o cmake/CPM.cmake
194+ ```
195+
196+ 2 . ** Create CMakeLists.txt** with the usage example above
197+
198+ 3 . ** Add your headers** to ` include/your_namespace/ `
199+
200+ 4 . ** Add examples** to ` examples/ ` (use ` _fail ` suffix for compile-fail tests)
201+
202+ 5 . ** Add tests** to ` tests/ `
203+
204+ 6 . ** Build and test** :
205+ ``` bash
206+ cmake --preset=test
207+ cmake --build --preset=test
208+ ctest --preset=test
209+ ```
210+
211+ ## Template Files Generated
212+
213+ The template automatically generates:
214+
215+ - ** CMakePresets.json** : Build configurations for different purposes
216+ - ** .github/workflows/ci.yml** : Multi-platform CI/CD pipeline
217+ - ** .gitignore** : Standard ignores for C++ projects
218+ - ** Package config files** : For proper CMake integration
219+
145220## License
146221
147222Distributed under the Boost Software License, Version 1.0. See ` LICENSE ` .
0 commit comments