1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmPropertyMap.h"
13 #include "cmSystemTools.h"
16 cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
18 cmPropertyMap::iterator it = this->find(name);
20 if (it == this->end())
22 prop = &(*this)[name];
31 void cmPropertyMap::SetProperty(const char *name, const char *value,
32 cmProperty::ScopeType scope)
44 if (!this->CMakeInstance)
46 cmSystemTools::Error("CMakeInstance not set on a property map!");
51 this->CMakeInstance->RecordPropertyAccess(name,scope);
57 cmProperty *prop = this->GetOrCreateProperty(name);
58 prop->Set(name,value);
61 void cmPropertyMap::AppendProperty(const char* name, const char* value,
62 cmProperty::ScopeType scope, bool asString)
64 // Skip if nothing to append.
65 if(!name || !value || !*value)
70 if (!this->CMakeInstance)
72 cmSystemTools::Error("CMakeInstance not set on a property map!");
77 this->CMakeInstance->RecordPropertyAccess(name,scope);
83 cmProperty *prop = this->GetOrCreateProperty(name);
84 prop->Append(name,value,asString);
87 const char *cmPropertyMap
88 ::GetPropertyValue(const char *name,
89 cmProperty::ScopeType scope,
98 // has the property been defined?
100 if (!this->CMakeInstance)
102 cmSystemTools::Error("CMakeInstance not set on a property map!");
107 this->CMakeInstance->RecordPropertyAccess(name,scope);
111 cmPropertyMap::const_iterator it = this->find(name);
112 if (it == this->end())
114 // should we chain up?
115 if (this->CMakeInstance)
117 chain = this->CMakeInstance->IsPropertyChained(name,scope);
121 return it->second.GetValue();