summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2008-04-01 18:22:09 (GMT)
committerKen Martin <ken.martin@kitware.com>2008-04-01 18:22:09 (GMT)
commit16f1cc9b59c59dcd763ea9d2b65548fa5f7b4fa1 (patch)
tree0926d56a73423ec3f875a88d5b72015597fa81e6 /Source
parentd00476610d830a0db96da26d6c87e33d36860120 (diff)
downloadCMake-16f1cc9b59c59dcd763ea9d2b65548fa5f7b4fa1.zip
CMake-16f1cc9b59c59dcd763ea9d2b65548fa5f7b4fa1.tar.gz
CMake-16f1cc9b59c59dcd763ea9d2b65548fa5f7b4fa1.tar.bz2
ENH: support unset of properties
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGetPropertyCommand.cxx21
-rw-r--r--Source/cmGetPropertyCommand.h9
-rw-r--r--Source/cmSetPropertyCommand.cxx48
-rw-r--r--Source/cmSetPropertyCommand.h1
-rw-r--r--Source/cmSourceFile.cxx4
-rw-r--r--Source/cmTarget.cxx4
-rw-r--r--Source/cmTest.cxx4
7 files changed, 65 insertions, 26 deletions
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 830be0c..3d2140c 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -94,6 +94,11 @@ bool cmGetPropertyCommand
doing = DoingNone;
this->InfoType = OutFullDoc;
}
+ else if(args[i] == "SET")
+ {
+ doing = DoingNone;
+ this->InfoType = OutSet;
+ }
else if(args[i] == "DEFINED")
{
doing = DoingNone;
@@ -158,6 +163,20 @@ bool cmGetPropertyCommand
}
this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str());
}
+ else if(this->InfoType == OutDefined)
+ {
+ // Lookup if the property is defined
+ const char *value;
+ if(this->Makefile->GetCMakeInstance()->
+ GetPropertyDefinition(this->PropertyName.c_str(), scope))
+ {
+ this->Makefile->AddDefinition(this->Variable.c_str(), "1");
+ }
+ else
+ {
+ this->Makefile->AddDefinition(this->Variable.c_str(), "0");
+ }
+ }
else
{
// Dispatch property getting.
@@ -181,7 +200,7 @@ bool cmGetPropertyCommand
//----------------------------------------------------------------------------
bool cmGetPropertyCommand::StoreResult(const char* value)
{
- if(this->InfoType == OutDefined)
+ if(this->InfoType == OutSet)
{
this->Makefile->AddDefinition(this->Variable.c_str(), value? "1":"0");
}
diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h
index 0df2371..d7503ba 100644
--- a/Source/cmGetPropertyCommand.h
+++ b/Source/cmGetPropertyCommand.h
@@ -68,7 +68,7 @@ public:
" TEST <test> |\n"
" VARIABLE>\n"
" PROPERTY <name>\n"
- " [DEFINED | BRIEF_DOCS | FULL_DOCS])\n"
+ " [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])\n"
"Get one property from one object in a scope. "
"The first argument specifies the variable in which to store the "
"result. "
@@ -85,8 +85,11 @@ public:
"The required PROPERTY option is immediately followed by the name "
"of the property to get. "
"If the property is not set an empty value is returned. "
+ "If the SET option is given the variable is set to a boolean "
+ "value indicating whether the property has been set."
"If the DEFINED option is given the variable is set to a boolean "
- "value indicating whether the property has been set. "
+ "value indicating whether the property has been defined "
+ "such as with define_property. "
"If BRIEF_DOCS or FULL_DOCS is given then the variable is set to "
"a string containing documentation for the requested property. "
"If documentation is requested for a property that has not been "
@@ -95,7 +98,7 @@ public:
cmTypeMacro(cmGetPropertyCommand, cmCommand);
private:
- enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc };
+ enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc, OutSet };
std::string Variable;
std::string Name;
std::string PropertyName;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index c1ed54b..21eeaf1 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -23,6 +23,7 @@
cmSetPropertyCommand::cmSetPropertyCommand()
{
this->AppendMode = false;
+ this->Remove = true;
}
//----------------------------------------------------------------------------
@@ -96,6 +97,7 @@ bool cmSetPropertyCommand
this->PropertyValue += sep;
sep = ";";
this->PropertyValue += *arg;
+ this->Remove = false;
}
else
{
@@ -141,13 +143,18 @@ bool cmSetPropertyCommand::HandleGlobalMode()
// Set or append the property.
cmake* cm = this->Makefile->GetCMakeInstance();
const char* name = this->PropertyName.c_str();
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ value = 0;
+ }
if(this->AppendMode)
{
- cm->AppendProperty(name, this->PropertyValue.c_str());
+ cm->AppendProperty(name, value);
}
else
{
- cm->SetProperty(name, this->PropertyValue.c_str());
+ cm->SetProperty(name, value);
}
return true;
@@ -202,13 +209,18 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
// Set or append the property.
const char* name = this->PropertyName.c_str();
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ value = 0;
+ }
if(this->AppendMode)
{
- mf->AppendProperty(name, this->PropertyValue.c_str());
+ mf->AppendProperty(name, value);
}
else
{
- mf->SetProperty(name, this->PropertyValue.c_str());
+ mf->SetProperty(name, value);
}
return true;
@@ -245,13 +257,18 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ value = 0;
+ }
if(this->AppendMode)
{
- target->AppendProperty(name, this->PropertyValue.c_str());
+ target->AppendProperty(name, value);
}
else
{
- target->SetProperty(name, this->PropertyValue.c_str());
+ target->SetProperty(name, value);
}
return true;
@@ -287,13 +304,19 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ value = 0;
+ }
+
if(this->AppendMode)
{
- sf->AppendProperty(name, this->PropertyValue.c_str());
+ sf->AppendProperty(name, value);
}
else
{
- sf->SetProperty(name, this->PropertyValue.c_str());
+ sf->SetProperty(name, value);
}
return true;
}
@@ -343,13 +366,18 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ value = 0;
+ }
if(this->AppendMode)
{
- test->AppendProperty(name, this->PropertyValue.c_str());
+ test->AppendProperty(name, value);
}
else
{
- test->SetProperty(name, this->PropertyValue.c_str());
+ test->SetProperty(name, value);
}
return true;
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index a6d3966..8ef0b7c 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -92,6 +92,7 @@ private:
std::set<cmStdString> Names;
std::string PropertyName;
std::string PropertyValue;
+ bool Remove;
bool AppendMode;
// Implementation of each property type.
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index a9eb668..1cc2b2c 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -262,10 +262,6 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
{
return;
}
- if (!value)
- {
- value = "NOTFOUND";
- }
this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ee2930e..aa4c403 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1591,10 +1591,6 @@ void cmTarget::SetProperty(const char* prop, const char* value)
{
return;
}
- if (!value)
- {
- value = "NOTFOUND";
- }
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 0a59fe0..2abebd8 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -76,10 +76,6 @@ void cmTest::SetProperty(const char* prop, const char* value)
{
return;
}
- if (!value)
- {
- value = "NOTFOUND";
- }
this->Properties.SetProperty(prop, value, cmProperty::TEST);
}