1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDefinePropertyCommand.cxx,v $
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"
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
)
102 this->BriefDocs
= args
[i
];
104 else if(doing
== DoingFull
)
107 this->FullDocs
= args
[i
];
112 e
<< "given invalid argument \"" << args
[i
] << "\".";
113 this->SetError(e
.str().c_str());
118 // Make sure a property name was found.
119 if(this->PropertyName
.empty())
121 this->SetError("not given a PROPERTY <name> argument.");
125 // Make sure documentation was given.
126 if(this->BriefDocs
.empty())
128 this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
131 if(this->FullDocs
.empty())
133 this->SetError("not given a FULL_DOCS <full-doc> argument.");
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
);