1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDefinePropertyCommand.cxx,v $
6 Date: $Date: 2009-06-15 20:12:25 $
7 Version: $Revision: 1.5 $
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"
20 // cmDefinePropertiesCommand
21 bool cmDefinePropertyCommand
22 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
26 this->SetError("called with incorrect number of arguments");
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
;
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());
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")
85 else if(args
[i
] == "FULL_DOCS")
89 else if(args
[i
] == "INHERITED")
94 else if(doing
== DoingProperty
)
97 this->PropertyName
= args
[i
];
99 else if(doing
== DoingBrief
)
101 this->BriefDocs
+= args
[i
];
103 else if(doing
== DoingFull
)
105 this->FullDocs
+= args
[i
];
110 e
<< "given invalid argument \"" << args
[i
] << "\".";
111 this->SetError(e
.str().c_str());
116 // Make sure a property name was found.
117 if(this->PropertyName
.empty())
119 this->SetError("not given a PROPERTY <name> argument.");
123 // Make sure documentation was given.
124 if(this->BriefDocs
.empty())
126 this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
129 if(this->FullDocs
.empty())
131 this->SetError("not given a FULL_DOCS <full-doc> argument.");
135 // Actually define the property.
136 this->Makefile
->GetCMakeInstance()->DefineProperty
137 (this->PropertyName
.c_str(), scope
,
138 this->BriefDocs
.c_str(), this->FullDocs
.c_str(), inherited
);