cmSetDirectoryPropertiesCommand.cxx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "cmExecutionStatus.h"
  5. #include "cmMakefile.h"
  6. // cmSetDirectoryPropertiesCommand
  7. bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
  8. cmExecutionStatus& status)
  9. {
  10. if (args.empty()) {
  11. status.SetError("called with incorrect number of arguments");
  12. return false;
  13. }
  14. // PROPERTIES followed by prop value pairs
  15. if (args.size() % 2 != 1) {
  16. status.SetError("Wrong number of arguments");
  17. return false;
  18. }
  19. for (auto iter = args.begin() + 1; iter != args.end(); iter += 2) {
  20. const std::string& prop = *iter;
  21. if (prop == "VARIABLES") {
  22. status.SetError(
  23. "Variables and cache variables should be set using SET command");
  24. return false;
  25. }
  26. if (prop == "MACROS") {
  27. status.SetError(
  28. "Commands and macros cannot be set using SET_CMAKE_PROPERTIES");
  29. return false;
  30. }
  31. status.GetMakefile().SetProperty(prop, *(iter + 1));
  32. }
  33. return true;
  34. }