cmMessageCommand.cxx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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::InitialPass(std::vector<std::string> const& args,
  13. cmExecutionStatus&)
  14. {
  15. if (args.size() < 1) {
  16. this->SetError("called with incorrect number of arguments");
  17. return false;
  18. }
  19. std::vector<std::string>::const_iterator i = args.begin();
  20. cmake::MessageType type = cmake::MESSAGE;
  21. bool status = false;
  22. bool fatal = false;
  23. if (*i == "SEND_ERROR") {
  24. type = cmake::FATAL_ERROR;
  25. ++i;
  26. } else if (*i == "FATAL_ERROR") {
  27. fatal = true;
  28. type = cmake::FATAL_ERROR;
  29. ++i;
  30. } else if (*i == "WARNING") {
  31. type = cmake::WARNING;
  32. ++i;
  33. } else if (*i == "AUTHOR_WARNING") {
  34. if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
  35. !this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
  36. fatal = true;
  37. type = cmake::AUTHOR_ERROR;
  38. } else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
  39. type = cmake::AUTHOR_WARNING;
  40. } else {
  41. return true;
  42. }
  43. ++i;
  44. } else if (*i == "STATUS") {
  45. status = true;
  46. ++i;
  47. } else if (*i == "DEPRECATION") {
  48. if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) {
  49. fatal = true;
  50. type = cmake::DEPRECATION_ERROR;
  51. } else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") ||
  52. this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) {
  53. type = cmake::DEPRECATION_WARNING;
  54. } else {
  55. return true;
  56. }
  57. ++i;
  58. }
  59. std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
  60. if (type != cmake::MESSAGE) {
  61. // we've overriden the message type, above, so force IssueMessage to use it
  62. this->Makefile->IssueMessage(type, message, true);
  63. } else {
  64. if (status) {
  65. this->Makefile->DisplayStatus(message.c_str(), -1);
  66. } else {
  67. cmSystemTools::Message(message.c_str());
  68. }
  69. }
  70. if (fatal) {
  71. cmSystemTools::SetFatalErrorOccured();
  72. }
  73. return true;
  74. }