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

View File

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

View File

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

View File

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

View File

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