From 9a5b4eba97628c53f051d653cdc8a301f5f32312 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 May 2007 17:40:59 -0400 Subject: [PATCH] BUG: All variable accesses should produce watch callbacks, including IF(DEFINED ) ones. Instead we define a new access type for IF(DEFINED) so that the error does not show up for backward compatibility variables. --- Source/cmIfCommand.cxx | 7 ++++--- Source/cmMakefile.cxx | 26 +++++++++++++++++++++++--- Source/cmMakefile.h | 2 +- Source/cmVariableWatch.h | 1 + 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 2814f7210..8faab58a9 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -307,17 +307,18 @@ bool cmIfCommand::IsTrue(const std::vector &args, if (*arg == "DEFINED" && argP1 != newArgs.end()) { size_t argP1len = argP1->size(); + bool bdef = false; if(argP1len > 4 && argP1->substr(0, 4) == "ENV{" && argP1->operator[](argP1len-1) == '}') { std::string env = argP1->substr(4, argP1len-5); - def = cmSystemTools::GetEnv(env.c_str()); + bdef = cmSystemTools::GetEnv(env.c_str())?true:false; } else { - def = makefile->GetDefinitionNoWatch((argP1)->c_str()); + bdef = makefile->IsDefinitionSet((argP1)->c_str()); } - if(def) + if(bdef) { *arg = "1"; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9f05114de..f126d0e68 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1633,7 +1633,7 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const return ret; } -const char* cmMakefile::GetDefinitionNoWatch(const char* name) const +bool cmMakefile::IsDefinitionSet(const char* name) const { const char* def = 0; DefinitionMap::const_iterator pos = this->Definitions.find(name); @@ -1645,12 +1645,32 @@ const char* cmMakefile::GetDefinitionNoWatch(const char* name) const { def = this->GetCacheManager()->GetCacheValue(name); } - return def; +#ifdef CMAKE_BUILD_WITH_CMAKE + if(cmVariableWatch* vv = this->GetVariableWatch()) + { + if(!def) + { + vv->VariableAccessed + (name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, + def, this); + } + } +#endif + return def?true:false; } const char* cmMakefile::GetDefinition(const char* name) const { - const char* def = this->GetDefinitionNoWatch(name); + const char* def = 0; + DefinitionMap::const_iterator pos = this->Definitions.find(name); + if(pos != this->Definitions.end()) + { + def = (*pos).second.c_str(); + } + else + { + def = this->GetCacheManager()->GetCacheValue(name); + } #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1ea866ce4..8f4d0ee89 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -492,9 +492,9 @@ public: * cache is then queried. */ const char* GetDefinition(const char*) const; - const char* GetDefinitionNoWatch(const char*) const; const char* GetSafeDefinition(const char*) const; const char* GetRequiredDefinition(const char* name) const; + bool IsDefinitionSet(const char*) const; /** * Get the list of all variables in the current space. If argument * cacheonly is specified and is greater than 0, then only cache diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 7f97c282c..fc24d179c 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -55,6 +55,7 @@ public: { VARIABLE_READ_ACCESS = 0, UNKNOWN_VARIABLE_READ_ACCESS, + UNKNOWN_VARIABLE_DEFINED_ACCESS, ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS, VARIABLE_MODIFIED_ACCESS, VARIABLE_REMOVED_ACCESS,