cmSetDirectoryPropertiesCommand.cxx 1.41 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4
#include "cmSetDirectoryPropertiesCommand.h"

5 6 7
#include "cmMakefile.h"

class cmExecutionStatus;
8 9

// cmSetDirectoryPropertiesCommand
10 11
bool cmSetDirectoryPropertiesCommand::InitialPass(
  std::vector<std::string> const& args, cmExecutionStatus&)
12
{
13
  if (args.empty()) {
14 15
    this->SetError("called with incorrect number of arguments");
    return false;
16
  }
17

18
  std::string errors;
19 20 21
  bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
    this->Makefile, args.begin() + 1, args.end(), errors);
  if (!ret) {
22
    this->SetError(errors);
23
  }
24 25
  return ret;
}
26

27 28 29
bool cmSetDirectoryPropertiesCommand::RunCommand(
  cmMakefile* mf, std::vector<std::string>::const_iterator ait,
  std::vector<std::string>::const_iterator aitend, std::string& errors)
30
{
31 32
  for (; ait != aitend; ait += 2) {
    if (ait + 1 == aitend) {
33
      errors = "Wrong number of arguments";
34
      return false;
35
    }
36
    const std::string& prop = *ait;
37 38 39
    const std::string& value = *(ait + 1);
    if (prop == "VARIABLES") {
      errors = "Variables and cache variables should be set using SET command";
40
      return false;
Daniel Pfeifer's avatar
Daniel Pfeifer committed
41 42
    }
    if (prop == "MACROS") {
43
      errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
44 45
      return false;
    }
46 47
    mf->SetProperty(prop, value.c_str());
  }
48

49 50
  return true;
}