2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-12-01 21:35:21 +03:00
|
|
|
#include "cmPropertyMap.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
|
|
|
cmPropertyMap::iterator it = this->find(name);
|
|
|
|
cmProperty *prop;
|
|
|
|
if (it == this->end())
|
|
|
|
{
|
|
|
|
prop = &(*this)[name];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prop = &(it->second);
|
|
|
|
}
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
void cmPropertyMap::SetProperty(const std::string& name, const char *value,
|
2006-12-01 21:35:21 +03:00
|
|
|
cmProperty::ScopeType scope)
|
|
|
|
{
|
2007-03-13 21:23:08 +03:00
|
|
|
if(!value)
|
|
|
|
{
|
|
|
|
this->erase(name);
|
|
|
|
return;
|
|
|
|
}
|
2006-12-07 18:33:35 +03:00
|
|
|
(void)scope;
|
2006-12-01 21:35:21 +03:00
|
|
|
|
|
|
|
cmProperty *prop = this->GetOrCreateProperty(name);
|
|
|
|
prop->Set(name,value);
|
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
|
2011-07-14 01:14:41 +04:00
|
|
|
cmProperty::ScopeType scope, bool asString)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
|
|
|
// Skip if nothing to append.
|
2013-09-03 00:27:32 +04:00
|
|
|
if(!value || !*value)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
(void)scope;
|
|
|
|
|
|
|
|
cmProperty *prop = this->GetOrCreateProperty(name);
|
2011-07-14 01:14:41 +04:00
|
|
|
prop->Append(name,value,asString);
|
2008-01-18 02:13:55 +03:00
|
|
|
}
|
|
|
|
|
2006-12-01 21:35:21 +03:00
|
|
|
const char *cmPropertyMap
|
2013-09-03 00:27:32 +04:00
|
|
|
::GetPropertyValue(const std::string& name,
|
2012-08-13 21:42:58 +04:00
|
|
|
cmProperty::ScopeType scope,
|
2006-12-01 21:35:21 +03:00
|
|
|
bool &chain) const
|
2012-08-13 21:42:58 +04:00
|
|
|
{
|
2006-12-01 21:35:21 +03:00
|
|
|
chain = false;
|
2013-09-03 00:27:32 +04:00
|
|
|
if (name.empty())
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmPropertyMap::const_iterator it = this->find(name);
|
|
|
|
if (it == this->end())
|
|
|
|
{
|
|
|
|
// should we chain up?
|
2006-12-07 17:45:32 +03:00
|
|
|
if (this->CMakeInstance)
|
|
|
|
{
|
|
|
|
chain = this->CMakeInstance->IsPropertyChained(name,scope);
|
|
|
|
}
|
2006-12-01 21:35:21 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return it->second.GetValue();
|
|
|
|
}
|
|
|
|
|