Coverage Report

Created: 2026-03-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmMessenger.h
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <iosfwd>
8
#include <memory>
9
#include <string>
10
11
#include <cm/optional>
12
13
#include "cmListFileCache.h"
14
#include "cmMessageType.h" // IWYU pragma: keep
15
16
#ifndef CMAKE_BOOTSTRAP
17
#  include "cmSarifLog.h"
18
#endif
19
20
#ifdef CMake_ENABLE_DEBUGGER
21
namespace cmDebugger {
22
class cmDebuggerAdapter;
23
}
24
#endif
25
26
class cmMessenger
27
{
28
public:
29
  void IssueMessage(
30
    MessageType t, std::string const& text,
31
    cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
32
33
  void DisplayMessage(MessageType t, std::string const& text,
34
                      cmListFileBacktrace const& backtrace) const;
35
36
  void SetTopSource(cm::optional<std::string> topSource);
37
38
  void SetSuppressDevWarnings(bool suppress)
39
0
  {
40
0
    this->SuppressDevWarnings = suppress;
41
0
  }
42
  void SetSuppressDeprecatedWarnings(bool suppress)
43
0
  {
44
0
    this->SuppressDeprecatedWarnings = suppress;
45
0
  }
46
  void SetDevWarningsAsErrors(bool error)
47
0
  {
48
0
    this->DevWarningsAsErrors = error;
49
0
  }
50
  void SetDeprecatedWarningsAsErrors(bool error)
51
0
  {
52
0
    this->DeprecatedWarningsAsErrors = error;
53
0
  }
54
55
0
  bool GetSuppressDevWarnings() const { return this->SuppressDevWarnings; }
56
  bool GetSuppressDeprecatedWarnings() const
57
0
  {
58
0
    return this->SuppressDeprecatedWarnings;
59
0
  }
60
0
  bool GetDevWarningsAsErrors() const { return this->DevWarningsAsErrors; }
61
  bool GetDeprecatedWarningsAsErrors() const
62
0
  {
63
0
    return this->DeprecatedWarningsAsErrors;
64
0
  }
65
66
#ifndef CMAKE_BOOTSTRAP
67
1
  cmSarif::ResultsLog const& GetSarifResultsLog() const { return SarifLog; }
68
#endif
69
70
  // Print the top of a backtrace.
71
  void PrintBacktraceTitle(std::ostream& out,
72
                           cmListFileBacktrace const& bt) const;
73
#ifdef CMake_ENABLE_DEBUGGER
74
  void SetDebuggerAdapter(
75
    std::shared_ptr<cmDebugger::cmDebuggerAdapter> const& debuggerAdapter)
76
0
  {
77
0
    DebuggerAdapter = debuggerAdapter;
78
0
  }
79
#endif
80
81
private:
82
  bool IsMessageTypeVisible(MessageType t) const;
83
  MessageType ConvertMessageType(MessageType t) const;
84
85
  cm::optional<std::string> TopSource;
86
87
#ifndef CMAKE_BOOTSTRAP
88
  cmSarif::ResultsLog SarifLog;
89
#endif
90
91
  bool SuppressDevWarnings = false;
92
  bool SuppressDeprecatedWarnings = false;
93
  bool DevWarningsAsErrors = false;
94
  bool DeprecatedWarningsAsErrors = false;
95
#ifdef CMake_ENABLE_DEBUGGER
96
  std::shared_ptr<cmDebugger::cmDebuggerAdapter> DebuggerAdapter;
97
#endif
98
};