cmMessageCommand.cxx 2.1 KB

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