2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2015-04-04 19:20:12 +00:00
|
|
|
#ifndef cmState_h
|
|
|
|
#define cmState_h
|
|
|
|
|
2016-08-16 23:08:13 +00:00
|
|
|
#include <cmConfigure.h> // IWYU pragma: keep
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2016-11-05 20:40:14 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-08-16 23:08:13 +00:00
|
|
|
#include "cmDefinitions.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmLinkedTree.h"
|
2016-08-16 23:08:13 +00:00
|
|
|
#include "cmProperty.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmPropertyDefinitionMap.h"
|
|
|
|
#include "cmPropertyMap.h"
|
2016-11-05 20:40:14 +00:00
|
|
|
#include "cmStatePrivate.h"
|
2016-10-18 19:28:48 +00:00
|
|
|
#include "cmStateTypes.h"
|
2015-04-04 19:20:12 +00:00
|
|
|
|
2016-08-16 23:08:13 +00:00
|
|
|
class cmCacheManager;
|
2015-04-11 10:30:26 +00:00
|
|
|
class cmCommand;
|
2016-08-16 23:08:13 +00:00
|
|
|
class cmPropertyDefinition;
|
2016-10-18 19:28:47 +00:00
|
|
|
class cmStateSnapshot;
|
2016-10-18 19:28:47 +00:00
|
|
|
|
2015-04-04 19:20:12 +00:00
|
|
|
class cmState
|
|
|
|
{
|
2016-10-18 19:28:47 +00:00
|
|
|
friend class cmStateSnapshot;
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2015-04-04 19:20:12 +00:00
|
|
|
public:
|
2015-10-10 13:42:02 +00:00
|
|
|
cmState();
|
2015-04-11 10:30:26 +00:00
|
|
|
~cmState();
|
2015-04-04 19:20:12 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
static const char* GetTargetTypeName(cmStateEnums::TargetType targetType);
|
2015-10-07 22:26:50 +00:00
|
|
|
|
2016-10-18 19:28:47 +00:00
|
|
|
cmStateSnapshot CreateBaseSnapshot();
|
|
|
|
cmStateSnapshot CreateBuildsystemDirectorySnapshot(
|
|
|
|
cmStateSnapshot originSnapshot);
|
|
|
|
cmStateSnapshot CreateFunctionCallSnapshot(cmStateSnapshot originSnapshot,
|
|
|
|
std::string const& fileName);
|
|
|
|
cmStateSnapshot CreateMacroCallSnapshot(cmStateSnapshot originSnapshot,
|
|
|
|
std::string const& fileName);
|
|
|
|
cmStateSnapshot CreateIncludeFileSnapshot(cmStateSnapshot originSnapshot,
|
|
|
|
std::string const& fileName);
|
|
|
|
cmStateSnapshot CreateVariableScopeSnapshot(cmStateSnapshot originSnapshot);
|
|
|
|
cmStateSnapshot CreateInlineListFileSnapshot(cmStateSnapshot originSnapshot,
|
|
|
|
std::string const& fileName);
|
|
|
|
cmStateSnapshot CreatePolicyScopeSnapshot(cmStateSnapshot originSnapshot);
|
|
|
|
cmStateSnapshot Pop(cmStateSnapshot originSnapshot);
|
2015-04-11 16:38:16 +00:00
|
|
|
|
2016-10-18 19:28:47 +00:00
|
|
|
static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*);
|
|
|
|
static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType);
|
2015-04-04 19:20:12 +00:00
|
|
|
static bool IsCacheEntryType(std::string const& key);
|
|
|
|
|
2015-10-10 13:21:41 +00:00
|
|
|
bool LoadCache(const std::string& path, bool internal,
|
|
|
|
std::set<std::string>& excludes,
|
|
|
|
std::set<std::string>& includes);
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool SaveCache(const std::string& path);
|
2015-10-10 13:21:41 +00:00
|
|
|
|
|
|
|
bool DeleteCache(const std::string& path);
|
|
|
|
|
2015-04-04 19:20:12 +00:00
|
|
|
std::vector<std::string> GetCacheEntryKeys() const;
|
|
|
|
const char* GetCacheEntryValue(std::string const& key) const;
|
|
|
|
const char* GetInitializedCacheValue(std::string const& key) const;
|
2016-10-18 19:28:47 +00:00
|
|
|
cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const;
|
2015-04-04 19:20:12 +00:00
|
|
|
void SetCacheEntryValue(std::string const& key, std::string const& value);
|
|
|
|
void SetCacheValue(std::string const& key, std::string const& value);
|
|
|
|
|
|
|
|
void RemoveCacheEntry(std::string const& key);
|
|
|
|
|
|
|
|
void SetCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName,
|
|
|
|
std::string const& value);
|
|
|
|
void SetCacheEntryBoolProperty(std::string const& key,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string const& propertyName, bool value);
|
2016-06-10 08:10:07 +00:00
|
|
|
std::vector<std::string> GetCacheEntryPropertyList(std::string const& key);
|
2015-04-04 19:20:12 +00:00
|
|
|
const char* GetCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName);
|
|
|
|
bool GetCacheEntryPropertyAsBool(std::string const& key,
|
|
|
|
std::string const& propertyName);
|
|
|
|
void AppendCacheEntryProperty(std::string const& key,
|
|
|
|
const std::string& property,
|
|
|
|
const std::string& value,
|
|
|
|
bool asString = false);
|
|
|
|
void RemoveCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName);
|
|
|
|
|
2015-10-10 13:08:15 +00:00
|
|
|
///! Break up a line like VAR:type="value" into var, type and value
|
2016-05-16 14:34:04 +00:00
|
|
|
static bool ParseCacheEntry(const std::string& entry, std::string& var,
|
2016-10-18 19:28:47 +00:00
|
|
|
std::string& value,
|
|
|
|
cmStateEnums::CacheEntryType& type);
|
2015-10-10 13:08:15 +00:00
|
|
|
|
2016-10-18 19:28:47 +00:00
|
|
|
cmStateSnapshot Reset();
|
2015-04-04 21:33:26 +00:00
|
|
|
// Define a property
|
|
|
|
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* ShortDescription,
|
|
|
|
const char* FullDescription, bool chain = false);
|
2015-04-04 21:33:26 +00:00
|
|
|
|
|
|
|
// get property definition
|
2016-05-16 14:34:04 +00:00
|
|
|
cmPropertyDefinition const* GetPropertyDefinition(
|
|
|
|
const std::string& name, cmProperty::ScopeType scope) const;
|
2015-04-04 21:33:26 +00:00
|
|
|
|
|
|
|
// Is a property defined?
|
2015-06-06 07:46:38 +00:00
|
|
|
bool IsPropertyDefined(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope) const;
|
|
|
|
bool IsPropertyChained(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope) const;
|
2015-04-04 21:33:26 +00:00
|
|
|
|
2015-04-11 12:16:39 +00:00
|
|
|
void SetLanguageEnabled(std::string const& l);
|
|
|
|
bool GetLanguageEnabled(std::string const& l) const;
|
|
|
|
std::vector<std::string> GetEnabledLanguages() const;
|
2015-04-30 12:56:48 +00:00
|
|
|
void SetEnabledLanguages(std::vector<std::string> const& langs);
|
2015-04-11 12:16:39 +00:00
|
|
|
void ClearEnabledLanguages();
|
2015-04-04 21:33:26 +00:00
|
|
|
|
2015-04-11 10:16:54 +00:00
|
|
|
bool GetIsInTryCompile() const;
|
|
|
|
void SetIsInTryCompile(bool b);
|
|
|
|
|
2017-04-03 16:47:32 +00:00
|
|
|
bool GetIsGeneratorMultiConfig() const;
|
|
|
|
void SetIsGeneratorMultiConfig(bool b);
|
|
|
|
|
2015-04-11 10:30:26 +00:00
|
|
|
cmCommand* GetCommand(std::string const& name) const;
|
|
|
|
void AddCommand(cmCommand* command);
|
|
|
|
void RemoveUnscriptableCommands();
|
|
|
|
void RenameCommand(std::string const& oldName, std::string const& newName);
|
|
|
|
void RemoveUserDefinedCommands();
|
|
|
|
std::vector<std::string> GetCommandNames() const;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void SetGlobalProperty(const std::string& prop, const char* value);
|
|
|
|
void AppendGlobalProperty(const std::string& prop, const char* value,
|
|
|
|
bool asString = false);
|
|
|
|
const char* GetGlobalProperty(const std::string& prop);
|
2015-04-11 12:17:46 +00:00
|
|
|
bool GetGlobalPropertyAsBool(const std::string& prop);
|
|
|
|
|
2015-04-12 13:26:54 +00:00
|
|
|
const char* GetSourceDirectory() const;
|
|
|
|
void SetSourceDirectory(std::string const& sourceDirectory);
|
|
|
|
const char* GetBinaryDirectory() const;
|
|
|
|
void SetBinaryDirectory(std::string const& binaryDirectory);
|
|
|
|
|
2015-05-24 09:46:30 +00:00
|
|
|
void SetWindowsShell(bool windowsShell);
|
|
|
|
bool UseWindowsShell() const;
|
|
|
|
void SetWindowsVSIDE(bool windowsVSIDE);
|
|
|
|
bool UseWindowsVSIDE() const;
|
|
|
|
void SetWatcomWMake(bool watcomWMake);
|
|
|
|
bool UseWatcomWMake() const;
|
|
|
|
void SetMinGWMake(bool minGWMake);
|
|
|
|
bool UseMinGWMake() const;
|
|
|
|
void SetNMake(bool nMake);
|
|
|
|
bool UseNMake() const;
|
|
|
|
void SetMSYSShell(bool mSYSShell);
|
|
|
|
bool UseMSYSShell() const;
|
|
|
|
|
2015-10-10 12:34:26 +00:00
|
|
|
unsigned int GetCacheMajorVersion() const;
|
|
|
|
unsigned int GetCacheMinorVersion() const;
|
|
|
|
|
2015-04-04 19:20:12 +00:00
|
|
|
private:
|
2015-10-10 13:05:50 +00:00
|
|
|
friend class cmake;
|
|
|
|
void AddCacheEntry(const std::string& key, const char* value,
|
2016-10-18 19:28:47 +00:00
|
|
|
const char* helpString,
|
|
|
|
cmStateEnums::CacheEntryType type);
|
2015-10-10 13:05:50 +00:00
|
|
|
|
2015-04-04 21:33:26 +00:00
|
|
|
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
|
2015-04-11 12:16:39 +00:00
|
|
|
std::vector<std::string> EnabledLanguages;
|
2015-04-11 10:30:26 +00:00
|
|
|
std::map<std::string, cmCommand*> Commands;
|
2015-04-11 12:17:46 +00:00
|
|
|
cmPropertyMap GlobalProperties;
|
2015-10-10 13:42:02 +00:00
|
|
|
cmCacheManager* CacheManager;
|
2015-05-04 21:01:29 +00:00
|
|
|
|
2016-10-18 19:28:45 +00:00
|
|
|
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>
|
|
|
|
BuildsystemDirectory;
|
2015-05-23 08:37:07 +00:00
|
|
|
|
2015-05-31 17:37:08 +00:00
|
|
|
cmLinkedTree<std::string> ExecutionListFiles;
|
|
|
|
|
2016-10-18 19:28:45 +00:00
|
|
|
cmLinkedTree<cmStateDetail::PolicyStackEntry> PolicyStack;
|
2016-10-18 19:28:45 +00:00
|
|
|
cmLinkedTree<cmStateDetail::SnapshotDataType> SnapshotData;
|
2015-06-21 19:26:43 +00:00
|
|
|
cmLinkedTree<cmDefinitions> VarTree;
|
2015-05-04 21:08:19 +00:00
|
|
|
|
2015-04-12 13:26:54 +00:00
|
|
|
std::string SourceDirectory;
|
|
|
|
std::string BinaryDirectory;
|
2015-04-11 10:16:54 +00:00
|
|
|
bool IsInTryCompile;
|
2017-04-03 16:47:32 +00:00
|
|
|
bool IsGeneratorMultiConfig;
|
2015-05-24 09:46:30 +00:00
|
|
|
bool WindowsShell;
|
|
|
|
bool WindowsVSIDE;
|
|
|
|
bool WatcomWMake;
|
|
|
|
bool MinGWMake;
|
|
|
|
bool NMake;
|
|
|
|
bool MSYSShell;
|
2015-04-04 19:20:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|