cmMessageCommand.cxx 2.3 KB

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