Don't use a cmLocalGenerator instance to call static methods.

This commit is contained in:
Stephen Kelly 2015-05-05 21:50:39 +02:00
parent a3139d4b15
commit 9486769866
5 changed files with 21 additions and 23 deletions

View File

@ -242,8 +242,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
} }
// Detect languages to enable. // Detect languages to enable.
cmLocalGenerator* lg = this->Makefile->GetLocalGenerator(); cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
std::set<std::string> testLangs; std::set<std::string> testLangs;
for(std::vector<std::string>::iterator si = sources.begin(); for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
@ -323,7 +322,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
std::string langFlags = "CMAKE_" + *li + "_FLAGS"; std::string langFlags = "CMAKE_" + *li + "_FLAGS";
const char* flags = this->Makefile->GetDefinition(langFlags); const char* flags = this->Makefile->GetDefinition(langFlags);
fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(), fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
lg->EscapeForCMake(flags?flags:"").c_str()); cmLocalGenerator::EscapeForCMake(flags?flags:"").c_str());
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
" ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
} }
@ -356,7 +355,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* exeLinkFlags = const char* exeLinkFlags =
this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS"); this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
lg->EscapeForCMake(exeLinkFlags?exeLinkFlags:"").c_str()); cmLocalGenerator::EscapeForCMake(
exeLinkFlags ? exeLinkFlags : "").c_str());
} break; } break;
} }
fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"

View File

@ -20,15 +20,14 @@
static std::string cmIfCommandError( static std::string cmIfCommandError(
cmMakefile* mf, std::vector<cmExpandedCommandArgument> const& args) std::vector<cmExpandedCommandArgument> const& args)
{ {
cmLocalGenerator* lg = mf->GetLocalGenerator();
std::string err = "given arguments:\n "; std::string err = "given arguments:\n ";
for(std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin(); for(std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
i != args.end(); ++i) i != args.end(); ++i)
{ {
err += " "; err += " ";
err += lg->EscapeForCMake(i->GetValue()); err += cmLocalGenerator::EscapeForCMake(i->GetValue());
} }
err += "\n"; err += "\n";
return err; return err;
@ -118,7 +117,7 @@ IsFunctionBlocked(const cmListFileFunction& lff,
if (!errorString.empty()) if (!errorString.empty())
{ {
std::string err = cmIfCommandError(&mf, expandedArguments); std::string err = cmIfCommandError(expandedArguments);
err += errorString; err += errorString;
mf.IssueMessage(messType, err); mf.IssueMessage(messType, err);
if (messType == cmake::FATAL_ERROR) if (messType == cmake::FATAL_ERROR)
@ -206,7 +205,7 @@ bool cmIfCommand
if (!errorString.empty()) if (!errorString.empty())
{ {
std::string err = cmIfCommandError(this->Makefile, expandedArguments); std::string err = cmIfCommandError(expandedArguments);
err += errorString; err += errorString;
if (status == cmake::FATAL_ERROR) if (status == cmake::FATAL_ERROR)
{ {

View File

@ -1261,7 +1261,7 @@ cmLocalUnixMakefileGenerator3
f != files.end(); ++f) f != files.end(); ++f)
{ {
std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED); std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED);
fout << " " << this->EscapeForCMake(fc) << "\n"; fout << " " << cmLocalGenerator::EscapeForCMake(fc) << "\n";
} }
fout << ")\n"; fout << ")\n";
} }
@ -2060,7 +2060,7 @@ void cmLocalUnixMakefileGenerator3
di != defines.end(); ++di) di != defines.end(); ++di)
{ {
cmakefileStream cmakefileStream
<< " " << this->EscapeForCMake(*di) << "\n"; << " " << cmLocalGenerator::EscapeForCMake(*di) << "\n";
} }
cmakefileStream cmakefileStream
<< " )\n"; << " )\n";
@ -2113,7 +2113,8 @@ void cmLocalUnixMakefileGenerator3
for(std::vector<std::string>::const_iterator tri = transformRules.begin(); for(std::vector<std::string>::const_iterator tri = transformRules.begin();
tri != transformRules.end(); ++tri) tri != transformRules.end(); ++tri)
{ {
cmakefileStream << " " << this->EscapeForCMake(*tri) << "\n"; cmakefileStream << " "
<< cmLocalGenerator::EscapeForCMake(*tri) << "\n";
} }
cmakefileStream cmakefileStream
<< " )\n"; << " )\n";

View File

@ -1118,8 +1118,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
pi != this->MultipleOutputPairs.end(); ++pi) pi != this->MultipleOutputPairs.end(); ++pi)
{ {
*this->InfoFileStream *this->InfoFileStream
<< " " << this->LocalGenerator->EscapeForCMake(pi->first) << " " << cmLocalGenerator::EscapeForCMake(pi->first)
<< " " << this->LocalGenerator->EscapeForCMake(pi->second) << " " << cmLocalGenerator::EscapeForCMake(pi->second)
<< "\n"; << "\n";
} }
*this->InfoFileStream << " )\n\n"; *this->InfoFileStream << " )\n\n";

