cmMessageCommand.cxx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #include "cmMessenger.h"
  12. // cmLibraryCommand
  13. bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
  14. cmExecutionStatus&)
  15. {
  16. if (args.empty()) {
  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. type = cmake::FATAL_ERROR;
  26. ++i;
  27. } else if (*i == "FATAL_ERROR") {
  28. fatal = true;
  29. type = cmake::FATAL_ERROR;
  30. ++i;
  31. } else if (*i == "WARNING") {
  32. type = cmake::WARNING;
  33. ++i;
  34. } else if (*i == "AUTHOR_WARNING") {
  35. if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
  36. !this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
  37. fatal = true;
  38. type = cmake::AUTHOR_ERROR;
  39. } else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
  40. type = cmake::AUTHOR_WARNING;
  41. } else {
  42. return true;
  43. }
  44. ++i;
  45. } else if (*i == "STATUS") {
  46. status = true;
  47. ++i;
  48. } else if (*i == "DEPRECATION") {
  49. if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) {
  50. fatal = true;
  51. type = cmake::DEPRECATION_ERROR;
  52. } else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") ||
  53. this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) {
  54. type = cmake::DEPRECATION_WARNING;
  55. } else {
  56. return true;
  57. }
  58. ++i;
  59. }
  60. std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
  61. if (type != cmake::MESSAGE) {
  62. // we've overriden the message type, above, so display it directly
  63. cmMessenger* m = this->Makefile->GetMessenger();
  64. m->DisplayMessage(type, message, this->Makefile->GetBacktrace());
  65. } else {
  66. if (status) {
  67. this->Makefile->DisplayStatus(message.c_str(), -1);
  68. } else {
  69. cmSystemTools::Message(message.c_str());
  70. }
  71. }
  72. if (fatal) {
  73. cmSystemTools::SetFatalErrorOccured();
  74. }
  75. return true;
  76. }