summaryrefslogtreecommitdiff
path: root/Source/cmSetPropertyCommand.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2014-05-15 19:12:40 +0200
committerBrad King <brad.king@kitware.com>2014-05-28 12:28:18 -0400
commit15a8af21e8bd8354dfff2063e01f695f85efdeb8 (patch)
treeb7d98cab3ba63f61074a4f63a250934f0294826a /Source/cmSetPropertyCommand.cxx
parent032961c6ac81d82270a7b1986935111aa5e32a56 (diff)
downloadcmake-15a8af21e8bd8354dfff2063e01f695f85efdeb8.tar.gz
Add an "installed file" property scope
Teach set_property and get_property an "INSTALL" property type to be associated with install-tree file paths. Make the properties available to CPack for use during packaging. Add a "prop_inst" Sphinx domain object type for documentation of such properties.
Diffstat (limited to 'Source/cmSetPropertyCommand.cxx')
-rw-r--r--Source/cmSetPropertyCommand.cxx59
1 files changed, 58 insertions, 1 deletions
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 5f970f82a8..c624d170ad 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -61,11 +61,16 @@ bool cmSetPropertyCommand
{
scope = cmProperty::CACHE;
}
+ else if(*arg == "INSTALL")
+ {
+ scope = cmProperty::INSTALL;
+ }
else
{
cmOStringStream e;
e << "given invalid scope " << *arg << ". "
- << "Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, CACHE.";
+ << "Valid scopes are GLOBAL, DIRECTORY, "
+ "TARGET, SOURCE, TEST, CACHE, INSTALL.";
this->SetError(e.str());
return false;
}
@@ -135,6 +140,7 @@ bool cmSetPropertyCommand
case cmProperty::SOURCE_FILE: return this->HandleSourceMode();
case cmProperty::TEST: return this->HandleTestMode();
case cmProperty::CACHE: return this->HandleCacheMode();
+ case cmProperty::INSTALL: return this->HandleInstallMode();
case cmProperty::VARIABLE:
case cmProperty::CACHED_VARIABLE:
@@ -488,3 +494,54 @@ bool cmSetPropertyCommand::HandleCacheEntry(cmCacheManager::CacheIterator& it)
return true;
}
+
+//----------------------------------------------------------------------------
+bool cmSetPropertyCommand::HandleInstallMode()
+{
+ cmake* cm = this->Makefile->GetCMakeInstance();
+
+ for(std::set<std::string>::const_iterator i = this->Names.begin();
+ i != this->Names.end(); ++i)
+ {
+ if(cmInstalledFile* file = cm->GetOrCreateInstalledFile(
+ this->Makefile, *i))
+ {
+ if(!this->HandleInstall(file))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "given INSTALL name that could not be found or created: " << *i;
+ this->SetError(e.str());
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmSetPropertyCommand::HandleInstall(cmInstalledFile* file)
+{
+ // Set or append the property.
+ std::string const& name = this->PropertyName;
+
+ cmMakefile* mf = this->Makefile;
+
+ const char *value = this->PropertyValue.c_str();
+ if (this->Remove)
+ {
+ file->RemoveProperty(name);
+ }
+ else if(this->AppendMode)
+ {
+ file->AppendProperty(mf, name, value, this->AppendAsString);
+ }
+ else
+ {
+ file->SetProperty(mf, name, value);
+ }
+ return true;
+}