You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+146-2Lines changed: 146 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,9 +88,153 @@ The `include/project_name` folder will also include a `include.cmake` file that
88
88
89
89
Tests are contained in the component's `tests` folder. See `idi_component_test` and `idi_component_test_public` function documentation below for more information on how tests can be added. Tests are built around CTest and use Catch2 by default.
90
90
91
-
## Documentation
91
+
## Code Coverage
92
92
93
-
WIP
93
+
The framework includes built-in support for code coverage instrumentation and reporting via GCC/Clang's `--coverage` flag.
94
+
95
+
### Requirements
96
+
97
+
-**Compiler:** GCC or Clang (MSVC is not supported for coverage)
98
+
-**Report tools (at least one recommended):**
99
+
-`lcov` + `genhtml` — generates HTML reports (preferred)
100
+
-`gcovr` — generates HTML and/or Cobertura XML reports (useful for CI)
101
+
102
+
Install on Debian/Ubuntu:
103
+
104
+
```sh
105
+
$ sudo apt install lcov # lcov + genhtml
106
+
$ pip install gcovr # gcovr (alternative / CI XML reports)
107
+
```
108
+
109
+
### Usage
110
+
111
+
Enable coverage by passing `-DCODE_COVERAGE=ON` at configure time:
112
+
113
+
```sh
114
+
$ cd build
115
+
$ cmake .. -DCODE_COVERAGE=ON
116
+
$ cmake --build .
117
+
```
118
+
119
+
Then run one of the coverage build targets:
120
+
121
+
| Target | Description |
122
+
|---|---|
123
+
|`ccov-all`| Run all tests and generate an aggregate HTML coverage report |
124
+
|`ccov-all-xml`| Generate a Cobertura XML report (requires `gcovr`, available when `lcov` is also present) |
125
+
|`ccov-clean`| Remove all generated coverage data and reports |
-**LCOV info file:**`build/reports/coverage/coverage.info`
135
+
-**Cobertura XML:**`build/reports/coverage/coverage.xml` (when using `gcovr`)
136
+
137
+
### How It Works
138
+
139
+
Coverage is integrated into the framework's component system automatically. The existing `idi_component`, `idi_component_test`, and `idi_component_test_public` functions call `target_code_coverage()` on their targets. When `CODE_COVERAGE=ON`:
140
+
141
+
1. All component object libraries and test executables are compiled with `--coverage`.
142
+
2. Test executables registered with the `ALL` flag are collected for the aggregate report.
143
+
3. At the end of configuration, the `ccov-all` target is created which runs all registered tests and produces a filtered coverage report excluding test files, third-party libraries, and system headers.
144
+
145
+
When `CODE_COVERAGE=OFF` (the default), all coverage functions are no-ops and no build overhead is added.
146
+
147
+
### Tool Priority
148
+
149
+
The report generation strategy depends on which tools are available:
150
+
151
+
1.**lcov + genhtml** — HTML report via `ccov-all`; if `gcovr` is also available, `ccov-all-xml` is added for Cobertura XML.
152
+
2.**gcovr only** — `ccov-all` produces both HTML and XML reports.
153
+
3.**Neither** — `ccov-all` runs the tests and generates raw `.gcda`/`.gcno` data files only.
154
+
155
+
## Updating the Framework
156
+
157
+
The CMake framework includes a self-update mechanism that can pull in new versions of the framework files without overwriting your project-specific code (components, configuration, etc.).
158
+
159
+
### Update Sources
160
+
161
+
The updater supports three source modes:
162
+
163
+
| Mode | Description | Required Variable |
164
+
|---|---|---|
165
+
|`url` (default) | Downloads a zip archive from a URL |`FRAMEWORK_UPDATE_URL` (defaults to the IDI template master branch on GitHub) |
166
+
|`file`| Extracts from a local zip archive |`FRAMEWORK_UPDATE_FILE_LOC` — path to the archive relative to the project root |
167
+
|`folder`| Copies from a local folder |`FRAMEWORK_UPDATE_FOLDER_LOC` — absolute path to a template project folder |
168
+
169
+
### Running an Update
170
+
171
+
Trigger an update by passing `-DDO_FRAMEWORK_UPDATE=ON` during CMake configuration:
172
+
173
+
```sh
174
+
$ cd build
175
+
$ cmake .. -DDO_FRAMEWORK_UPDATE=ON
176
+
```
177
+
178
+
This will:
179
+
180
+
1. Download/extract/copy the update source into a temporary `.idi-framework-update` directory.
181
+
2. Compare the incoming framework version against the current one.
182
+
3. If an update is available, replace the framework files (`cmake/idi/`, `src/base/`, root `CMakeLists.txt`, `src/CMakeLists.txt`, and `lib/.gitignore`).
183
+
4. Rename the base component's include directory to match your `IDICMAKE_PROJECT_NAME`.
184
+
5. Clean up the temporary directory and set `IDICMAKE_DID_UPDATE` so the rest of configuration is skipped — you must re-run `cmake ..` after an update to configure normally.
185
+
186
+
**If the framework is already up-to-date**, the updater will error out. To force a re-application of the same version:
Your project-specific files are **not touched**: `platform-config.cmake`, `platform-compile-options.cmake`, `version.cmake`, `components.cmake`, custom components, `cmake-hooks/`, `lib/libraries.cmake`, and `demo/`.
234
+
235
+
### Version Checks
236
+
237
+
After updating, the framework validates that your root and `src/` CMakeLists.txt files meet the minimum required version numbers (`IDICMAKE_ROOT_REQ_CML_V`, `IDICMAKE_SRC_REQ_CML_V`, `IDICMAKE_BASE_REQ_CML_V`). If the update replaced these files, they will already be at the correct version. If a major framework update changes the required versions, the updater will replace these files automatically.
0 commit comments