cmMessageCommand.cxx 1.73 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1 2
/*=========================================================================

3
  Program:   CMake - Cross-Platform Makefile Generator
Ken Martin's avatar
Ken Martin committed
4 5 6 7 8
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

9 10
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
Ken Martin's avatar
Ken Martin committed
11

Will Schroeder's avatar
Will Schroeder committed
12 13 14
     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.
Ken Martin's avatar
Ken Martin committed
15 16 17 18 19

=========================================================================*/
#include "cmMessageCommand.h"

// cmLibraryCommand
20
bool cmMessageCommand::InitialPass(std::vector<std::string> const& args)
Ken Martin's avatar
Ken Martin committed
21
{
22
  if(args.size() < 1 )
Ken Martin's avatar
Ken Martin committed
23 24 25 26
    {
    this->SetError("called with incorrect number of arguments");
    return false;
    }
Bill Hoffman's avatar
Bill Hoffman committed
27 28
  std::string message;
  std::vector<std::string>::const_iterator i = args.begin();
29 30

  bool send_error = false;
31
  bool fatal_error = false;
32
  bool status = false;
33 34 35 36 37
  if (*i == "SEND_ERROR")
    {
    send_error = true;
    ++i;
    }
38 39
  else
    {
40 41 42 43 44 45 46 47
    if (*i == "STATUS")
      {
      status = true;
      ++i;
      }
    else
      {
      if (*i == "FATAL_ERROR")
48
        {
49 50
        fatal_error = true;
        ++i;
51
        }
52
      }
53
    }
54

Bill Hoffman's avatar
Bill Hoffman committed
55
  for(;i != args.end(); ++i)
Ken Martin's avatar
Ken Martin committed
56
    {
Bill Hoffman's avatar
Bill Hoffman committed
57
    message += *i;
Ken Martin's avatar
Ken Martin committed
58
    }
59 60 61 62 63 64 65

  if (send_error)
    {
    cmSystemTools::Error(message.c_str());
    }
  else
    {
66 67 68 69 70 71 72 73
      if (status)
        {
          m_Makefile->DisplayStatus(message.c_str(), -1);
        }
      else
        {
          cmSystemTools::Message(message.c_str());
        }
74
    }
75 76 77 78
  if(fatal_error)
    {
    cmSystemTools::SetFatalErrorOccured();
    }
Ken Martin's avatar
Ken Martin committed
79 80 81
  return true;
}