summaryrefslogtreecommitdiffstats
path: root/Source/cmSetCommand.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-18 17:04:36 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-18 17:04:36 (GMT)
commitcb0af952cf1ebaa82eb09bb3b63be681e3d2d3ca (patch)
tree75e5212f28a89f8741d1981f16c5859e2cae2811 /Source/cmSetCommand.cxx
parent1e7d8f8148585109e77420ffd23954a33a378b00 (diff)
downloadCMake-cb0af952cf1ebaa82eb09bb3b63be681e3d2d3ca.zip
CMake-cb0af952cf1ebaa82eb09bb3b63be681e3d2d3ca.tar.gz
CMake-cb0af952cf1ebaa82eb09bb3b63be681e3d2d3ca.tar.bz2
ENH: allow cache to override config file
Diffstat (limited to 'Source/cmSetCommand.cxx')
-rw-r--r--Source/cmSetCommand.cxx76
1 files changed, 51 insertions, 25 deletions
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index ecc7f53..433d37f 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -52,36 +52,62 @@ bool cmSetCommand::Invoke(std::vector<std::string>& args)
{
return true;
}
- if(args[1] == "CACHE")
- {
- const char* type = "STRING"; // default type is string
- if(args.size() > 2)
- {
- type = args[2].c_str();
- }
- m_Makefile->AddDefinition(args[0].c_str(), "");
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- "",
- "Value Computed by CMake",
- cmCacheManager::StringToType(type));
- return true;
+// here are the options with the num
+// SET VAR
+// SET VAR value
+// SET VAR CACHE|CACHE_NO_REPLACE
+// SET VAR value CACHE|CACHE_NO_REPLACE
+// SET VAR CACHE|CACHE_NO_REPLACE TYPE
+// SET VAR value CACHE|CACHE_NO_REPLACE TYPE
+ const char* type = "STRING"; // set a default type of STRING
+ const char* value = "";// set a default value of the empty string
+ if(args.size() > 1)
+ {
+ // always expand the first argument
+ m_Makefile->ExpandVariablesInString(args[1]);
+ value = args[1].c_str();
}
-
- // expand value
- m_Makefile->ExpandVariablesInString(args[1]);
- m_Makefile->AddDefinition(args[0].c_str(), args[1].c_str());
-
- // should we store the result in the cache ?
- if (args.size() > 2 && args[2] == "CACHE")
+ // get the current cache value for the variable
+ const char* cacheValue =
+ cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
+ // assume this will not be cached
+ bool cache = false;
+ // search the arguments for key words CACHE and CACHE_NO_REPLACE
+ for(int i = 1; i < args.size() && !cache; ++i)
{
- const char* type = "STRING"; // default type is string
- if(args.size() > 3)
+ if(args[i] == "CACHE_NO_REPLACE")
{
- type = args[3].c_str();
+ // if already in cache, ignore entire command
+ if(cacheValue)
+ {
+ return true;
+ }
+ cache = true;
}
+ if(args[i] == "CACHE")
+ {
+ cache == true;
+ }
+ // if this is to be cached, find the value and type
+ if(cache)
+ {
+ // if this is the
+ if(i == 1)
+ {
+ value = "";
+ }
+ if(i+1 < args.size())
+ {
+ type = args[i+1].c_str();
+ }
+ }
+ }
+ m_Makefile->AddDefinition(args[0].c_str(), value);
+ if(cache)
+ {
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- args[1].c_str(),
- "Value Computed by CMake",
+ value,
+ "Value Computed by CMake",
cmCacheManager::StringToType(type));
}
return true;