From 435a2f3ccb51acf119cfa1671f1c5b344a7d47a0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 10 Oct 2015 14:26:56 +0200 Subject: [PATCH] cmCacheManager: Port away from cmake instance. --- Source/cmCacheManager.cxx | 4 +--- Source/cmCacheManager.h | 3 +-- Source/cmState.cxx | 1 + Source/cmake.cxx | 24 +++++++++++++++++++++--- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 9dac27b1c..bfa60b387 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -21,11 +21,10 @@ #include #include -cmCacheManager::cmCacheManager(cmake* cm) +cmCacheManager::cmCacheManager() { this->CacheMajorVersion = 0; this->CacheMinorVersion = 0; - this->CMakeInstance = cm; } static bool ParseEntryWithoutType(const std::string& entry, @@ -671,7 +670,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key, } e.SetProperty("HELPSTRING", helpString? helpString : "(This variable does not exist and should not be used)"); - this->CMakeInstance->UnwatchUnusedCli(key); } bool cmCacheManager::CacheIterator::IsAtEnd() const diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 76533b52d..24400663a 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -17,7 +17,6 @@ #include "cmState.h" class cmMarkAsAdvancedCommand; -class cmake; /** \class cmCacheManager * \brief Control class for cmake's cache @@ -28,7 +27,7 @@ class cmake; class cmCacheManager { public: - cmCacheManager(cmake* cm); + cmCacheManager(); class CacheIterator; friend class cmCacheManager::CacheIterator; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 962826500..a42d075c3 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -252,6 +252,7 @@ void cmState::AddCacheEntry(const std::string& key, const char* value, { this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value, helpString, type); + this->CMakeInstance->UnwatchUnusedCli(key); } void cmState::RemoveCacheEntry(std::string const& key) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4fc48d542..69a3f0319 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -151,7 +151,7 @@ cmake::cmake() #endif this->Verbose = false; - this->CacheManager = new cmCacheManager(this); + this->CacheManager = new cmCacheManager; this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; @@ -1760,12 +1760,30 @@ bool cmake::LoadCache(const std::string& path, bool internal, std::set& excludes, std::set& includes) { - return this->State->LoadCache(path, internal, excludes, includes); + bool result = this->State->LoadCache(path, internal, excludes, includes); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::SaveCache(const std::string& path) { - return this->State->SaveCache(path); + bool result = this->State->SaveCache(path); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION", + "CMAKE_CACHE_PATCH_VERSION", + "CMAKE_CACHEFILE_DIR"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::DeleteCache(const std::string& path)