cmMessageCommand.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmMessageCommand.h"
  11. // cmLibraryCommand
  12. bool cmMessageCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. std::vector<std::string>::const_iterator i = args.begin();
  21. cmake::MessageType type = cmake::MESSAGE;
  22. bool status = false;
  23. bool fatal = false;
  24. if (*i == "SEND_ERROR")
  25. {
  26. type = cmake::FATAL_ERROR;
  27. ++i;
  28. }
  29. else if (*i == "FATAL_ERROR")
  30. {
  31. fatal = true;
  32. type = cmake::FATAL_ERROR;
  33. ++i;
  34. }
  35. else if (*i == "WARNING")
  36. {
  37. type = cmake::WARNING;
  38. ++i;
  39. }
  40. else if (*i == "AUTHOR_WARNING")
  41. {
  42. if (this->Makefile->GetCMakeInstance()->GetSuppressDevWarnings(
  43. this->Makefile))
  44. {
  45. return true;
  46. }
  47. else
  48. {
  49. type = cmake::AUTHOR_WARNING;
  50. }
  51. ++i;
  52. }
  53. else if (*i == "STATUS")
  54. {
  55. status = true;
  56. ++i;
  57. }
  58. else if (*i == "DEPRECATION")
  59. {
  60. if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED"))
  61. {
  62. fatal = true;
  63. type = cmake::DEPRECATION_ERROR;
  64. }
  65. else
  66. {
  67. if (this->Makefile->GetCMakeInstance()->GetSuppressDeprecatedWarnings(
  68. this->Makefile))
  69. {
  70. return true;
  71. }
  72. else
  73. {
  74. type = cmake::DEPRECATION_WARNING;
  75. }
  76. }
  77. ++i;
  78. }
  79. std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
  80. if (type != cmake::MESSAGE)
  81. {
  82. // we've overriden the message type, above, so force IssueMessage to use it
  83. this->Makefile->IssueMessage(type, message, true);
  84. }
  85. else
  86. {
  87. if (status)
  88. {
  89. this->Makefile->DisplayStatus(message.c_str(), -1);
  90. }
  91. else
  92. {
  93. cmSystemTools::Message(message.c_str());
  94. }
  95. }
  96. if(fatal)
  97. {
  98. cmSystemTools::SetFatalErrorOccured();
  99. }
  100. return true;
  101. }