diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index c8374db3f..ab0bb79b5 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -849,7 +849,8 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop, //---------------------------------------------------------------------------- void cmCacheManager::CacheEntry::AppendProperty(const char* prop, - const char* value) + const char* value, + bool asString) { if(strcmp(prop, "TYPE") == 0) { @@ -859,7 +860,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, { if(value) { - if(!this->Value.empty() && *value) + if(!this->Value.empty() && *value && !asString) { this->Value += ";"; } @@ -868,7 +869,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, } else { - this->Properties.AppendProperty(prop, value, cmProperty::CACHE); + this->Properties.AppendProperty(prop, value, cmProperty::CACHE, asString); } } @@ -893,11 +894,12 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) //---------------------------------------------------------------------------- void cmCacheManager::CacheIterator::AppendProperty(const char* p, - const char* v) + const char* v, + bool asString) { if(!this->IsAtEnd()) { - this->GetEntry().AppendProperty(p, v); + this->GetEntry().AppendProperty(p, v, asString); } } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 314017bf5..9c94d214c 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -41,7 +41,8 @@ private: cmPropertyMap Properties; const char* GetProperty(const char*) const; void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value); + void AppendProperty(const char* property, const char* value, + bool asString=false); bool Initialized; CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false) {} @@ -61,7 +62,8 @@ public: bool GetPropertyAsBool(const char*) const ; bool PropertyExists(const char*) const; void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value); + void AppendProperty(const char* property, const char* value, + bool asString=false); void SetProperty(const char* property, bool value); const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 63bf03bdd..e2151158b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3332,7 +3332,8 @@ 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) +void cmMakefile::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { @@ -3365,7 +3366,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value) return; } - this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY); + this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } const char *cmMakefile::GetPropertyOrDefinition(const char* prop) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c1aef3c0..c01bb5d8a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -799,7 +799,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); + void AppendProperty(const char *prop, const char *value,bool asString=false); 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 166bd007e..3b37cf3b8 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -19,10 +19,10 @@ void cmProperty::Set(const char *name, const char *value) this->ValueHasBeenSet = true; } -void cmProperty::Append(const char *name, const char *value) +void cmProperty::Append(const char *name, const char *value, bool asString) { this->Name = name; - if(!this->Value.empty() && *value) + if(!this->Value.empty() && *value && !asString) { this->Value += ";"; } diff --git a/Source/cmProperty.h b/Source/cmProperty.h index 71bd1e768..e0fcd631e 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -24,7 +24,7 @@ public: void Set(const char *name, const char *value); // append to this property - void Append(const char *name, const char *value); + void Append(const char *name, const char *value, bool asString = false); // get the value const char *GetValue() const; diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 052b811f9..a4d0bf3d8 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -59,7 +59,7 @@ void cmPropertyMap::SetProperty(const char *name, const char *value, } void cmPropertyMap::AppendProperty(const char* name, const char* value, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope, bool asString) { // Skip if nothing to append. if(!name || !value || !*value) @@ -81,7 +81,7 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value, #endif cmProperty *prop = this->GetOrCreateProperty(name); - prop->Append(name,value); + prop->Append(name,value,asString); } const char *cmPropertyMap diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 02fb0606a..94275e2ac 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -25,7 +25,7 @@ public: cmProperty::ScopeType scope); void AppendProperty(const char* name, const char* value, - cmProperty::ScopeType scope); + cmProperty::ScopeType scope, bool asString=false); const char *GetPropertyValue(const char *name, cmProperty::ScopeType scope, diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 3a4773ce5..cc10840fd 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -20,6 +20,7 @@ cmSetPropertyCommand::cmSetPropertyCommand() { this->AppendMode = false; + this->AppendAsString = false; this->Remove = true; } @@ -83,6 +84,13 @@ bool cmSetPropertyCommand { doing = DoingNone; this->AppendMode = true; + this->AppendAsString = false; + } + else if(*arg == "APPEND_STRING") + { + doing = DoingNone; + this->AppendMode = true; + this->AppendAsString = true; } else if(doing == DoingNames) { @@ -152,7 +160,7 @@ bool cmSetPropertyCommand::HandleGlobalMode() } if(this->AppendMode) { - cm->AppendProperty(name, value); + cm->AppendProperty(name, value, this->AppendAsString); } else { @@ -218,7 +226,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() } if(this->AppendMode) { - mf->AppendProperty(name, value); + mf->AppendProperty(name, value, this->AppendAsString); } else { @@ -266,7 +274,7 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) } if(this->AppendMode) { - target->AppendProperty(name, value); + target->AppendProperty(name, value, this->AppendAsString); } else { @@ -317,7 +325,7 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) if(this->AppendMode) { - sf->AppendProperty(name, value); + sf->AppendProperty(name, value, this->AppendAsString); } else { @@ -377,7 +385,7 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test) } if(this->AppendMode) { - test->AppendProperty(name, value); + test->AppendProperty(name, value, this->AppendAsString); } else { @@ -464,7 +472,7 @@ bool cmSetPropertyCommand::HandleCacheEntry(cmCacheManager::CacheIterator& it) } if(this->AppendMode) { - it.AppendProperty(name, value); + it.AppendProperty(name, value, this->AppendAsString); } else { diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index c477bb73b..3a0169ed6 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -56,7 +56,7 @@ public: " SOURCE [src1 [src2 ...]] |\n" " TEST [test1 [test2 ...]] |\n" " CACHE [entry1 [entry2 ...]]>\n" - " [APPEND]\n" + " [APPEND] [APPEND_STRING]\n" " PROPERTY [value1 [value2 ...]])\n" "Set one property on zero or more objects of a scope. " "The first argument determines the scope in which the property " @@ -77,6 +77,9 @@ public: "list. " "If the APPEND option is given the list is appended to any " "existing property value." + "If the APPEND_STRING option is given the string is append to any " + "existing property value as string, i.e. it results in a longer " + "string and not a list of strings." ; } @@ -93,6 +96,7 @@ private: std::string PropertyValue; bool Remove; bool AppendMode; + bool AppendAsString; // Implementation of each property type. bool HandleGlobalMode(); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 42d3f06ff..dfa2c0b3f 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -291,13 +291,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmSourceFile::AppendProperty(const char* prop, const char* value) +void cmSourceFile::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE); + this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE, + asString); } //---------------------------------------------------------------------------- diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 2dc848815..55147e192 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -44,7 +44,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); + void AppendProperty(const char* prop, const char* value,bool asString=false); const char *GetProperty(const char *prop) const; bool GetPropertyAsBool(const char *prop) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 52b907217..191de3851 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2191,13 +2191,14 @@ void cmTarget::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTarget::AppendProperty(const char* prop, const char* value) +void cmTarget::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::TARGET); + this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); this->MaybeInvalidatePropertyCache(prop); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3b1f016a6..6f5dac813 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -224,7 +224,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); + void AppendProperty(const char* prop, const char* value,bool asString=false); 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 c25a8b6bf..502c1740d 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -84,13 +84,13 @@ void cmTest::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTest::AppendProperty(const char* prop, const char* value) +void cmTest::AppendProperty(const char* prop, const char* value, bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::TEST); + this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); } //---------------------------------------------------------------------------- diff --git a/Source/cmTest.h b/Source/cmTest.h index e27a24eaf..6223a01ea 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -47,7 +47,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); + void AppendProperty(const char* prop, const char* value,bool asString=false); 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 45927cb04..e5cc1a699 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3536,7 +3536,7 @@ 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) +void cmake::AppendProperty(const char* prop, const char* value, bool asString) { if (!prop) { @@ -3549,7 +3549,7 @@ void cmake::AppendProperty(const char* prop, const char* value) this->DebugConfigs.clear(); } - this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL); + this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); } const char *cmake::GetProperty(const char* prop) diff --git a/Source/cmake.h b/Source/cmake.h index fac86c18e..b791b7c28 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -263,7 +263,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); + void AppendProperty(const char *prop, const char *value,bool asString=false); const char *GetProperty(const char *prop); const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index e0c752297..c1bc3b9e3 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -71,6 +71,24 @@ if (NOT TARGETRESULT) "Error: target result is TARGETRESULT=${TARGETRESULT}") endif (NOT TARGETRESULT) +# test APPEND and APPEND_STRING set_property() +set_property(TARGET Properties PROPERTY FOO foo) +set_property(TARGET Properties PROPERTY BAR bar) +set_property(TARGET Properties APPEND PROPERTY FOO 123) +set_property(TARGET Properties APPEND_STRING PROPERTY BAR 456) + +get_property(APPEND_RESULT TARGET Properties PROPERTY FOO) +if (NOT "${APPEND_RESULT}" STREQUAL "foo;123") + message(SEND_ERROR + "Error: target result is APPEND_RESULT=${APPEND_RESULT}") +endif () + +get_property(APPEND_STRING_RESULT TARGET Properties PROPERTY BAR) +if (NOT "${APPEND_STRING_RESULT}" STREQUAL "bar456") + message(SEND_ERROR + "Error: target result is APPEND_STRING_RESULT=${APPEND_STRING_RESULT}") +endif () + # test get_property SET get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET) if (NOT TARGETRESULT)