From 9b5f80a83c07b4c840b190f4f9057f2cf0fa03d4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 11 Apr 2015 14:17:46 +0200 Subject: [PATCH] Move global properties to cmState. --- Source/cmState.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmState.h | 8 +++++++ Source/cmake.cxx | 42 +++------------------------------ Source/cmake.h | 2 -- 4 files changed, 70 insertions(+), 41 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 17b6cf20b..e46846e23 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -191,6 +191,8 @@ void cmState::RemoveCacheEntryProperty(std::string const& key, void cmState::Initialize() { + this->GlobalProperties.clear(); + this->PropertyDefinitions.clear(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -384,3 +386,60 @@ void cmState::RemoveUserDefinedCommands() } } } + +void cmState::SetGlobalProperty(const std::string& prop, const char* value) +{ + this->GlobalProperties.SetProperty(prop, value, cmProperty::GLOBAL); +} + +void cmState::AppendGlobalProperty(const std::string& prop, + const char* value, bool asString) +{ + this->GlobalProperties.AppendProperty(prop, value, + cmProperty::GLOBAL, asString); +} + +const char *cmState::GetGlobalProperty(const std::string& prop) +{ + // watch for special properties + std::string output = ""; + if ( prop == "CACHE_VARIABLES" ) + { + std::vector cacheKeys = this->GetCacheEntryKeys(); + this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str()); + } + else if ( prop == "COMMANDS" ) + { + std::vector commands = this->GetCommandNames(); + this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str()); + } + else if ( prop == "IN_TRY_COMPILE" ) + { + this->SetGlobalProperty("IN_TRY_COMPILE", + this->IsInTryCompile ? "1" : "0"); + } + else if ( prop == "ENABLED_LANGUAGES" ) + { + std::string langs; + langs = cmJoin(this->EnabledLanguages, ";"); + this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str()); + } +#define STRING_LIST_ELEMENT(F) ";" #F + if (prop == "CMAKE_C_KNOWN_FEATURES") + { + return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; + } + if (prop == "CMAKE_CXX_KNOWN_FEATURES") + { + return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; + } +#undef STRING_LIST_ELEMENT + bool dummy = false; + return this->GlobalProperties.GetPropertyValue(prop, cmProperty::GLOBAL, + dummy); +} + +bool cmState::GetGlobalPropertyAsBool(const std::string& prop) +{ + return cmSystemTools::IsOn(this->GetGlobalProperty(prop)); +} diff --git a/Source/cmState.h b/Source/cmState.h index a7a17eef3..34b2ccf06 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -14,6 +14,7 @@ #include "cmStandardIncludes.h" #include "cmPropertyDefinitionMap.h" +#include "cmPropertyMap.h" class cmake; class cmCommand; @@ -88,10 +89,17 @@ public: void RemoveUserDefinedCommands(); std::vector GetCommandNames() const; + 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); + bool GetGlobalPropertyAsBool(const std::string& prop); + private: std::map PropertyDefinitions; std::vector EnabledLanguages; std::map Commands; + cmPropertyMap GlobalProperties; cmake* CMakeInstance; bool IsInTryCompile; }; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a83596d27..7d02505c4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -188,8 +188,6 @@ cmake::~cmake() void cmake::InitializeProperties() { - this->Properties.clear(); - this->State->Initialize(); } @@ -2187,52 +2185,18 @@ void cmake::GenerateGraphViz(const char* fileName) const void cmake::SetProperty(const std::string& prop, const char* value) { - this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); + this->State->SetGlobalProperty(prop, value); } void cmake::AppendProperty(const std::string& prop, const char* value, bool asString) { - this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); + this->State->AppendGlobalProperty(prop, value, asString); } const char *cmake::GetProperty(const std::string& prop) { - // watch for special properties - std::string output = ""; - if ( prop == "CACHE_VARIABLES" ) - { - std::vector cacheKeys = this->State->GetCacheEntryKeys(); - this->SetProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str()); - } - else if ( prop == "COMMANDS" ) - { - std::vector commands = this->State->GetCommandNames(); - this->SetProperty("COMMANDS", cmJoin(commands, ";").c_str()); - } - else if ( prop == "IN_TRY_COMPILE" ) - { - this->SetProperty("IN_TRY_COMPILE", - this->State->GetIsInTryCompile() ? "1" : "0"); - } - else if ( prop == "ENABLED_LANGUAGES" ) - { - std::string langs; - langs = cmJoin(this->State->GetEnabledLanguages(), ";"); - this->SetProperty("ENABLED_LANGUAGES", langs.c_str()); - } -#define STRING_LIST_ELEMENT(F) ";" #F - if (prop == "CMAKE_C_KNOWN_FEATURES") - { - return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; - } - if (prop == "CMAKE_CXX_KNOWN_FEATURES") - { - return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; - } -#undef STRING_LIST_ELEMENT - bool dummy = false; - return this->Properties.GetPropertyValue(prop, cmProperty::GLOBAL, dummy); + return this->State->GetGlobalProperty(prop); } bool cmake::GetPropertyAsBool(const std::string& prop) diff --git a/Source/cmake.h b/Source/cmake.h index 27f28ac6d..352850dfd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -15,7 +15,6 @@ #include "cmListFileCache.h" #include "cmSystemTools.h" -#include "cmPropertyMap.h" #include "cmInstalledFile.h" #include "cmCacheManager.h" #include "cmState.h" @@ -336,7 +335,6 @@ protected: void RunCheckForUnusedVariables(); void InitializeProperties(); int HandleDeleteCacheVariables(const std::string& var); - cmPropertyMap Properties; typedef cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();