Skip to content

Commit 91bb307

Browse files
authored
Update README.md
1 parent 9f90026 commit 91bb307

File tree

1 file changed

+117
-27
lines changed

1 file changed

+117
-27
lines changed

README.md

Lines changed: 117 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ Before building the project, make sure the following tools are installed on your
7474
| lcov / gentml | _Optional_ | For code coverage reports (`Coverage` build type) |
7575
| cppcheck, clang-format, clang-tidy | _Optional_ | For static analysis and formatting checks |
7676

77-
You can install tools on Ubuntu like so:
78-
```bash
79-
sudo apt update
80-
sudo apt install build-essential cmake ninja-build clang-format clang-tidy cppcheck doxygen lcov
81-
```
82-
83-
**Note:** the project gracefully skips unavailable tools and emits a warning if optional tools aren't found.
77+
> The project gracefully skips unavailable tools and emits a warning if optional tools aren't found.
8478
8579
### Build Presets
8680

@@ -103,24 +97,12 @@ cmake --list-presets
10397

10498
> All commands assume you are using CMake Presets, which are fully configured for this project.
10599
106-
#### Configure and Build
107-
108100
To configure and build using a preset:
109101
```bash
110102
cmake --preset gcc-RelWithDebInfo
111103
cmake --build --preset gcc-RelWithDebInfo
112104
```
113105

114-
### Run Tests
115-
116-
All tests are built with [GoogleTest](https://github.com/google/googletest). Enable them with the `ENABLE_TESTING` option (**enabled** by default).
117-
118-
```bash
119-
cmake --preset gcc-RelWithDebInfo
120-
cmake --build --preset gcc-RelWithDebInfo
121-
ctest --preset gcc-RelWithDebInfo
122-
```
123-
124106
### Sanitizers
125107

126108
The `Sanitize` build type enables runtime checks for memory errors (AddressSanitizer, UndefinedBehaviorSanitizer).
@@ -146,18 +128,126 @@ View the report in:
146128
build/gcc-Coverage/coverage-report/index.html
147129
```
148130

131+
## Developer Tooling
132+
133+
This project includes several tools to ensure code quality and maintainability. All tools are integrated as CMake targets and run independently from the build system.
134+
135+
### Code Formatting
136+
137+
Format all C++ files using `.clang-format`.
138+
139+
Run the check:
140+
```bash
141+
cmake --preset gcc-RelWithDebInfo
142+
cmake --build --preset gcc-RelWithDebInfo --target clang-format-check
143+
```
144+
> Use a pre-commit hook to automatically check formatting before each commit.
145+
146+
### Static Analysis
147+
148+
- Lint source code using [Clang-Tidy](https://clang.llvm.org/extra/clang-tidy).
149+
- Run deep static analysis using [Cppcheck](https://cppcheck.sourceforge.io/).
150+
151+
Run `clang-tidy` analysis:
152+
```bash
153+
cmake --preset gcc-RelWithDebInfo
154+
cmake --build --preset gcc-RelWithDebInfo --target clang-tidy
155+
```
156+
> Configurable via `.clang-tidy`, with selective checks enabled.
157+
158+
Run `cppcheck` analysis:
159+
```bash
160+
cmake --preset gcc-RelWithDebInfo
161+
cmake --build --preset gcc-RelWithDebInfo --target cppcheck
162+
```
163+
> Targets only your project files — third-party code is excluded.
164+
165+
### API Documentation
166+
167+
If `BUILD_DOCS=ON`, a `docs` target becomes available to generate HTML API documentation:
168+
```bash
169+
cmake --preset gcc-RelWithDebInfo -DBUILD_DOCS=ON
170+
cmake --build --preset gcc-RelWithDebInfo --target docs
171+
```
172+
173+
> Output will be generated in `build/<preset>/docs/html/`
174+
175+
## Installation
176+
177+
This project supports CMake's standard installation flow and can be consumed by other CMake-based projects using `find_package()`.
178+
149179
### Install the Library
150180

181+
To install the library (headers, compiled `.a`/`.so`, CMake config files):
151182
```bash
152-
cmake --preset gcc-Release
153-
cmake --build --preset gcc-Release
154-
cmake --install build/gcc-Release --prefix install # or /usr/local
183+
cmake --preset gcc-RelWithDebInfo
184+
cmake --build --preset gcc-RelWithDebInfo
185+
cmake --install build/gcc-RelWithDebInfo --prefix install # or /usr/local
186+
```
187+
- This installs the library to the `install/` directory.
188+
- You can also install system-wide with `--prefix /usr/local` (requires `sudo`).
189+
190+
### Use in External Project
191+
192+
After installation, consume the library like this in another CMake project:
193+
```bash
194+
find_package(modern_cpp_project REQUIRED)
195+
target_link_libraries(my_app PRIVATE modern_cpp_project::math)
196+
```
197+
198+
Make sure CMake knows where to find the installed package:
199+
```bash
200+
cmake -DCMAKE_PREFIX_PATH=/path/to/install ..
201+
```
202+
203+
> The install includes CMake config files, version info, and targets for linking.
204+
205+
## Testing and Coverage
206+
207+
This project includes unit tests, benchmarks, and support for code coverage analysis.
208+
209+
### Unit Testing
210+
211+
Unit tests use **GoogleTest** (via `FetchContent`) and are auto-discovered.
212+
- Tests are enabled by default (`ENABLE_TESTING=ON`)
213+
- Run with any build type (e.g., `Debug`, `RelWithDebInfo`, `Sanitize`)
214+
215+
Build and run tests:
216+
```bash
217+
cmake --preset gcc-RelWithDebInfo
218+
cmake --build --preset gcc-RelWithDebInfo
219+
ctest --preset gcc-RelWithDebInfo
220+
```
221+
222+
> Use `Sanitize` builds to detect memory and undefined behavior.
223+
224+
### Benchmarks
225+
226+
Benchmarks are written using **Google Benchmark** and are **not enabled** by default (`ENABLE_BENCHMARKS=OFF`).
227+
228+
> Benchmarks are skipped in `Sanitize` and `Coverage` builds for performance and accuracy.
229+
230+
Build and run:
231+
```bash
232+
cmake --preset gcc-Release -DENABLE_BENCHMARKS=ON
233+
cmake --build --preset gcc-Release --target benchmarks
234+
./build/gcc-Release/benchmarks/benchmarks
235+
```
236+
237+
### Code Coverage
238+
239+
Coverage is powered by `lcov` + `genhtml`, enabled via the special `Coverage` build type.
240+
241+
Generate coverage report:
242+
```bash
243+
cmake --preset gcc-Coverage
244+
cmake --build --preset gcc-Coverage
245+
ctest --preset gcc-Coverage
246+
cmake --build --preset gcc-Coverage --target coverage
155247
```
156248

157-
This installs:
158-
- Compiled static/shared libraries
159-
- Public headers from `include/`
160-
- CMake config files for `find_package(...)` consumers
249+
> Coverage report can be found in `build/gcc-Coverage/coverage-report/index.html`
250+
> Coverage excludes third-party and application/benchmark targets. Only `src/` and `tests/` are measured.
161251
162252
## Contributing
163253

@@ -168,6 +258,6 @@ Pull requests are welcome. Please ensure:
168258

169259
## License
170260

171-
This project is licensed under the [Apache License 2.0](LICENSE).
261+
This project is licensed under the **Apache License 2.0**.
172262

173263
You are free to use, modify, distribute, and include this code in commercial or open-source projects.

0 commit comments

Comments
 (0)