summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2002-11-13 20:20:20 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2002-11-13 20:20:20 (GMT)
commit2905d39689a23c580b3356f668ad02397424f09e (patch)
tree9f73a87cb9c3030ea9871bc56e1a02a29cf04b4c
parent46ede79d587f86b9ed8126f4d454b36b8fd9b151 (diff)
downloadCMake-2905d39689a23c580b3356f668ad02397424f09e.zip
CMake-2905d39689a23c580b3356f668ad02397424f09e.tar.gz
CMake-2905d39689a23c580b3356f668ad02397424f09e.tar.bz2
ENH: check to make sure cmake matches the cmake used to generate the cache
-rw-r--r--Source/cmGlobalUnixMakefileGenerator.cxx15
-rw-r--r--Source/cmake.cxx49
-rw-r--r--Source/cmake.h2
3 files changed, 40 insertions, 26 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx
index 4fc0f60..2619f69 100644
--- a/Source/cmGlobalUnixMakefileGenerator.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator.cxx
@@ -24,21 +24,6 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
cmMakefile *mf)
{
bool isLocal = m_CMakeInstance->GetLocal();
- const char* majv = mf->GetDefinition("CMAKE_CACHE_MAJOR_VERSION");
- const char* minv = mf->GetDefinition("CMAKE_CACHE_MINOR_VERSION");
- const char* relv = mf->GetDefinition("CMAKE_CACHE_RELEASE_VERSION");
- bool cacheSameCMake = false;
- if(majv && atoi(majv) == cmMakefile::GetMajorVersion()
- && minv && atoi(minv) == cmMakefile::GetMinorVersion()
- && relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0))
- {
- cacheSameCMake = true;
- }
- if(!cacheSameCMake)
- {
- isLocal = false;
- }
-
// if no lang specified use CXX
if(!lang )
{
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 340ee32..7807927 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -805,6 +805,21 @@ int cmake::Configure()
return 0;
}
+bool cmake::CacheVersionMatches()
+{
+ const char* majv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION");
+ const char* minv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION");
+ const char* relv = m_CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION");
+ bool cacheSameCMake = false;
+ if(majv && atoi(majv) == cmMakefile::GetMajorVersion()
+ && minv && atoi(minv) == cmMakefile::GetMinorVersion()
+ && relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0))
+ {
+ cacheSameCMake = true;
+ }
+ return cacheSameCMake;
+}
+
// handle a command line invocation
int cmake::Run(const std::vector<std::string>& args)
{
@@ -840,20 +855,32 @@ int cmake::Run(const std::vector<std::string>& args)
// Add any cache args
this->SetCacheArgs(args);
-
- // if we are local do the local thing, otherwise do global
- if (m_Local)
- {
- return this->LocalGenerate();
+
+ int ret = 0;
+ // if not local or the cmake version has changed
+ // since the last run of cmake, run a global generate
+ if(!m_Local || !this->CacheVersionMatches())
+ {
+ bool saveLocalFlag = m_Local;
+ m_Local = false;
+ ret = this->Configure();
+ if (ret)
+ {
+ return ret;
+ }
+ ret = this->Generate();
+ if(ret)
+ {
+ return ret;
+ }
+ m_Local = saveLocalFlag;
}
-
- // otherwise global
- int ret = this->Configure();
- if (ret)
+ // if we are local do the local thing
+ if (m_Local)
{
- return ret;
+ ret = this->LocalGenerate();
}
- return this->Generate();
+ return ret;
}
int cmake::Generate()
diff --git a/Source/cmake.h b/Source/cmake.h
index 749e448..cf0d7bf 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -236,6 +236,8 @@ protected:
std::string m_cmStartDirectory;
std::string m_StartOutputDirectory;
+ ///! return true if the same cmake was used to make the cache.
+ bool CacheVersionMatches();
///! read in a cmake list file to initialize the cache
void ReadListFile(const char *path);