[cmake-commits] king committed cmMakefile.cxx 1.423 1.424
cmMakefile.h 1.217 1.218 cmProperty.cxx 1.1 1.2 cmProperty.h
1.2 1.3 cmPropertyMap.cxx 1.10 1.11 cmPropertyMap.h 1.1 1.2
cmSetPropertyCommand.cxx 1.2 1.3 cmSetPropertyCommand.h 1.1 1.2
cmSourceFile.cxx 1.43 1.44 cmSourceFile.h 1.23 1.24
cmTarget.cxx 1.175 1.176 cmTarget.h 1.94 1.95 cmTest.cxx 1.8
1.9 cmTest.h 1.5 1.6 cmake.cxx 1.351 1.352 cmake.h 1.98 1.99
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 17 18:13:57 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv10668/Source
Modified Files:
cmMakefile.cxx cmMakefile.h cmProperty.cxx cmProperty.h
cmPropertyMap.cxx cmPropertyMap.h cmSetPropertyCommand.cxx
cmSetPropertyCommand.h cmSourceFile.cxx cmSourceFile.h
cmTarget.cxx cmTarget.h cmTest.cxx cmTest.h cmake.cxx cmake.h
Log Message:
ENH: Add AppendProperty methods for use by C++ code in CMake. Simplify implementation of SET_PROPERTY command by using them.
Index: cmTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTest.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmTest.h 7 Dec 2006 14:44:45 -0000 1.5
+++ cmTest.h 17 Jan 2008 23:13:55 -0000 1.6
@@ -52,6 +52,7 @@
///! 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; };
Index: cmTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTest.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmTest.cxx 10 Jan 2008 03:09:19 -0000 1.8
+++ cmTest.cxx 17 Jan 2008 23:13:55 -0000 1.9
@@ -85,6 +85,16 @@
}
//----------------------------------------------------------------------------
+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.
Index: cmProperty.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmProperty.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmProperty.cxx 1 Dec 2006 18:35:02 -0000 1.1
+++ cmProperty.cxx 17 Jan 2008 23:13:55 -0000 1.2
@@ -24,6 +24,17 @@
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)
Index: cmSetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertyCommand.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmSetPropertyCommand.cxx 17 Jan 2008 21:24:51 -0000 1.2
+++ cmSetPropertyCommand.cxx 17 Jan 2008 23:13:55 -0000 1.3
@@ -129,37 +129,6 @@
}
//----------------------------------------------------------------------------
-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 @@
// 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 @@
// 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 @@
{
// 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 @@
{
// 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 @@
{
// 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;
Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- cmake.h 1 Jan 2008 20:13:41 -0000 1.98
+++ cmake.h 17 Jan 2008 23:13:55 -0000 1.99
@@ -258,6 +258,7 @@
///! 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);
Index: cmPropertyMap.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPropertyMap.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmPropertyMap.h 1 Dec 2006 18:35:03 -0000 1.1
+++ cmPropertyMap.h 17 Jan 2008 23:13:55 -0000 1.2
@@ -29,6 +29,9 @@
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;
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.351
retrieving revision 1.352
diff -u -d -r1.351 -r1.352
--- cmake.cxx 15 Jan 2008 15:49:59 -0000 1.351
+++ cmake.cxx 17 Jan 2008 23:13:55 -0000 1.352
@@ -3435,6 +3435,15 @@
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);
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -d -r1.217 -r1.218
--- cmMakefile.h 3 Jan 2008 16:21:39 -0000 1.217
+++ cmMakefile.h 17 Jan 2008 23:13:55 -0000 1.218
@@ -713,6 +713,7 @@
///! 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);
Index: cmProperty.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmProperty.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmProperty.h 25 Jun 2007 14:34:21 -0000 1.2
+++ cmProperty.h 17 Jan 2008 23:13:55 -0000 1.3
@@ -28,6 +28,9 @@
// 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;
Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cmSourceFile.cxx 16 Jan 2008 02:02:00 -0000 1.43
+++ cmSourceFile.cxx 17 Jan 2008 23:13:55 -0000 1.44
@@ -271,6 +271,16 @@
}
//----------------------------------------------------------------------------
+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.
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- cmTarget.h 23 Dec 2007 20:03:42 -0000 1.94
+++ cmTarget.h 17 Jan 2008 23:13:55 -0000 1.95
@@ -187,6 +187,7 @@
///! 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);
Index: cmSourceFile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmSourceFile.h 17 Dec 2007 15:12:19 -0000 1.23
+++ cmSourceFile.h 17 Jan 2008 23:13:55 -0000 1.24
@@ -49,6 +49,7 @@
///! 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;
Index: cmPropertyMap.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPropertyMap.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmPropertyMap.cxx 6 Nov 2007 19:16:00 -0000 1.10
+++ cmPropertyMap.cxx 17 Jan 2008 23:13:55 -0000 1.11
@@ -63,6 +63,32 @@
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,
Index: cmSetPropertyCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertyCommand.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmSetPropertyCommand.h 17 Jan 2008 20:54:49 -0000 1.1
+++ cmSetPropertyCommand.h 17 Jan 2008 23:13:55 -0000 1.2
@@ -93,9 +93,6 @@
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();
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- cmTarget.cxx 16 Jan 2008 02:02:00 -0000 1.175
+++ cmTarget.cxx 17 Jan 2008 23:13:55 -0000 1.176
@@ -1346,6 +1346,16 @@
}
//----------------------------------------------------------------------------
+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;
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.423
retrieving revision 1.424
diff -u -d -r1.423 -r1.424
--- cmMakefile.cxx 10 Jan 2008 03:09:19 -0000 1.423
+++ cmMakefile.cxx 17 Jan 2008 23:13:55 -0000 1.424
@@ -2613,6 +2613,42 @@
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);
More information about the Cmake-commits
mailing list