cmState.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2015 Stephen Kelly <[email protected]>
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmState_h
  11. #define cmState_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmPropertyDefinitionMap.h"
  14. #include "cmPropertyMap.h"
  15. #include "cmLinkedTree.h"
  16. class cmake;
  17. class cmCommand;
  18. class cmState
  19. {
  20. struct SnapshotDataType;
  21. typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
  22. friend class Snapshot;
  23. public:
  24. cmState(cmake* cm);
  25. ~cmState();
  26. enum SnapshotType
  27. {
  28. BuildsystemDirectoryType
  29. };
  30. class Snapshot {
  31. public:
  32. Snapshot(cmState* state = 0, PositionType position = PositionType());
  33. const char* GetCurrentSourceDirectory() const;
  34. void SetCurrentSourceDirectory(std::string const& dir);
  35. const char* GetCurrentBinaryDirectory() const;
  36. void SetCurrentBinaryDirectory(std::string const& dir);
  37. std::vector<std::string> const&
  38. GetCurrentSourceDirectoryComponents() const;
  39. std::vector<std::string> const&
  40. GetCurrentBinaryDirectoryComponents() const;
  41. const char* GetRelativePathTopSource() const;
  42. const char* GetRelativePathTopBinary() const;
  43. void SetRelativePathTopSource(const char* dir);
  44. void SetRelativePathTopBinary(const char* dir);
  45. bool IsValid() const;
  46. Snapshot GetBuildsystemDirectoryParent() const;
  47. cmState* GetState() const;
  48. private:
  49. void ComputeRelativePathTopSource();
  50. void ComputeRelativePathTopBinary();
  51. private:
  52. friend class cmState;
  53. cmState* State;
  54. cmState::PositionType Position;
  55. };
  56. Snapshot CreateBaseSnapshot();
  57. Snapshot CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot);
  58. enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,
  59. UNINITIALIZED };
  60. static CacheEntryType StringToCacheEntryType(const char*);
  61. static const char* CacheEntryTypeToString(CacheEntryType);
  62. static bool IsCacheEntryType(std::string const& key);
  63. std::vector<std::string> GetCacheEntryKeys() const;
  64. const char* GetCacheEntryValue(std::string const& key) const;
  65. const char* GetInitializedCacheValue(std::string const& key) const;
  66. CacheEntryType GetCacheEntryType(std::string const& key) const;
  67. void SetCacheEntryValue(std::string const& key, std::string const& value);
  68. void SetCacheValue(std::string const& key, std::string const& value);
  69. void AddCacheEntry(const std::string& key, const char* value,
  70. const char* helpString, CacheEntryType type);
  71. void RemoveCacheEntry(std::string const& key);
  72. void SetCacheEntryProperty(std::string const& key,
  73. std::string const& propertyName,
  74. std::string const& value);
  75. void SetCacheEntryBoolProperty(std::string const& key,
  76. std::string const& propertyName,
  77. bool value);
  78. const char* GetCacheEntryProperty(std::string const& key,
  79. std::string const& propertyName);
  80. bool GetCacheEntryPropertyAsBool(std::string const& key,
  81. std::string const& propertyName);
  82. void AppendCacheEntryProperty(std::string const& key,
  83. const std::string& property,
  84. const std::string& value,
  85. bool asString = false);
  86. void RemoveCacheEntryProperty(std::string const& key,
  87. std::string const& propertyName);
  88. Snapshot Reset();
  89. // Define a property
  90. void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
  91. const char *ShortDescription,
  92. const char *FullDescription,
  93. bool chain = false);
  94. // get property definition
  95. cmPropertyDefinition const* GetPropertyDefinition
  96. (const std::string& name, cmProperty::ScopeType scope) const;
  97. // Is a property defined?
  98. bool IsPropertyDefined(const std::string& name,
  99. cmProperty::ScopeType scope) const;
  100. bool IsPropertyChained(const std::string& name,
  101. cmProperty::ScopeType scope) const;
  102. void SetLanguageEnabled(std::string const& l);
  103. bool GetLanguageEnabled(std::string const& l) const;
  104. std::vector<std::string> GetEnabledLanguages() const;
  105. void SetEnabledLanguages(std::vector<std::string> const& langs);
  106. void ClearEnabledLanguages();
  107. bool GetIsInTryCompile() const;
  108. void SetIsInTryCompile(bool b);
  109. cmCommand* GetCommand(std::string const& name) const;
  110. void AddCommand(cmCommand* command);
  111. void RemoveUnscriptableCommands();
  112. void RenameCommand(std::string const& oldName, std::string const& newName);
  113. void RemoveUserDefinedCommands();
  114. std::vector<std::string> GetCommandNames() const;
  115. void SetGlobalProperty(const std::string& prop, const char *value);
  116. void AppendGlobalProperty(const std::string& prop,
  117. const char *value,bool asString=false);
  118. const char *GetGlobalProperty(const std::string& prop);
  119. bool GetGlobalPropertyAsBool(const std::string& prop);
  120. const char* GetSourceDirectory() const;
  121. void SetSourceDirectory(std::string const& sourceDirectory);
  122. const char* GetBinaryDirectory() const;
  123. void SetBinaryDirectory(std::string const& binaryDirectory);
  124. std::vector<std::string> const& GetSourceDirectoryComponents() const;
  125. std::vector<std::string> const& GetBinaryDirectoryComponents() const;
  126. void SetWindowsShell(bool windowsShell);
  127. bool UseWindowsShell() const;
  128. void SetWindowsVSIDE(bool windowsVSIDE);
  129. bool UseWindowsVSIDE() const;
  130. void SetWatcomWMake(bool watcomWMake);
  131. bool UseWatcomWMake() const;
  132. void SetMinGWMake(bool minGWMake);
  133. bool UseMinGWMake() const;
  134. void SetNMake(bool nMake);
  135. bool UseNMake() const;
  136. void SetMSYSShell(bool mSYSShell);
  137. bool UseMSYSShell() const;
  138. private:
  139. std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
  140. std::vector<std::string> EnabledLanguages;
  141. std::map<std::string, cmCommand*> Commands;
  142. cmPropertyMap GlobalProperties;
  143. cmake* CMakeInstance;
  144. struct BuildsystemDirectoryStateType;
  145. cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory;
  146. cmLinkedTree<SnapshotDataType> SnapshotData;
  147. std::vector<std::string> SourceDirectoryComponents;
  148. std::vector<std::string> BinaryDirectoryComponents;
  149. std::string SourceDirectory;
  150. std::string BinaryDirectory;
  151. bool IsInTryCompile;
  152. bool WindowsShell;
  153. bool WindowsVSIDE;
  154. bool WatcomWMake;
  155. bool MinGWMake;
  156. bool NMake;
  157. bool MSYSShell;
  158. };
  159. #endif