View File

@ -82,7 +82,6 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// be translated. // be translated.
std::string exe = command[0]; std::string exe = command[0];
cmMakefile* mf = this->Test->GetMakefile(); cmMakefile* mf = this->Test->GetMakefile();
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmTarget* target = mf->FindTargetToUse(exe); cmTarget* target = mf->FindTargetToUse(exe);
if(target && target->GetType() == cmTarget::EXECUTABLE) if(target && target->GetType() == cmTarget::EXECUTABLE)
{ {
@ -98,13 +97,13 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
std::string emulatorExe(emulatorWithArgs[0]); std::string emulatorExe(emulatorWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(emulatorExe); cmSystemTools::ConvertToUnixSlashes(emulatorExe);
os << lg->EscapeForCMake(emulatorExe) << " "; os << cmLocalGenerator::EscapeForCMake(emulatorExe) << " ";
for(std::vector<std::string>::const_iterator ei = for(std::vector<std::string>::const_iterator ei =
emulatorWithArgs.begin()+1; emulatorWithArgs.begin()+1;
ei != emulatorWithArgs.end(); ei != emulatorWithArgs.end();
++ei) ++ei)
{ {
os << lg->EscapeForCMake(*ei) << " "; os << cmLocalGenerator::EscapeForCMake(*ei) << " ";
} }
} }
} }
@ -116,11 +115,12 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
} }
// Generate the command line with full escapes. // Generate the command line with full escapes.
os << lg->EscapeForCMake(exe); os << cmLocalGenerator::EscapeForCMake(exe);
for(std::vector<std::string>::const_iterator ci = command.begin()+1; for(std::vector<std::string>::const_iterator ci = command.begin()+1;
ci != command.end(); ++ci) ci != command.end(); ++ci)
{ {
os << " " << lg->EscapeForCMake(ge.Parse(*ci)->Evaluate(mf, config)); os << " " << cmLocalGenerator::EscapeForCMake(
ge.Parse(*ci)->Evaluate(mf, config));
} }
// Finish the test command. // Finish the test command.
@ -136,7 +136,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
i != pm.end(); ++i) i != pm.end(); ++i)
{ {
os << " " << i->first os << " " << i->first
<< " " << lg->EscapeForCMake( << " " << cmLocalGenerator::EscapeForCMake(
ge.Parse(i->second.GetValue())->Evaluate(mf, config)); ge.Parse(i->second.GetValue())->Evaluate(mf, config));
} }
os << ")" << std::endl; os << ")" << std::endl;
@ -197,8 +197,6 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
fout << ")" << std::endl; fout << ")" << std::endl;
// Output properties for the test. // Output properties for the test.
cmMakefile* mf = this->Test->GetMakefile();
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmPropertyMap& pm = this->Test->GetProperties(); cmPropertyMap& pm = this->Test->GetProperties();
if(!pm.empty()) if(!pm.empty())
{ {
@ -208,7 +206,7 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
i != pm.end(); ++i) i != pm.end(); ++i)
{ {
fout << " " << i->first fout << " " << i->first
<< " " << lg->EscapeForCMake(i->second.GetValue()); << " " << cmLocalGenerator::EscapeForCMake(i->second.GetValue());
} }
fout << ")" << std::endl; fout << ")" << std::endl;
} }