summaryrefslogtreecommitdiffstats
path: root/Source/cmGetPropertyCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-03-10 15:10:59 (GMT)
committerBrad King <brad.king@kitware.com>2009-03-10 15:10:59 (GMT)
commite5e91d617940cab2ea4e8630c6c20cd09794b3a9 (patch)
tree07799700331300e0e2e2a4ffdef98f5040f20736 /Source/cmGetPropertyCommand.cxx
parentca9fb4826f89722a5a190e0c69e6bf5c26889a55 (diff)
downloadCMake-e5e91d617940cab2ea4e8630c6c20cd09794b3a9.zip
CMake-e5e91d617940cab2ea4e8630c6c20cd09794b3a9.tar.gz
CMake-e5e91d617940cab2ea4e8630c6c20cd09794b3a9.tar.bz2
ENH: Teach set/get_property about CACHE properties
This adds the CACHE option to set_property and get_property commands. This allows full control over cache entry information, so advanced users can tweak their project cache as desired. The set_property command allows only pre-defined CACHE properties to be set since others would not persist anyway.
Diffstat (limited to 'Source/cmGetPropertyCommand.cxx')
-rw-r--r--Source/cmGetPropertyCommand.cxx27
1 files changed, 26 insertions, 1 deletions
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 88a3e7c..3446fb2 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -65,12 +65,16 @@ bool cmGetPropertyCommand
{
scope = cmProperty::VARIABLE;
}
+ else if(args[1] == "CACHE")
+ {
+ scope = cmProperty::CACHE;
+ }
else
{
cmOStringStream e;
e << "given invalid scope " << args[1] << ". "
<< "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE.";
+ << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE.";
this->SetError(e.str().c_str());
return false;
}
@@ -187,6 +191,7 @@ bool cmGetPropertyCommand
case cmProperty::SOURCE_FILE: return this->HandleSourceMode();
case cmProperty::TEST: return this->HandleTestMode();
case cmProperty::VARIABLE: return this->HandleVariableMode();
+ case cmProperty::CACHE: return this->HandleCacheMode();
case cmProperty::CACHED_VARIABLE:
break; // should never happen
@@ -359,3 +364,23 @@ bool cmGetPropertyCommand::HandleVariableMode()
return this->StoreResult
(this->Makefile->GetDefinition(this->PropertyName.c_str()));
}
+
+//----------------------------------------------------------------------------
+bool cmGetPropertyCommand::HandleCacheMode()
+{
+ if(this->Name.empty())
+ {
+ this->SetError("not given name for CACHE scope.");
+ return false;
+ }
+
+ const char* value = 0;
+ cmCacheManager::CacheIterator it =
+ this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str());
+ if(!it.IsAtEnd())
+ {
+ value = it.GetProperty(this->PropertyName.c_str());
+ }
+ this->StoreResult(value);
+ return true;
+}