cmMessageCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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::string message;
  21. std::vector<std::string>::const_iterator i = args.begin();
  22. cmake::MessageType type = cmake::MESSAGE;
  23. bool status = false;
  24. bool fatal = false;
  25. if (*i == "SEND_ERROR")
  26. {
  27. type = cmake::FATAL_ERROR;
  28. ++i;
  29. }
  30. else if (*i == "FATAL_ERROR")
  31. {
  32. fatal = true;
  33. type = cmake::FATAL_ERROR;
  34. ++i;
  35. }
  36. else if (*i == "WARNING")
  37. {
  38. type = cmake::WARNING;
  39. ++i;
  40. }
  41. else if (*i == "AUTHOR_WARNING")
  42. {
  43. type = cmake::AUTHOR_WARNING;
  44. ++i;
  45. }
  46. else if (*i == "STATUS")
  47. {
  48. status = true;
  49. ++i;
  50. }
  51. for(;i != args.end(); ++i)
  52. {
  53. message += *i;
  54. }
  55. if (type != cmake::MESSAGE)
  56. {
  57. this->Makefile->IssueMessage(type, message.c_str());
  58. }
  59. else
  60. {
  61. if (status)
  62. {
  63. this->Makefile->DisplayStatus(message.c_str(), -1);
  64. }
  65. else
  66. {
  67. cmSystemTools::Message(message.c_str());
  68. }
  69. }
  70. if(fatal)
  71. {
  72. cmSystemTools::SetFatalErrorOccured();
  73. }
  74. return true;
  75. }