File: CMAKE_EXPORT_SARIF.rst

package info (click to toggle)
cmake 4.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,336 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (81 lines) | stat: -rw-r--r-- 2,244 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
CMAKE_EXPORT_SARIF
------------------

.. versionadded:: 4.0

Enable or disable CMake diagnostics output in SARIF format for a project.

If enabled, CMake will generate a SARIF log file containing diagnostic messages
output by CMake when running in a project. By default, the log file is written
to ``.cmake/sarif/cmake.sarif``, but the location can be changed by setting the
command-line option :option:`cmake --sarif-output` to the desired path.

The Static Analysis Results Interchange Format (SARIF) is a JSON-based standard
format for static analysis tools (including build tools like CMake) to record
and communicate diagnostic messages. CMake generates a SARIF log entry for
warnings and errors produced while running CMake on a project (e.g.
:command:`message` calls). Each log entry includes the message, severity, and
location information if available.

An example of CMake's SARIF output is:

.. code-block:: json

  {
    "version" : "2.1.0",
    "$schema" : "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json",
    "runs" :
    [
      {
        "tool" :
        {
          "driver" :
          {
            "name" : "CMake",
            "rules" :
            [
              {
                "id" : "CMake.Warning",
                "messageStrings" :
                {
                  "default" :
                  {
                    "text" : "CMake Warning: {0}"
                  }
                },
                "name" : "CMake Warning"
              }
            ]
          }
        },
        "results" :
        [
          {
            "level" : "warning",
            "locations" :
            [
              {
                "physicalLocation" :
                {
                  "artifactLocation" :
                  {
                    "uri" : "/home/user/development/project/CMakeLists.txt"
                  },
                  "region" :
                  {
                    "startLine" : 5
                  }
                }
              }
            ],
            "message" :
            {
              "text" : "An example warning"
            },
            "ruleId" : "CMake.Warning",
            "ruleIndex" : 0
          }
        ]
      }
    ]
  }