From f709e5588eaae694c7b1203580da0b5487b9ef73 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 27 Aug 2001 14:44:15 -0400 Subject: [PATCH] ENH: change expand variables to use GetDefinition --- Source/cmMakefile.cxx | 12 ++++---- Source/cmMakefile.h | 2 +- Source/cmUnixMakefileGenerator.cxx | 46 ++++++++++++++++-------------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a54b78ad9..3eb2d61cb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -787,9 +787,9 @@ bool cmMakefile::IsOn(const char* name) return cmSystemTools::IsOn(value); } -const char* cmMakefile::GetDefinition(const char* name) +const char* cmMakefile::GetDefinition(const char* name) const { - DefinitionMap::iterator pos = m_Definitions.find(name); + DefinitionMap::const_iterator pos = m_Definitions.find(name); if(pos != m_Definitions.end()) { return (*pos).second.c_str(); @@ -929,16 +929,16 @@ void cmMakefile::ExpandVariablesInString(std::string& source, } else { - DefinitionMap::const_iterator pos = m_Definitions.find(var.c_str()); - if(pos != m_Definitions.end()) + const char* lookup = this->GetDefinition(var.c_str()); + if(lookup) { if (escapeQuotes) { - result += cmSystemTools::EscapeQuotes((*pos).second.c_str()); + result += cmSystemTools::EscapeQuotes(lookup); } else { - result += (*pos).second; + result += lookup; } found = true; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 5146f8f99..b3e586573 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -452,7 +452,7 @@ public: * If the variable is not found in this makefile instance, the * cache is then queried. */ - const char* GetDefinition(const char*); + const char* GetDefinition(const char*) const; /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index d5303fc67..d93b803da 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -1370,27 +1370,31 @@ void cmUnixMakefileGenerator::ComputeSystemInfo() { if (m_CacheOnly) { - if(m_Makefile->GetDefinition("CMAKE_CXX_COMPILER")) - { - std::string env = "CXX=${CMAKE_CXX_COMPILER}"; - m_Makefile->ExpandVariablesInString(env); - putenv(const_cast(env.c_str())); - env = "CC=${CMAKE_C_COMPILER}"; - m_Makefile->ExpandVariablesInString(env); - putenv(const_cast(env.c_str())); - } - - // currently we run configure shell script here to determine the info - std::string output; - std::string cmd = "cd "; - cmd += m_Makefile->GetHomeOutputDirectory(); - cmd += "; "; - const char* root - = m_Makefile->GetDefinition("CMAKE_ROOT"); - cmd += root; - cmd += "/Templates/configure"; - cmSystemTools::RunCommand(cmd.c_str(), output); - m_Makefile->AddDefinition("RUN_CONFIGURE", true); + if(m_Makefile->GetDefinition("CMAKE_CXX_COMPILER")) + { + std::string env = "CXX=${CMAKE_CXX_COMPILER}"; + m_Makefile->ExpandVariablesInString(env); + std::cout << "Setting: " << env.c_str() << "\n"; + putenv(const_cast(env.c_str())); + } + if(m_Makefile->GetDefinition("CMAKE_C_COMPILER")) + { + std::string env = "CC=${CMAKE_C_COMPILER}"; + m_Makefile->ExpandVariablesInString(env); + std::cout << "Setting: " << env.c_str() << "\n"; + putenv(const_cast(env.c_str())); + } + // currently we run configure shell script here to determine the info + std::string output; + std::string cmd = "cd "; + cmd += m_Makefile->GetHomeOutputDirectory(); + cmd += "; "; + const char* root + = m_Makefile->GetDefinition("CMAKE_ROOT"); + cmd += root; + cmd += "/Templates/configure"; + cmSystemTools::RunCommand(cmd.c_str(), output); + m_Makefile->AddDefinition("RUN_CONFIGURE", true); } // now load the settings