Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmDefinePropertyCommand.cxx
blob2161c7dcf3e8a4fed692d4458ae2faf282057842
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDefinePropertyCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/02/14 18:36:23 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmDefinePropertyCommand.h"
18 #include "cmake.h"
20 // cmDefinePropertiesCommand
21 bool cmDefinePropertyCommand
22 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
24 if(args.size() < 1)
26 this->SetError("called with incorrect number of arguments");
27 return false;
30 // Get the scope in which to define the property.
31 cmProperty::ScopeType scope;
32 if(args[0] == "GLOBAL")
34 scope = cmProperty::GLOBAL;
36 else if(args[0] == "DIRECTORY")
38 scope = cmProperty::DIRECTORY;
40 else if(args[0] == "TARGET")
42 scope = cmProperty::TARGET;
44 else if(args[0] == "SOURCE")
46 scope = cmProperty::SOURCE_FILE;
48 else if(args[0] == "TEST")
50 scope = cmProperty::TEST;
52 else if(args[0] == "VARIABLE")
54 scope = cmProperty::VARIABLE;
56 else if (args[0] == "CACHED_VARIABLE")
58 scope = cmProperty::CACHED_VARIABLE;
60 else
62 cmOStringStream e;
63 e << "given invalid scope " << args[0] << ". "
64 << "Valid scopes are "
65 << "GLOBAL, DIRECTORY, TARGET, SOURCE, "
66 << "TEST, VARIABLE, CACHED_VARIABLE.";
67 this->SetError(e.str().c_str());
68 return false;
71 // Parse remaining arguments.
72 bool inherited = false;
73 enum Doing { DoingNone, DoingProperty, DoingBrief, DoingFull };
74 Doing doing = DoingNone;
75 for(unsigned int i=1; i < args.size(); ++i)
77 if(args[i] == "PROPERTY")
79 doing = DoingProperty;
81 else if(args[i] == "BRIEF_DOCS")
83 doing = DoingBrief;
85 else if(args[i] == "FULL_DOCS")
87 doing = DoingFull;
89 else if(args[i] == "INHERITED")
91 doing = DoingNone;
92 inherited = true;
94 else if(doing == DoingProperty)
96 doing = DoingNone;
97 this->PropertyName = args[i];
99 else if(doing == DoingBrief)
101 doing = DoingNone;
102 this->BriefDocs = args[i];
104 else if(doing == DoingFull)
106 doing = DoingNone;
107 this->FullDocs = args[i];
109 else
111 cmOStringStream e;
112 e << "given invalid argument \"" << args[i] << "\".";
113 this->SetError(e.str().c_str());
114 return false;
118 // Make sure a property name was found.
119 if(this->PropertyName.empty())
121 this->SetError("not given a PROPERTY <name> argument.");
122 return false;
125 // Make sure documentation was given.
126 if(this->BriefDocs.empty())
128 this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
129 return false;
131 if(this->FullDocs.empty())
133 this->SetError("not given a FULL_DOCS <full-doc> argument.");
134 return false;
137 // Actually define the property.
138 this->Makefile->GetCMakeInstance()->DefineProperty
139 (this->PropertyName.c_str(), scope,
140 this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);
142 return true;