cmSetDirectoryPropertiesCommand.cxx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmSetDirectoryPropertiesCommand.h"
  11. #include "cmake.h"
  12. // cmSetDirectoryPropertiesCommand
  13. bool cmSetDirectoryPropertiesCommand::InitialPass(
  14. std::vector<std::string> const& args, cmExecutionStatus&)
  15. {
  16. if (args.empty()) {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. std::string errors;
  21. bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
  22. this->Makefile, args.begin() + 1, args.end(), errors);
  23. if (!ret) {
  24. this->SetError(errors);
  25. }
  26. return ret;
  27. }
  28. bool cmSetDirectoryPropertiesCommand::RunCommand(
  29. cmMakefile* mf, std::vector<std::string>::const_iterator ait,
  30. std::vector<std::string>::const_iterator aitend, std::string& errors)
  31. {
  32. for (; ait != aitend; ait += 2) {
  33. if (ait + 1 == aitend) {
  34. errors = "Wrong number of arguments";
  35. return false;
  36. }
  37. const std::string& prop = *ait;
  38. const std::string& value = *(ait + 1);
  39. if (prop == "VARIABLES") {
  40. errors = "Variables and cache variables should be set using SET command";
  41. return false;
  42. }
  43. if (prop == "MACROS") {
  44. errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
  45. return false;
  46. }
  47. mf->SetProperty(prop, value.c_str());
  48. }
  49. return true;
  50. }