1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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 "cmDefinePropertyCommand.h"
15 // cmDefinePropertiesCommand
16 bool cmDefinePropertyCommand
17 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
21 this->SetError("called with incorrect number of arguments");
25 // Get the scope in which to define the property.
26 cmProperty::ScopeType scope;
27 if(args[0] == "GLOBAL")
29 scope = cmProperty::GLOBAL;
31 else if(args[0] == "DIRECTORY")
33 scope = cmProperty::DIRECTORY;
35 else if(args[0] == "TARGET")
37 scope = cmProperty::TARGET;
39 else if(args[0] == "SOURCE")
41 scope = cmProperty::SOURCE_FILE;
43 else if(args[0] == "TEST")
45 scope = cmProperty::TEST;
47 else if(args[0] == "VARIABLE")
49 scope = cmProperty::VARIABLE;
51 else if (args[0] == "CACHED_VARIABLE")
53 scope = cmProperty::CACHED_VARIABLE;
58 e << "given invalid scope " << args[0] << ". "
59 << "Valid scopes are "
60 << "GLOBAL, DIRECTORY, TARGET, SOURCE, "
61 << "TEST, VARIABLE, CACHED_VARIABLE.";
62 this->SetError(e.str().c_str());
66 // Parse remaining arguments.
67 bool inherited = false;
68 enum Doing { DoingNone, DoingProperty, DoingBrief, DoingFull };
69 Doing doing = DoingNone;
70 for(unsigned int i=1; i < args.size(); ++i)
72 if(args[i] == "PROPERTY")
74 doing = DoingProperty;
76 else if(args[i] == "BRIEF_DOCS")
80 else if(args[i] == "FULL_DOCS")
84 else if(args[i] == "INHERITED")
89 else if(doing == DoingProperty)
92 this->PropertyName = args[i];
94 else if(doing == DoingBrief)
96 this->BriefDocs += args[i];
98 else if(doing == DoingFull)
100 this->FullDocs += args[i];
105 e << "given invalid argument \"" << args[i] << "\".";
106 this->SetError(e.str().c_str());
111 // Make sure a property name was found.
112 if(this->PropertyName.empty())
114 this->SetError("not given a PROPERTY <name> argument.");
118 // Make sure documentation was given.
119 if(this->BriefDocs.empty())
121 this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
124 if(this->FullDocs.empty())
126 this->SetError("not given a FULL_DOCS <full-doc> argument.");
130 // Actually define the property.
131 this->Makefile->GetCMakeInstance()->DefineProperty
132 (this->PropertyName.c_str(), scope,
133 this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);