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