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
This commit is contained in:
Alexander Neundorf 2007-06-04 13:48:11 -04:00
parent 8fdca686b3
commit 003654670b
3 changed files with 13 additions and 11 deletions

View File

@ -439,7 +439,7 @@ bool cmCacheManager::SaveCache(const char* path)
{ {
const CacheEntry& ce = (*i).second; const CacheEntry& ce = (*i).second;
CacheEntryType t = ce.Type; CacheEntryType t = ce.Type;
if(t == cmCacheManager::UNINITIALIZED || !ce.Initialized) if(!ce.Initialized)
{ {
/* /*
// This should be added in, but is not for now. // This should be added in, but is not for now.

View File

@ -33,8 +33,10 @@
# include <cmsys/Terminal.h> # include <cmsys/Terminal.h>
#endif #endif
# include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/Glob.hxx>
#include <cmsys/RegularExpression.hxx>
// only build kdevelop generator on non-windows platforms // only build kdevelop generator on non-windows platforms
// when not bootstrapping cmake // when not bootstrapping cmake
@ -288,7 +290,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
} }
else else
{ {
cmSystemTools::Error("-D must be followed with VAR=VALUE."); cmSystemTools::Error("-D must be followed with VAR=VALUE.");
return false; return false;
} }
} }
@ -298,8 +300,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
cmCacheManager::ParseEntry(entry.c_str(), var, value)) cmCacheManager::ParseEntry(entry.c_str(), var, value))
{ {
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
"No help, variable specified on the command line.", "No help, variable specified on the command line.", type);
type==cmCacheManager::UNINITIALIZED?cmCacheManager::STRING:type);
} }
else else
{ {
@ -325,7 +326,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false; 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 //go through all cache entries and collect the vars which will be removed
std::vector<std::string> entriesToDelete; std::vector<std::string> entriesToDelete;
cmCacheManager::CacheIterator it = cmCacheManager::CacheIterator it =
@ -336,7 +338,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
if(t != cmCacheManager::STATIC && t != cmCacheManager::UNINITIALIZED) if(t != cmCacheManager::STATIC && t != cmCacheManager::UNINITIALIZED)
{ {
std::string entryName = it.GetName(); std::string entryName = it.GetName();
if (entryName.find(entryPattern) != std::string::npos) if (regex.find(entryName.c_str()))
{ {
entriesToDelete.push_back(entryName); entriesToDelete.push_back(entryName);
} }

View File

@ -388,11 +388,11 @@ private:
"for the project. This option may be used to specify a setting " \ "for the project. This option may be used to specify a setting " \
"that takes priority over the project's default value. The option " \ "that takes priority over the project's default value. The option " \
"may be repeated for as many cache entries as desired."}, \ "may be repeated for as many cache entries as desired."}, \
{"-U <var>", "Remove one or more cmake cache entries.", \ {"-U <globbing_expr>", "Remove matching entries from CMake cache.", \
"This option may be used to remove one or more variables from the " \ "This option may be used to remove one or more variables from the " \
"CMakeCache.txt file, so that CMake will search them again. All " \ "CMakeCache.txt file, globbing expressions using * and ? are supported. "\
"variables which contain \"<var>\" will be removed. The option may be "\ "The option may be repeated for as many cache entries as desired.\n" \
"repeated for as many cache entries as desired."}, \ "Use with care, you can make your CMakeCache.txt non-working."}, \
{"-G <generator-name>", "Specify a makefile generator.", \ {"-G <generator-name>", "Specify a makefile generator.", \
"CMake may support multiple native build systems on certain platforms. " \ "CMake may support multiple native build systems on certain platforms. " \
"A makefile generator is responsible for generating a particular build " \ "A makefile generator is responsible for generating a particular build " \