summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmMakefile.cxx36
-rw-r--r--Source/cmMakefile.h1
-rw-r--r--Source/cmProperty.cxx11
-rw-r--r--Source/cmProperty.h3
-rw-r--r--Source/cmPropertyMap.cxx26
-rw-r--r--Source/cmPropertyMap.h3
-rw-r--r--Source/cmSetPropertyCommand.cxx76
-rw-r--r--Source/cmSetPropertyCommand.h3
-rw-r--r--Source/cmSourceFile.cxx10
-rw-r--r--Source/cmSourceFile.h1
-rw-r--r--Source/cmTarget.cxx10
-rw-r--r--Source/cmTarget.h1
-rw-r--r--Source/cmTest.cxx10
-rw-r--r--Source/cmTest.h1
-rw-r--r--Source/cmake.cxx9
-rw-r--r--Source/cmake.h1
16 files changed, 138 insertions, 64 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1b3ca61dc3..104d007adb 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2613,6 +2613,42 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
}
+void cmMakefile::AppendProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+
+ // handle special props
+ std::string propname = prop;
+ if ( propname == "INCLUDE_DIRECTORIES" )
+ {
+ std::vector<std::string> varArgsExpanded;
+ cmSystemTools::ExpandListArgument(value, varArgsExpanded);
+ for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
+ vi != varArgsExpanded.end(); ++vi)
+ {
+ this->AddIncludeDirectory(vi->c_str());
+ }
+ return;
+ }
+
+ if ( propname == "LINK_DIRECTORIES" )
+ {
+ std::vector<std::string> varArgsExpanded;
+ cmSystemTools::ExpandListArgument(value, varArgsExpanded);
+ for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
+ vi != varArgsExpanded.end(); ++vi)
+ {
+ this->AddLinkDirectory(vi->c_str());
+ }
+ return;
+ }
+
+ this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY);
+}
+
const char *cmMakefile::GetPropertyOrDefinition(const char* prop)
{
const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY);
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 3fa99513ee..989cd1536c 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -713,6 +713,7 @@ public:
///! Set/Get a property of this directory
void SetProperty(const char *prop, const char *value);
+ void AppendProperty(const char *prop, const char *value);
const char *GetProperty(const char *prop);
const char *GetPropertyOrDefinition(const char *prop);
const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
index dbfeae9aff..5e082dc998 100644
--- a/Source/cmProperty.cxx
+++ b/Source/cmProperty.cxx
@@ -24,6 +24,17 @@ void cmProperty::Set(const char *name, const char *value)
this->ValueHasBeenSet = true;
}
+void cmProperty::Append(const char *name, const char *value)
+{
+ this->Name = name;
+ if(!this->Value.empty() && *value)
+ {
+ this->Value += ";";
+ }
+ this->Value += value;
+ this->ValueHasBeenSet = true;
+}
+
const char *cmProperty::GetValue() const
{
if (this->ValueHasBeenSet)
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index fc8e2775b1..7d238b6efe 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -28,6 +28,9 @@ public:
// set this property
void Set(const char *name, const char *value);
+ // append to this property
+ void Append(const char *name, const char *value);
+
// get the value
const char *GetValue() const;
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index dcd3cb71af..db1f75b2cd 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -63,6 +63,32 @@ void cmPropertyMap::SetProperty(const char *name, const char *value,
prop->Set(name,value);
}
+void cmPropertyMap::AppendProperty(const char* name, const char* value,
+ cmProperty::ScopeType scope)
+{
+ // Skip if nothing to append.
+ if(!name || !value || !*value)
+ {
+ return;
+ }
+#ifdef CMAKE_STRICT
+ if (!this->CMakeInstance)
+ {
+ cmSystemTools::Error("CMakeInstance not set on a property map!");
+ abort();
+ }
+ else
+ {
+ this->CMakeInstance->RecordPropertyAccess(name,scope);
+ }
+#else
+ (void)scope;
+#endif
+
+ cmProperty *prop = this->GetOrCreateProperty(name);
+ prop->Append(name,value);
+}
+
const char *cmPropertyMap
::GetPropertyValue(const char *name,
cmProperty::ScopeType scope,
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index 11d35d689c..b058a820ed 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -29,6 +29,9 @@ public:
void SetProperty(const char *name, const char *value,
cmProperty::ScopeType scope);
+ void AppendProperty(const char* name, const char* value,
+ cmProperty::ScopeType scope);
+
const char *GetPropertyValue(const char *name,
cmProperty::ScopeType scope,
bool &chain) const;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 3b6a53af58..933a3e8cf6 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -129,37 +129,6 @@ bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
-bool cmSetPropertyCommand::ConstructValue(std::string& value,
- const char* old)
-{
- if(this->AppendMode)
- {
- // This is an append. Start with the original value.
- if(old)
- {
- value = old;
- }
- }
- else if(this->PropertyValue.empty())
- {
- // This is a set to no values. Remove the property.
- return false;
- }
-
- // Add the new value.
- if(!this->PropertyValue.empty())
- {
- if(!value.empty())
- {
- value += ";";
- }
- value += this->PropertyValue;
- }
-
- return true;
-}
-
-//----------------------------------------------------------------------------
bool cmSetPropertyCommand::HandleGlobalMode()
{
if(!this->Names.empty())
@@ -171,16 +140,13 @@ bool cmSetPropertyCommand::HandleGlobalMode()
// Set or append the property.
cmake* cm = this->Makefile->GetCMakeInstance();
const char* name = this->PropertyName.c_str();
- std::string value;
- if(this->ConstructValue(value, cm->GetProperty(name)))
+ if(this->AppendMode)
{
- // Set the new property.
- cm->SetProperty(name, value.c_str());
+ cm->AppendProperty(name, this->PropertyValue.c_str());
}
else
{
- // Remove the property.
- cm->SetProperty(name, 0);
+ cm->SetProperty(name, this->PropertyValue.c_str());
}
return true;
@@ -235,16 +201,13 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
// Set or append the property.
const char* name = this->PropertyName.c_str();
- std::string value;
- if(this->ConstructValue(value, mf->GetProperty(name)))
+ if(this->AppendMode)
{
- // Set the new property.
- mf->SetProperty(name, value.c_str());
+ mf->AppendProperty(name, this->PropertyValue.c_str());
}
else
{
- // Remove the property.
- mf->SetProperty(name, 0);
+ mf->SetProperty(name, this->PropertyValue.c_str());
}
return true;
@@ -283,16 +246,13 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
- std::string value;
- if(this->ConstructValue(value, target->GetProperty(name)))
+ if(this->AppendMode)
{
- // Set the new property.
- target->SetProperty(name, value.c_str());
+ target->AppendProperty(name, this->PropertyValue.c_str());
}
else
{
- // Remove the property.
- target->SetProperty(name, 0);
+ target->SetProperty(name, this->PropertyValue.c_str());
}
return true;
@@ -328,16 +288,13 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
- std::string value;
- if(this->ConstructValue(value, sf->GetProperty(name)))
+ if(this->AppendMode)
{
- // Set the new property.
- sf->SetProperty(name, value.c_str());
+ sf->AppendProperty(name, this->PropertyValue.c_str());
}
else
{
- // Remove the property.
- sf->SetProperty(name, 0);
+ sf->SetProperty(name, this->PropertyValue.c_str());
}
// TODO: MACOSX_PACKAGE_LOCATION special case in
@@ -392,16 +349,13 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test)
{
// Set or append the property.
const char* name = this->PropertyName.c_str();
- std::string value;
- if(this->ConstructValue(value, test->GetProperty(name)))
+ if(this->AppendMode)
{
- // Set the new property.
- test->SetProperty(name, value.c_str());
+ test->AppendProperty(name, this->PropertyValue.c_str());
}
else
{
- // Remove the property.
- test->SetProperty(name, 0);
+ test->SetProperty(name, this->PropertyValue.c_str());
}
return true;
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index c5de8e56fd..06d4da59bf 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -93,9 +93,6 @@ private:
std::string PropertyValue;
bool AppendMode;
- // Implementation of value construction.
- bool ConstructValue(std::string& value, const char* old);
-
// Implementation of each property type.
bool HandleGlobalMode();
bool HandleDirectoryMode();
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index f0dbd989fe..48f975df7a 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -271,6 +271,16 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
+void cmSourceFile::AppendProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+ this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE);
+}
+
+//----------------------------------------------------------------------------
const char* cmSourceFile::GetProperty(const char* prop) const
{
// Check for computed properties.
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 9ad6f3e2bc..423e44030e 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -49,6 +49,7 @@ public:
///! Set/Get a property of this source file
void SetProperty(const char *prop, const char *value);
+ void AppendProperty(const char* prop, const char* value);
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 981ba3fc0c..6f90024ecd 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1346,6 +1346,16 @@ void cmTarget::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
+void cmTarget::AppendProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+ this->Properties.AppendProperty(prop, value, cmProperty::TARGET);
+}
+
+//----------------------------------------------------------------------------
void cmTarget::MarkAsImported()
{
this->IsImportedTarget = true;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 8439ee18a6..d1b48e6682 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -187,6 +187,7 @@ public:
///! Set/Get a property of this target file
void SetProperty(const char *prop, const char *value);
+ void AppendProperty(const char* prop, const char* value);
const char *GetProperty(const char *prop);
const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
bool GetPropertyAsBool(const char *prop);
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 11c6a8c80e..0a59fe0359 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -85,6 +85,16 @@ void cmTest::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
+void cmTest::AppendProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+ this->Properties.AppendProperty(prop, value, cmProperty::TEST);
+}
+
+//----------------------------------------------------------------------------
void cmTest::SetMakefile(cmMakefile* mf)
{
// Set our makefile.
diff --git a/Source/cmTest.h b/Source/cmTest.h
index 9594a46eb7..d4945db88b 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -52,6 +52,7 @@ public:
///! Set/Get a property of this source file
void SetProperty(const char *prop, const char *value);
+ void AppendProperty(const char* prop, const char* value);
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
cmPropertyMap &GetProperties() { return this->Properties; };
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index c5466a6efd..e95a3bbe7d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3435,6 +3435,15 @@ void cmake::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);
}
+void cmake::AppendProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+ this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL);
+}
+
const char *cmake::GetProperty(const char* prop)
{
return this->GetProperty(prop, cmProperty::GLOBAL);
diff --git a/Source/cmake.h b/Source/cmake.h
index b43e77018f..80c9de8b11 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -258,6 +258,7 @@ class cmake
///! Set/Get a property of this target file
void SetProperty(const char *prop, const char *value);
+ void AppendProperty(const char *prop, const char *value);
const char *GetProperty(const char *prop);
const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
bool GetPropertyAsBool(const char *prop);