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.

127 lines
3.4 KiB

  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 "cmPropertyDefinitionMap.h"
  14. #include "cmSystemTools.h"
  15. #include "cmDocumentationSection.h"
  16. void cmPropertyDefinitionMap
  17. ::DefineProperty(const char *name, cmProperty::ScopeType scope,
  18. const char *ShortDescription,
  19. const char *FullDescription,
  20. const char *DocumentationSection,
  21. bool chain)
  22. {
  23. if (!name)
  24. {
  25. return;
  26. }
  27. cmPropertyDefinitionMap::iterator it = this->find(name);
  28. cmPropertyDefinition *prop;
  29. if (it == this->end())
  30. {
  31. prop = &(*this)[name];
  32. prop->DefineProperty(name,scope,ShortDescription, FullDescription,
  33. DocumentationSection, chain);
  34. }
  35. }
  36. void cmPropertyDefinitionMap
  37. ::GetPropertiesDocumentation(std::map<std::string,
  38. cmDocumentationSection *>& v) const
  39. {
  40. for(cmPropertyDefinitionMap::const_iterator j = this->begin();
  41. j != this->end(); ++j)
  42. {
  43. // add a section if needed
  44. std::string secName = j->second.GetDocumentationSection();
  45. // if a section was not specified then use the scope
  46. if (!secName.size())
  47. {
  48. switch (j->second.GetScope())
  49. {
  50. case cmProperty::GLOBAL:
  51. secName = "Properties of Global Scope";
  52. break;
  53. case cmProperty::TARGET:
  54. secName = "Properties on Targets";
  55. break;
  56. case cmProperty::SOURCE_FILE:
  57. secName = "Properties on Source Files";
  58. break;
  59. case cmProperty::DIRECTORY:
  60. secName = "Properties on Directories";
  61. break;
  62. case cmProperty::TEST:
  63. secName = "Properties on Tests";
  64. break;
  65. case cmProperty::VARIABLE:
  66. secName = "Variables";
  67. break;
  68. case cmProperty::CACHED_VARIABLE:
  69. secName = "Cached Variables";
  70. break;
  71. default:
  72. secName = "Properties of Unknown Scope";
  73. break;
  74. }
  75. }
  76. if (!v[secName])
  77. {
  78. v[secName] = new
  79. cmDocumentationSection(secName.c_str(),
  80. cmSystemTools::UpperCase(secName).c_str());
  81. }
  82. cmDocumentationEntry e = j->second.GetDocumentation();
  83. if (e.Brief.size() || e.Full.size())
  84. {
  85. v[secName]->Append(e);
  86. }
  87. }
  88. }
  89. bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
  90. {
  91. if (!name)
  92. {
  93. return false;
  94. }
  95. cmPropertyDefinitionMap::iterator it = this->find(name);
  96. if (it == this->end())
  97. {
  98. return false;
  99. }
  100. return true;
  101. }
  102. bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
  103. {
  104. if (!name)
  105. {
  106. return false;
  107. }
  108. cmPropertyDefinitionMap::iterator it = this->find(name);
  109. if (it == this->end())
  110. {
  111. return false;
  112. }
  113. return it->second.IsChained();
  114. }