summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeSystemConfig.cmake.in38
-rw-r--r--Source/cmSetCommand.cxx76
2 files changed, 71 insertions, 43 deletions
diff --git a/CMakeSystemConfig.cmake.in b/CMakeSystemConfig.cmake.in
index 85c2cca..cb13f6e 100644
--- a/CMakeSystemConfig.cmake.in
+++ b/CMakeSystemConfig.cmake.in
@@ -3,21 +3,23 @@
# in, which need not be the source directory
#
SET (CMAKE_WORDS_BIGENDIAN @CMAKE_WORDS_BIGENDIAN@ )
-SET (CMAKE_USE_SPROC @CMAKE_USE_SPROC@ CACHE BOOL)
-SET (CMAKE_USE_PTHREADS @CMAKE_USE_PTHREADS@ CACHE BOOL)
-SET (CMAKE_HP_PTHREADS @CMAKE_HP_PTHREADS@ CACHE BOOL)
-SET (CMAKE_LIB_EXT @CMAKE_LIB_EXT@ CACHE STRING)
-SET (CMAKE_RANLIB "@RANLIB@" CACHE STRING)
-SET (CMAKE_AR "@CMAKE_AR@" CACHE STRING)
-SET (CMAKE_CXX_COMPILER "@CXX@" CACHE FILEPATH)
-SET (CMAKE_CXX_FLAGS "@CXXFLAGS@" CACHE STRING)
-SET (CMAKE_TEMPLATE_FLAGS "@CMAKE_TEMPLATE_FLAGS@" CACHE STRING)
-SET (CMAKE_C_COMPILER "@CC@" CACHE FILEPATH)
-SET (CMAKE_C_FLAGS "@CFLAGS@" CACHE STRING)
-SET (CMAKE_SHLIB_CFLAGS "@CMAKE_SHLIB_CFLAGS@" CACHE STRING)
-SET (CMAKE_SHLIB_BUILD_FLAGS "@CMAKE_SHLIB_BUILD_FLAGS@" CACHE STRING)
-SET (CMAKE_SHLIB_SUFFIX @CMAKE_SHLIB_SUFFIX@ CACHE STRING)
-SET (CMAKE_THREAD_LIBS "@CMAKE_THREAD_LIBS@" CACHE STRING)
-SET (CMAKE_DL_LIBS "@CMAKE_DL_LIBS@" CACHE STRING)
-SET (CMAKE_SHLIB_LINK_FLAGS "@CMAKE_SHLIB_LINK_FLAGS@" CACHE STRING)
-SET (CMAKE_SHLIB_LD_LIBS "@CMAKE_SHLIB_LD_LIBS@" CACHE STRING)
+SET (CMAKE_USE_SPROC @CMAKE_USE_SPROC@ CACHE_NO_REPLACE BOOL)
+SET (CMAKE_USE_PTHREADS @CMAKE_USE_PTHREADS@ CACHE_NO_REPLACE BOOL)
+SET (CMAKE_HP_PTHREADS @CMAKE_HP_PTHREADS@ CACHE_NO_REPLACE BOOL)
+SET (CMAKE_LIB_EXT @CMAKE_LIB_EXT@ CACHE_NO_REPLACE STRING)
+SET (CMAKE_RANLIB "@RANLIB@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_AR "@CMAKE_AR@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_CXX_COMPILER "@CXX@" CACHE_NO_REPLACE FILEPATH)
+SET (CMAKE_CXX_FLAGS "@CXXFLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_TEMPLATE_FLAGS "@CMAKE_TEMPLATE_FLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_C_COMPILER "@CC@" CACHE_NO_REPLACE FILEPATH)
+SET (CMAKE_C_FLAGS "@CFLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_CFLAGS "@CMAKE_SHLIB_CFLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_BUILD_FLAGS "@CMAKE_SHLIB_BUILD_FLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_SUFFIX @CMAKE_SHLIB_SUFFIX@ CACHE_NO_REPLACE STRING)
+SET (CMAKE_THREAD_LIBS "@CMAKE_THREAD_LIBS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_DL_LIBS "@CMAKE_DL_LIBS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_LINK_FLAGS "@CMAKE_SHLIB_LINK_FLAGS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_LD_LIBS "@CMAKE_SHLIB_LD_LIBS@" CACHE_NO_REPLACE STRING)
+SET (CMAKE_SHLIB_LD_LIBS "@CMAKE_SHLIB_LD_LIBS@" CACHE_NO_REPLACE_NO_REPLACE STRING)
+
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;