Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmMessageCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmMessageCommand.h"
13
14 // cmLibraryCommand
15 bool cmMessageCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   if(args.size() < 1 )
19     {
20     this->SetError("called with incorrect number of arguments");
21     return false;
22     }
23   std::string message;
24   std::vector<std::string>::const_iterator i = args.begin();
25
26   cmake::MessageType type = cmake::MESSAGE;
27   bool status = false;
28   bool fatal = false;
29   if (*i == "SEND_ERROR")
30     {
31     type = cmake::FATAL_ERROR;
32     ++i;
33     }
34   else if (*i == "FATAL_ERROR")
35     {
36     fatal = true;
37     type = cmake::FATAL_ERROR;
38     ++i;
39     }
40   else if (*i == "WARNING")
41     {
42     type = cmake::WARNING;
43     ++i;
44     }
45   else if (*i == "AUTHOR_WARNING")
46     {
47     type = cmake::AUTHOR_WARNING;
48     ++i;
49     }
50   else if (*i == "STATUS")
51     {
52     status = true;
53     ++i;
54     }
55
56   for(;i != args.end(); ++i)
57     {
58     message += *i;
59     }
60
61   if (type != cmake::MESSAGE)
62     {
63     this->Makefile->IssueMessage(type, message.c_str());
64     }
65   else
66     {
67     if (status)
68       {
69       this->Makefile->DisplayStatus(message.c_str(), -1);
70       }
71     else
72       {
73       cmSystemTools::Message(message.c_str());
74       }
75     }
76   if(fatal)
77     {
78     cmSystemTools::SetFatalErrorOccured();
79     }
80   return true;
81 }
82