cmMessenger.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <string>
  7. #include "cmListFileCache.h"
  8. #include "cmMessageType.h"
  9. class cmMessenger
  10. {
  11. public:
  12. void IssueMessage(
  13. MessageType t, std::string const& text,
  14. cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
  15. void DisplayMessage(MessageType t, std::string const& text,
  16. cmListFileBacktrace const& backtrace) const;
  17. void SetSuppressDevWarnings(bool suppress)
  18. {
  19. this->SuppressDevWarnings = suppress;
  20. }
  21. void SetSuppressDeprecatedWarnings(bool suppress)
  22. {
  23. this->SuppressDeprecatedWarnings = suppress;
  24. }
  25. void SetDevWarningsAsErrors(bool error)
  26. {
  27. this->DevWarningsAsErrors = error;
  28. }
  29. void SetDeprecatedWarningsAsErrors(bool error)
  30. {
  31. this->DeprecatedWarningsAsErrors = error;
  32. }
  33. bool GetSuppressDevWarnings() const { return this->SuppressDevWarnings; }
  34. bool GetSuppressDeprecatedWarnings() const
  35. {
  36. return this->SuppressDeprecatedWarnings;
  37. }
  38. bool GetDevWarningsAsErrors() const { return this->DevWarningsAsErrors; }
  39. bool GetDeprecatedWarningsAsErrors() const
  40. {
  41. return this->DeprecatedWarningsAsErrors;
  42. }
  43. // Print the top of a backtrace.
  44. void PrintBacktraceTitle(std::ostream& out,
  45. cmListFileBacktrace const& bt) const;
  46. private:
  47. bool IsMessageTypeVisible(MessageType t) const;
  48. MessageType ConvertMessageType(MessageType t) const;
  49. bool SuppressDevWarnings = false;
  50. bool SuppressDeprecatedWarnings = false;
  51. bool DevWarningsAsErrors = false;
  52. bool DeprecatedWarningsAsErrors = false;
  53. };