2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2006-12-07 17:45:32 +03:00
|
|
|
#include "cmDefinePropertyCommand.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2015-04-05 00:33:26 +03:00
|
|
|
#include "cmState.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2006-12-07 17:45:32 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2016-09-16 00:59:29 +03:00
|
|
|
if (args.empty()) {
|
2006-12-07 17:45:32 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
|
2008-02-14 21:36:23 +03:00
|
|
|
// Get the scope in which to define the property.
|
2006-12-07 17:45:32 +03:00
|
|
|
cmProperty::ScopeType scope;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args[0] == "GLOBAL") {
|
2006-12-07 17:45:32 +03:00
|
|
|
scope = cmProperty::GLOBAL;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "DIRECTORY") {
|
2006-12-07 17:45:32 +03:00
|
|
|
scope = cmProperty::DIRECTORY;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "TARGET") {
|
2006-12-07 17:45:32 +03:00
|
|
|
scope = cmProperty::TARGET;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "SOURCE") {
|
2006-12-07 17:45:32 +03:00
|
|
|
scope = cmProperty::SOURCE_FILE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "TEST") {
|
2006-12-07 17:45:32 +03:00
|
|
|
scope = cmProperty::TEST;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "VARIABLE") {
|
2007-06-25 18:34:21 +04:00
|
|
|
scope = cmProperty::VARIABLE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[0] == "CACHED_VARIABLE") {
|
2007-06-25 18:34:21 +04:00
|
|
|
scope = cmProperty::CACHED_VARIABLE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-02-14 21:36:23 +03:00
|
|
|
e << "given invalid scope " << args[0] << ". "
|
|
|
|
<< "Valid scopes are "
|
|
|
|
<< "GLOBAL, DIRECTORY, TARGET, SOURCE, "
|
|
|
|
<< "TEST, VARIABLE, CACHED_VARIABLE.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2006-12-07 17:45:32 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
|
2008-02-14 21:36:23 +03:00
|
|
|
// Parse remaining arguments.
|
|
|
|
bool inherited = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
enum Doing
|
|
|
|
{
|
|
|
|
DoingNone,
|
|
|
|
DoingProperty,
|
|
|
|
DoingBrief,
|
|
|
|
DoingFull
|
|
|
|
};
|
2008-02-14 21:36:23 +03:00
|
|
|
Doing doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
|
|
|
if (args[i] == "PROPERTY") {
|
2008-02-14 21:36:23 +03:00
|
|
|
doing = DoingProperty;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "BRIEF_DOCS") {
|
2008-02-14 21:36:23 +03:00
|
|
|
doing = DoingBrief;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "FULL_DOCS") {
|
2008-02-14 21:36:23 +03:00
|
|
|
doing = DoingFull;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "INHERITED") {
|
2008-02-14 21:36:23 +03:00
|
|
|
doing = DoingNone;
|
|
|
|
inherited = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingProperty) {
|
2008-02-14 21:36:23 +03:00
|
|
|
doing = DoingNone;
|
|
|
|
this->PropertyName = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingBrief) {
|
2009-06-16 00:12:27 +04:00
|
|
|
this->BriefDocs += args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingFull) {
|
2009-06-16 00:12:27 +04:00
|
|
|
this->FullDocs += args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-02-14 21:36:23 +03:00
|
|
|
e << "given invalid argument \"" << args[i] << "\".";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2008-02-14 21:36:23 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-14 21:36:23 +03:00
|
|
|
|
|
|
|
// Make sure a property name was found.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PropertyName.empty()) {
|
2008-02-14 21:36:23 +03:00
|
|
|
this->SetError("not given a PROPERTY <name> argument.");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-14 21:36:23 +03:00
|
|
|
|
|
|
|
// Make sure documentation was given.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->BriefDocs.empty()) {
|
2008-02-14 21:36:23 +03:00
|
|
|
this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->FullDocs.empty()) {
|
2008-02-14 21:36:23 +03:00
|
|
|
this->SetError("not given a FULL_DOCS <full-doc> argument.");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-14 21:36:23 +03:00
|
|
|
|
|
|
|
// Actually define the property.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->DefineProperty(
|
|
|
|
this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(),
|
|
|
|
inherited);
|
2008-02-14 21:36:23 +03:00
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
return true;
|
|
|
|
}
|