cmMessenger.h 2.5 KB

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