cmMessageCommand.cxx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmMessageCommand.h"
  14. // cmLibraryCommand
  15. bool cmMessageCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::string message;
  23. std::vector<std::string>::const_iterator i = args.begin();
  24. bool send_error = false;
  25. bool fatal_error = false;
  26. bool status = false;
  27. if (*i == "SEND_ERROR")
  28. {
  29. send_error = true;
  30. ++i;
  31. }
  32. else
  33. {
  34. if (*i == "STATUS")
  35. {
  36. status = true;
  37. ++i;
  38. }
  39. else
  40. {
  41. if (*i == "FATAL_ERROR")
  42. {
  43. fatal_error = true;
  44. ++i;
  45. }
  46. }
  47. }
  48. for(;i != args.end(); ++i)
  49. {
  50. message += *i;
  51. }
  52. if (send_error || fatal_error)
  53. {
  54. cmSystemTools::Error(message.c_str());
  55. }
  56. else
  57. {
  58. if (status)
  59. {
  60. this->Makefile->DisplayStatus(message.c_str(), -1);
  61. }
  62. else
  63. {
  64. cmSystemTools::Message(message.c_str());
  65. }
  66. }
  67. if(fatal_error )
  68. {
  69. cmSystemTools::SetFatalErrorOccured();
  70. }
  71. return true;
  72. }