added FORCE option

This commit is contained in:
Ken Martin 2002-10-09 15:48:59 -04:00
parent cb5763a410
commit f990777a60
2 changed files with 15 additions and 8 deletions

View File

@ -39,6 +39,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args)
const char* variable = args[0].c_str(); // VAR is always first
std::string value; // optional
bool cache = false; // optional
bool force = false; // optional
cmCacheManager::CacheEntryType type = cmCacheManager::STRING; // required if cache
const char* docstring = 0; // required if cache
std::string::size_type cacheStart = 0;
@ -60,19 +61,24 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args)
}
}
// look for FORCE argument
if (args.size() > 4 && args[args.size()-1] == "FORCE")
{
force = true;
}
if(args.size() == 2)
{
// SET (VAR value )
value= args[1];
// SET (VAR value )
value= args[1];
}
else if(args.size() == 4)
else if(args.size() == 4 + (force ? 1 : 0))
{
// SET (VAR CACHE TYPE "doc String")
cache = true;
cacheStart = 1;
}
else if(args.size() == 5)
else if(args.size() == 5 + (force ? 1 : 0))
{
// SET (VAR value CACHE TYPE "doc string")
cache = true;
@ -116,7 +122,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args)
// is already in the cache and the type is not internal
// then leave now without setting any definitions in the cache
// or the makefile
if(cache && type != cmCacheManager::INTERNAL)
if(cache && type != cmCacheManager::INTERNAL && !force)
{
return true;
}

View File

@ -67,14 +67,15 @@ public:
virtual const char* GetFullDocumentation()
{
return
"SET(VAR [VALUE] [CACHE TYPE DOCSTRING])\n"
"SET(VAR [VALUE] [CACHE TYPE DOCSTRING [FORCE]])\n"
"Within CMAKE sets VAR to the value VALUE. VALUE is expanded before VAR "
"is set to it. If CACHE is present, then the VAR is put in the cache."
" TYPE and DOCSTRING are required. TYPE may be BOOL, PATH, FILEPATH, STRING, INTERNAL, "
"or STATIC. If TYPE is INTERNAL, then the "
" VALUE is Always written into the cache, replacing any values "
"existing in the cache. If it is not a CACHE VAR, then this always "
"writes into the current makefile.\n"
"writes into the current makefile. The FORCE option will overwrite"
"the CACHE value removing any changes from the USER.\n"
"An optional syntax is SET(VAR VALUE1 ... VALUEN).\n"
"In this case VAR is set to a ; separated list of values.";
}