From 003654670b55a98eddd3c69de081eddb82383937 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Mon, 4 Jun 2007 13:48:11 -0400 Subject: [PATCH] ENH: -U for removing variables now uses globbing expressions -cmCacheManager: now also variables with type UNINITIALIZED are saved in CMakeCache.txt, these are the vars defined using -DFOO=foo but without type Alex --- Source/cmCacheManager.cxx | 2 +- Source/cmake.cxx | 14 ++++++++------ Source/cmake.h | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index d6794aafd..3967592c9 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -439,7 +439,7 @@ bool cmCacheManager::SaveCache(const char* path) { const CacheEntry& ce = (*i).second; CacheEntryType t = ce.Type; - if(t == cmCacheManager::UNINITIALIZED || !ce.Initialized) + if(!ce.Initialized) { /* // This should be added in, but is not for now. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index aae773ff4..90828373a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -33,8 +33,10 @@ # include #endif -# include +#include #include +#include +#include // only build kdevelop generator on non-windows platforms // when not bootstrapping cmake @@ -288,7 +290,7 @@ bool cmake::SetCacheArgs(const std::vector& args) } else { - cmSystemTools::Error("-D must be followed with VAR=VALUE."); + cmSystemTools::Error("-D must be followed with VAR=VALUE."); return false; } } @@ -298,8 +300,7 @@ bool cmake::SetCacheArgs(const std::vector& args) cmCacheManager::ParseEntry(entry.c_str(), var, value)) { this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), - "No help, variable specified on the command line.", - type==cmCacheManager::UNINITIALIZED?cmCacheManager::STRING:type); + "No help, variable specified on the command line.", type); } else { @@ -325,7 +326,8 @@ bool cmake::SetCacheArgs(const std::vector& args) return false; } } - + cmsys::RegularExpression regex( + cmsys::Glob::PatternToRegex(entryPattern.c_str(), true).c_str()); //go through all cache entries and collect the vars which will be removed std::vector entriesToDelete; cmCacheManager::CacheIterator it = @@ -336,7 +338,7 @@ bool cmake::SetCacheArgs(const std::vector& args) if(t != cmCacheManager::STATIC && t != cmCacheManager::UNINITIALIZED) { std::string entryName = it.GetName(); - if (entryName.find(entryPattern) != std::string::npos) + if (regex.find(entryName.c_str())) { entriesToDelete.push_back(entryName); } diff --git a/Source/cmake.h b/Source/cmake.h index c1485155f..3e7b5fa6a 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -388,11 +388,11 @@ private: "for the project. This option may be used to specify a setting " \ "that takes priority over the project's default value. The option " \ "may be repeated for as many cache entries as desired."}, \ - {"-U ", "Remove one or more cmake cache entries.", \ + {"-U ", "Remove matching entries from CMake cache.", \ "This option may be used to remove one or more variables from the " \ - "CMakeCache.txt file, so that CMake will search them again. All " \ - "variables which contain \"\" will be removed. The option may be "\ - "repeated for as many cache entries as desired."}, \ + "CMakeCache.txt file, globbing expressions using * and ? are supported. "\ + "The option may be repeated for as many cache entries as desired.\n" \ + "Use with care, you can make your CMakeCache.txt non-working."}, \ {"-G ", "Specify a makefile generator.", \ "CMake may support multiple native build systems on certain platforms. " \ "A makefile generator is responsible for generating a particular build " \