cmMessageCommand.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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->IsOn("CMAKE_ERROR_DEVELOPER_WARNINGS"))
  43. {
  44. fatal = true;
  45. type = cmake::AUTHOR_ERROR;
  46. }
  47. else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"))
  48. {
  49. type = cmake::AUTHOR_WARNING;
  50. }
  51. else
  52. {
  53. return true;
  54. }
  55. ++i;
  56. }
  57. else if (*i == "STATUS")
  58. {
  59. status = true;
  60. ++i;
  61. }
  62. else if (*i == "DEPRECATION")
  63. {
  64. if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED"))
  65. {
  66. fatal = true;
  67. type = cmake::DEPRECATION_ERROR;
  68. }
  69. else if (this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))
  70. {
  71. type = cmake::DEPRECATION_WARNING;
  72. }
  73. else
  74. {
  75. return true;
  76. }
  77. ++i;
  78. }
  79. std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
  80. if (type != cmake::MESSAGE)
  81. {
  82. this->Makefile->IssueMessage(type, message);
  83. }
  84. else
  85. {
  86. if (status)
  87. {
  88. this->Makefile->DisplayStatus(message.c_str(), -1);
  89. }
  90. else
  91. {
  92. cmSystemTools::Message(message.c_str());
  93. }
  94. }
  95. if(fatal)
  96. {
  97. cmSystemTools::SetFatalErrorOccured();
  98. }
  99. return true;
  100. }