summaryrefslogtreecommitdiffstats
path: root/Source/cmCommand.cxx
blob: 181b412661f8b0377469abf65c6e963c15d3c05e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#include "cmCommand.h"

#include "cmMakefile.h"
#include "cmake.h"

class cmExecutionStatus;
struct cmListFileArgument;

bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
                                  cmExecutionStatus& status)
{
  std::vector<std::string> expandedArguments;
  if (!this->Makefile->ExpandArguments(args, expandedArguments)) {
    // There was an error expanding arguments.  It was already
    // reported, so we can skip this command without error.
    return true;
  }
  return this->InitialPass(expandedArguments, status);
}

const char* cmCommand::GetError()
{
  if (this->Error.empty()) {
    this->Error = this->GetName();
    this->Error += " unknown error.";
  }
  return this->Error.c_str();
}

void cmCommand::SetError(const std::string& e)
{
  this->Error = this->GetName();
  this->Error += " ";
  this->Error += e;
}

bool cmCommand::Disallowed(cmPolicies::PolicyID pol, const char* e)
{
  switch (this->Makefile->GetPolicyStatus(pol)) {
    case cmPolicies::WARN:
      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
                                   cmPolicies::GetPolicyWarning(pol));
    case cmPolicies::OLD:
      return false;
    case cmPolicies::REQUIRED_IF_USED:
    case cmPolicies::REQUIRED_ALWAYS:
    case cmPolicies::NEW:
      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
      break;
  }
  return true;
}