diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-20 22:51:03 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-20 22:51:03 (GMT) |
commit | f7fae15d39d6e290686487778485734227415088 (patch) | |
tree | 4d9b374c6b9cbee02781bf442ab078cfdd449f87 /Source/cmCacheManager.cxx | |
parent | f3d63c1932f5a9d2b159ccddf9acd09f8c5358c2 (diff) | |
download | CMake-f7fae15d39d6e290686487778485734227415088.zip CMake-f7fae15d39d6e290686487778485734227415088.tar.gz CMake-f7fae15d39d6e290686487778485734227415088.tar.bz2 |
ENH: add command line arguments to set cache entries
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r-- | Source/cmCacheManager.cxx | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index a45ae32..3d6ac98 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -114,6 +114,32 @@ bool cmCacheManager::LoadCache(const char* path, return this->LoadCache(path, internal, emptySet, emptySet); } +bool cmCacheManager::ParseEntry(const char* entry, + std::string& var, + std::string& value, + CacheEntryType& type) +{ + // input line is: key:type=value + cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); + // input line is: "key":type=value + cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + type = cmCacheManager::StringToType(regQuoted.match(2).c_str()); + value = regQuoted.match(3); + return true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + type = cmCacheManager::StringToType(reg.match(2).c_str()); + value = reg.match(3); + return true; + } + return false; +} + bool cmCacheManager::LoadCache(const char* path, bool internal, std::set<std::string>& excludes, @@ -167,12 +193,10 @@ bool cmCacheManager::LoadCache(const char* path, continue; } } - if(regQuoted.find(realbuffer)) + if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.m_Value, e.m_Type)) { - entryKey = regQuoted.match(1); if ( excludes.find(entryKey) == excludes.end() ) { - e.m_Type = cmCacheManager::StringToType(regQuoted.match(2).c_str()); // 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 @@ -192,43 +216,10 @@ bool cmCacheManager::LoadCache(const char* path, e.m_HelpString += path; e.m_HelpString += "/CMakeCache.txt" ; } - e.m_Value = regQuoted.match(3); m_Cache[entryKey] = e; } } } - else if (reg.find(realbuffer)) - { - entryKey = reg.match(1); - if ( excludes.find(entryKey) == excludes.end() ) - { - e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str()); - // only load internal values if internal is set - // 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 - // not visible in the gui - if (!internal) - { - e.m_Type = INTERNAL; - e.m_HelpString = "DO NOT EDIT, "; - e.m_HelpString += entryKey; - e.m_HelpString += " loaded from external file. " - "To change this value edit this file: "; - e.m_HelpString += path; - e.m_HelpString += "/CMakeCache.txt"; - } - e.m_Value = reg.match(3); - m_Cache[entryKey] = e; - } - } - } else { cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(), @@ -247,6 +238,8 @@ bool cmCacheManager::LoadCache(const char* path, "current loaded cache", cmCacheManager::INTERNAL); } + // check to make sure the cache directory has not + // been moved if ( internal && this->GetCacheValue("CMAKE_CACHEFILE_DIR") ) { std::string currentcwd = path; |