cmMessenger.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifdef CMake_ENABLE_DEBUGGER
  12. namespace cmDebugger {
  13. class cmDebuggerAdapter;
  14. }
  15. #endif
  16. class cmMessenger
  17. {
  18. public:
  19. void IssueMessage(
  20. MessageType t, std::string const& text,
  21. cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
  22. void DisplayMessage(MessageType t, std::string const& text,
  23. cmListFileBacktrace const& backtrace) const;
  24. void SetTopSource(cm::optional<std::string> topSource);
  25. void SetSuppressDevWarnings(bool suppress)
  26. {
  27. this->SuppressDevWarnings = suppress;
  28. }
  29. void SetSuppressDeprecatedWarnings(bool suppress)
  30. {
  31. this->SuppressDeprecatedWarnings = suppress;
  32. }
  33. void SetDevWarningsAsErrors(bool error)
  34. {
  35. this->DevWarningsAsErrors = error;
  36. }
  37. void SetDeprecatedWarningsAsErrors(bool error)
  38. {
  39. this->DeprecatedWarningsAsErrors = error;
  40. }
  41. bool GetSuppressDevWarnings() const { return this->SuppressDevWarnings; }
  42. bool GetSuppressDeprecatedWarnings() const
  43. {
  44. return this->SuppressDeprecatedWarnings;
  45. }
  46. bool GetDevWarningsAsErrors() const { return this->DevWarningsAsErrors; }
  47. bool GetDeprecatedWarningsAsErrors() const
  48. {
  49. return this->DeprecatedWarningsAsErrors;
  50. }
  51. // Print the top of a backtrace.
  52. void PrintBacktraceTitle(std::ostream& out,
  53. cmListFileBacktrace const& bt) const;
  54. #ifdef CMake_ENABLE_DEBUGGER
  55. void SetDebuggerAdapter(
  56. std::shared_ptr<cmDebugger::cmDebuggerAdapter> const& debuggerAdapter)
  57. {
  58. DebuggerAdapter = debuggerAdapter;
  59. }
  60. #endif
  61. private:
  62. bool IsMessageTypeVisible(MessageType t) const;
  63. MessageType ConvertMessageType(MessageType t) const;
  64. cm::optional<std::string> TopSource;
  65. bool SuppressDevWarnings = false;
  66. bool SuppressDeprecatedWarnings = false;
  67. bool DevWarningsAsErrors = false;
  68. bool DeprecatedWarningsAsErrors = false;
  69. #ifdef CMake_ENABLE_DEBUGGER
  70. std::shared_ptr<cmDebugger::cmDebuggerAdapter> DebuggerAdapter;
  71. #endif
  72. };