ENH: allow cache to override config file

This commit is contained in:
Bill Hoffman 2001-05-18 13:04:36 -04:00
parent 1e7d8f8148
commit cb0af952cf
2 changed files with 72 additions and 44 deletions

View File

@ -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)

View File

@ -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;
}
// 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")
// 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)
{
const char* type = "STRING"; // default type is string
if(args.size() > 3)
// always expand the first argument
m_Makefile->ExpandVariablesInString(args[1]);
value = args[1].c_str();
}
// 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)
{
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;