Skip to content

Add support for CMake SARIF files - #5106

Open
Dan (dpt-kw) wants to merge 1 commit into
microsoft:mainfrom
dpt-kw:sarif
Open

Dan (dpt-kw) wants to merge 1 commit into
microsoft:mainfrom
dpt-kw:sarif

Conversation

@dpt-kw

@dpt-kw Dan (dpt-kw) commented Sep 22, 2026 •

Copy link
Copy Markdown

This change addresses item #5069.

This adds support for CMake's SARIF files by adding extension settings which control generation of the file and whether contents are loaded.

The following changes are proposed:

  • SARIF generation is controlled through the new setting exportSarifFile which will enable the cache variable CMAKE_EXPORT_SARIF unless the selected kit or preset specifies a value. Support was first added to CMake in 4.0.
  • Loading language diagnostics is controlled by loadSarifFile. If enabled, the extension checks the SARIF status by checking both the cache definition CMAKE_EXPORT_SARIF and the CLI flag --sarif-output=.... If the file is modern, language diagnostics will be loaded from this file instead of the stream parser. Proper configure diagnostics support isn't available until CMake 4.5.
    • The SARIF parser avoids a couple issues that appear with the stream parser in newer versions of CMake (since the 4.4 diagnostics overhaul), like missing the message severity level and defaulting to error (e.g. AUTHOR_WARNING).

The purpose of this change

Add extension options for controlling the new CMake SARIF feature in VS Code. Allow CMake-language diagnostics to be loaded from the SARIF file.

@dpt-kw

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Kitware, Inc."

@dpt-kw
Dan (dpt-kw) force-pushed the sarif branch 2 times, most recently from 4cea833 to 3067214 Compare October 28, 2026 14:56
@dpt-kw
Dan (dpt-kw) marked this pull request as ready for review November 3, 2026 14:55
Introduce an option to enable CMake SARIF file generation using the CMAKE_EXPORT_SARIF
cache variable and load language diagnostics from the file.

Fixes: microsoft#5069
@dpt-kw

Copy link
Copy Markdown
Author

I'm proposing adding a new dev-only dependency, @types/sarif@^2.1.7, which provides type definitions for SARIF. I'll need help from the team to add this dependency and otherwise review these changes. Is there someone specific I should ping?

CC: Hannia Valera (@hanniavalera)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant