cmSetDirectoryPropertiesCommand.cxx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmSetDirectoryPropertiesCommand.h"
  4. #include "cmMakefile.h"
  5. class cmExecutionStatus;
  6. // cmSetDirectoryPropertiesCommand
  7. bool cmSetDirectoryPropertiesCommand::InitialPass(
  8. std::vector<std::string> const& args, cmExecutionStatus&)
  9. {
  10. if (args.empty()) {
  11. this->SetError("called with incorrect number of arguments");
  12. return false;
  13. }
  14. std::string errors;
  15. bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
  16. this->Makefile, args.begin() + 1, args.end(), errors);
  17. if (!ret) {
  18. this->SetError(errors);
  19. }
  20. return ret;
  21. }
  22. bool cmSetDirectoryPropertiesCommand::RunCommand(
  23. cmMakefile* mf, std::vector<std::string>::const_iterator ait,
  24. std::vector<std::string>::const_iterator aitend, std::string& errors)
  25. {
  26. for (; ait != aitend; ait += 2) {
  27. if (ait + 1 == aitend) {
  28. errors = "Wrong number of arguments";
  29. return false;
  30. }
  31. const std::string& prop = *ait;
  32. const std::string& value = *(ait + 1);
  33. if (prop == "VARIABLES") {
  34. errors = "Variables and cache variables should be set using SET command";
  35. return false;
  36. }
  37. if (prop == "MACROS") {
  38. errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
  39. return false;
  40. }
  41. mf->SetProperty(prop, value.c_str());
  42. }
  43. return true;
  44. }