From 3b9f97f32d019520c372551ab4c6a321cb560094 Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Thu, 16 Aug 2001 11:41:44 -0400 Subject: Adding new options to LoadCache. --- Source/cmCacheManager.cxx | 20 +++++++++++++++----- Source/cmCacheManager.h | 3 ++- Source/cmLoadCacheCommand.cxx | 36 +++++++++++++++++++++++++++++++++--- Source/cmLoadCacheCommand.h | 8 ++++++-- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 7c01fe2..46e0ea2 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -111,12 +111,13 @@ bool cmCacheManager::LoadCache(const char* path, bool internal) { std::set emptySet; - return this->LoadCache(path, internal, emptySet); + return this->LoadCache(path, internal, emptySet, emptySet); } bool cmCacheManager::LoadCache(const char* path, bool internal, - std::set& excludes) + std::set& excludes, + std::set& includes) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -164,8 +165,12 @@ bool cmCacheManager::LoadCache(const char* path, if ( excludes.find(entryKey) == excludes.end() ) { e.m_Type = cmCacheManager::StringToType(regQuoted.match(2).c_str()); - // only load internal values if internal is set - if (internal || e.m_Type != INTERNAL) + // Load internal values if internal is set. + // If the entry is not internal to the cache being loaded + // or if it is in the list of internal entries to be + // imported, load it. + if ( internal || (e.m_Type != INTERNAL) || + (includes.find(entryKey) != includes.end()) ) { // If we are loading the cache from another project, // make all loaded entries internal so that it is @@ -186,7 +191,12 @@ bool cmCacheManager::LoadCache(const char* path, { e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str()); // only load internal values if internal is set - if (internal || e.m_Type != INTERNAL) + // Load internal values if internal is set. + // If the entry is not internal to the cache being loaded + // or if it is in the list of internal entries to be + // imported, load it. + if ( internal || (e.m_Type != INTERNAL) || + (includes.find(entryKey) != includes.end()) ) { // If we are loading the cache from another project, // make all loaded entries internal so that it is diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 206cec8..d1b6c21 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -79,7 +79,8 @@ public: bool LoadCache(const char* path); bool LoadCache(const char* path, bool internal); bool LoadCache(const char* path, bool internal, - std::set& excludes); + std::set& excludes, + std::set& includes); ///! Put cache definitions into makefile void DefineCache(cmMakefile*); diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 09e0480..93afbd6 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -24,8 +24,10 @@ bool cmLoadCacheCommand::InitialPass(std::vector& args) this->SetError("called with wrong number of arguments."); } + // Cache entries to be excluded from the import list. + // If this set is empty, all cache entries are brought in + // and they can not be overridden. bool excludeFiles=false; - unsigned int excludeIndex=0; unsigned int i; std::set excludes; @@ -40,16 +42,44 @@ bool cmLoadCacheCommand::InitialPass(std::vector& args) { excludeFiles=true; } + if (excludeFiles && (args[i] == "INCLUDE_INTERNALS")) + { + break; + } } + // Internal cache entries to be imported. + // If this set is empty, no internal cache entries are + // brought in. + bool includeFiles=false; + std::set includes; + for(i=0; iExpandVariablesInString(args[i]); + includes.insert(args[i]); + } + if (args[i] == "INCLUDE_INTERNALS") + { + includeFiles=true; + } + if (includeFiles && (args[i] == "EXCLUDE")) + { + break; + } + } + + for(i=0; iExpandVariablesInString(args[i]); - cmCacheManager::GetInstance()->LoadCache(args[i].c_str(),false,excludes); + cmCacheManager::GetInstance()->LoadCache(args[i].c_str(), false, + excludes, includes); cmCacheManager::GetInstance()->DefineCache(m_Makefile); } diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index a184f88..3a80af9 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -88,8 +88,12 @@ public: virtual const char* GetFullDocumentation() { return - "LOAD_CACHE(pathToCacheFile)\n" - "Load in the values from another cache. This is useful for a project that depends on another project built in a different tree."; + "LOAD_CACHE(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...])\n" + "Load in the values from another cache. This is useful for a project " + "that depends on another project built in a different tree." + "EXCLUDE option can be used to provide a list of entries to be included." + "INCLUDE_INTERNALS can be used to provide a list of internal entries" + "to be included. Normally, no internal entries are brougt in."; } cmTypeMacro(cmLoadCacheCommand, cmCommand); -- cgit v0.12