You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.3 KiB

19 years ago
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmPropertyMap.h"
  14. #include "cmSystemTools.h"
  15. #include "cmake.h"
  16. cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
  17. {
  18. cmPropertyMap::iterator it = this->find(name);
  19. cmProperty *prop;
  20. if (it == this->end())
  21. {
  22. prop = &(*this)[name];
  23. }
  24. else
  25. {
  26. prop = &(it->second);
  27. }
  28. return prop;
  29. }
  30. void cmPropertyMap::SetProperty(const char *name, const char *value,
  31. cmProperty::ScopeType scope)
  32. {
  33. if (!name)
  34. {
  35. return;
  36. }
  37. if(!value)
  38. {
  39. this->erase(name);
  40. return;
  41. }
  42. #ifdef CMAKE_STRICT
  43. if (!this->CMakeInstance)
  44. {
  45. cmSystemTools::Error("CMakeInstance not set on a property map!");
  46. abort();
  47. }
  48. else
  49. {
  50. this->CMakeInstance->RecordPropertyAccess(name,scope);
  51. }
  52. #else
  53. (void)scope;
  54. #endif
  55. cmProperty *prop = this->GetOrCreateProperty(name);
  56. prop->Set(name,value);
  57. }
  58. const char *cmPropertyMap
  59. ::GetPropertyValue(const char *name,
  60. cmProperty::ScopeType scope,
  61. bool &chain) const
  62. {
  63. chain = false;
  64. if (!name)
  65. {
  66. return 0;
  67. }
  68. // has the property been defined?
  69. #ifdef CMAKE_STRICT
  70. if (!this->CMakeInstance)
  71. {
  72. cmSystemTools::Error("CMakeInstance not set on a property map!");
  73. abort();
  74. }
  75. else
  76. {
  77. this->CMakeInstance->RecordPropertyAccess(name,scope);
  78. }
  79. #endif
  80. cmPropertyMap::const_iterator it = this->find(name);
  81. if (it == this->end())
  82. {
  83. // should we chain up?
  84. if (this->CMakeInstance)
  85. {
  86. chain = this->CMakeInstance->IsPropertyChained(name,scope);
  87. }
  88. return 0;
  89. }
  90. return it->second.GetValue();
  91. }