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
Add support for custom build problem matchers in CMake Tools (#4760)
* Add support for custom build problem matchers in CMake Tools
- Introduced `cmake.additionalBuildProblemMatchers` setting to allow users to define custom problem matchers for build output.
- Implemented `CustomParser` to handle user-defined regex patterns and integrate diagnostics into the VS Code Problems pane.
- Updated documentation and tests to cover new functionality, including examples for clang-tidy, PCLint, and cppcheck formats.
* fixed regex
* updated test
---------
Co-authored-by: Hannia Valera <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Features:
8
8
- Add individual CTest test nodes to the Project Outline with inline run/debug buttons, and enable debugging tests from both the Outline and Test Explorer without requiring a launch.json. [#4721](https://github.com/microsoft/vscode-cmake-tools/pull/4721)
9
9
- Add "Delete Cache, Reconfigure and Build" command that chains cache deletion, reconfiguration, and build into a single action. [#4723](https://github.com/microsoft/vscode-cmake-tools/pull/4723)
10
10
- Add "Set Build and Launch/Debug Target" command that sets both the build target and launch target simultaneously. [#4732](https://github.com/microsoft/vscode-cmake-tools/pull/4732)
11
+
- Add `cmake.additionalBuildProblemMatchers` setting to define custom problem matchers for build output. Supports tools like clang-tidy, PCLint Plus, cppcheck, or custom scripts integrated via `add_custom_command`/`add_custom_target`. [#4077](https://github.com/microsoft/vscode-cmake-tools/issues/4077)
11
12
12
13
Improvements:
13
14
- Make "CMake: Add ... Preset" commands available in the command palette when `cmake.useCMakePresets` is set to `auto`, even before a CMakePresets.json file exists. [#4401](https://github.com/microsoft/vscode-cmake-tools/issues/4401)
Copy file name to clipboardExpand all lines: docs/cmake-settings.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,7 @@ Options that support substitution, in the table below, allow variable references
49
49
|`cmake.emscriptenSearchDirs`| List of paths to search for Emscripten. |`[]`| no |
50
50
|`cmake.enableAutomaticKitScan`| Enable automatic kit scanning. |`true`| no |
51
51
|`cmake.enabledOutputParsers`| List of enabled output parsers. |`["cmake", "gcc", "gnuld", "msvc", "ghs", "diab", "iwyu"]`| no |
52
+
|`cmake.additionalBuildProblemMatchers`| Array of user-defined problem matchers for build output. Each entry has `name`, `regexp`, and optional capture group indices (`file`, `line`, `column`, `severity`, `message`, `code`). See [Additional Build Problem Matchers](#additional-build-problem-matchers) below. |`[]`| no |
52
53
|`cmake.enableLanguageServices`| If `true`, enable CMake language services. |`true`| no |
53
54
|`cmake.enableTraceLogging`| If `true`, enable trace logging. |`false`| no |
54
55
|`cmake.environment`| An object containing `key:value` pairs of environment variables, which will be available when configuring, building, or testing with CTest. |`{}` (no environment variables) | yes |
@@ -149,6 +150,74 @@ Supported commands for substitution:
149
150
|`cmake.activeBuildPresetName`|The name of the active build preset.|
150
151
|`cmake.activeTestPresetName`|The name of the active test preset.|
151
152
153
+
## Additional build problem matchers
154
+
155
+
The `cmake.additionalBuildProblemMatchers` setting lets you define custom problem matchers that are applied to build output. This is useful when you integrate tools like **clang-tidy**, **PCLint Plus**, **cppcheck**, or custom scripts into your CMake build via `add_custom_command` or `add_custom_target`. Diagnostics from these tools will appear in the VS Code **Problems** pane alongside the standard compiler errors.
156
+
157
+
Custom matchers run **after** the built-in parsers (`gcc`, `msvc`, `gnuld`, etc.), so they will not interfere with standard compiler diagnostics.
|`name`| string |**yes**| — | Friendly name shown as the diagnostic source in the Problems pane. |
164
+
|`regexp`| string |**yes**| — | Regular expression applied to each build output line. |
165
+
|`file`| integer | no |`1`| Capture group index for the file path. |
166
+
|`line`| integer | no |`2`| Capture group index for the line number. |
167
+
|`column`| integer | no | — | Capture group index for the column number. |
168
+
|`severity`| integer or string | no |`"warning"`| Either a capture group index (integer) that captures `"error"`, `"warning"`, or `"info"`, or a fixed string. |
169
+
|`message`| integer | no |`3`| Capture group index for the diagnostic message. |
170
+
|`code`| integer | no | — | Capture group index for a diagnostic code. |
171
+
172
+
### Examples
173
+
174
+
**clang-tidy** (`/path/file.cpp:10:5: warning: some message [check-name]`):
Copy file name to clipboardExpand all lines: package.nls.json
+35Lines changed: 35 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,41 @@
174
174
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
"message": "Additional problem matchers for build output. Use this to surface diagnostics from tools like clang-tidy, PCLint Plus, cppcheck, or custom scripts integrated via `add_custom_command`/`add_custom_target` in CMake.\n\nEach entry defines a `name` (used as the diagnostic source label), a `regexp`, and capture group indices for `file`, `line`, `column`, `severity`, `message`, and `code`.\n\nFor example, to match clang-tidy output like `/path/file.cpp:10:5: warning: some message [check-name]`:\n```json\n[\n {\n\"name\": \"clang-tidy\",\n\"regexp\": \"^(.+?):(\\\\d+):(\\\\d+):\\\\s+(warning|error|note):\\\\s+(.+?)\\\\s*(?:\\\\[(.+)\\\\])?$\",\n\"file\": 1,\n\"line\": 2,\n\"column\": 3,\n\"severity\": 4,\n\"message\": 5,\n\"code\": 6\n }\n]\n```\n\nCustom matchers run **after** the built-in parsers (`gcc`, `msvc`, etc.) so they do not steal lines from built-in compilers.",
179
+
"comment": [
180
+
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
181
+
]
182
+
},
183
+
"cmake-tools.configuration.cmake.additionalBuildProblemMatchers.name": "A unique name for this matcher, used as the diagnostic source label in the Problems pane.",
184
+
"cmake-tools.configuration.cmake.additionalBuildProblemMatchers.regexp": "The regular expression to match against each build output line.",
"message": "The capture group index for the file path. Defaults to `1`.",
187
+
"comment": [
188
+
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
"message": "The capture group index for the line number. Defaults to `2`.",
193
+
"comment": [
194
+
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
"message": "The capture group index for the column number. Optional.",
199
+
"comment": [
200
+
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
201
+
]
202
+
},
203
+
"cmake-tools.configuration.cmake.additionalBuildProblemMatchers.severity.group": "The capture group index for the severity (should capture 'error', 'warning', or 'info').",
204
+
"cmake-tools.configuration.cmake.additionalBuildProblemMatchers.severity.fixed": "A fixed severity to apply to all matches from this pattern.",
"message": "The capture group index for the diagnostic message. Defaults to `3`.",
207
+
"comment": [
208
+
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
209
+
]
210
+
},
211
+
"cmake-tools.configuration.cmake.additionalBuildProblemMatchers.code": "The capture group index for an optional diagnostic code.",
177
212
"cmake-tools.configuration.cmake.debugConfig.description": "The debug configuration to use when debugging a target.",
178
213
"cmake-tools.configuration.cmake.debugConfig.symbolSearchPath.description": "Visual Studio debugger symbol search paths.",
179
214
"cmake-tools.configuration.cmake.debugConfig.additionalSOLibSearchPath.description": "Paths for GDB or LLDB to search for .so files.",
0 commit comments