cmGlobalGenerator: Take Build output argument by reference
No call sites pass NULL to the output argument, so take it by reference to avoid the if(output) conditions. Propagate the change through the TryCompile APIs that call it.
This commit is contained in:
parent
b48211d426
commit
30983ebec1
|
@ -301,7 +301,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||||
int retVal = cm.GetGlobalGenerator()->Build(
|
int retVal = cm.GetGlobalGenerator()->Build(
|
||||||
this->SourceDir, this->BinaryDir,
|
this->SourceDir, this->BinaryDir,
|
||||||
this->BuildProject, *tarIt,
|
this->BuildProject, *tarIt,
|
||||||
&output, this->BuildMakeProgram,
|
output, this->BuildMakeProgram,
|
||||||
config,
|
config,
|
||||||
!this->BuildNoClean,
|
!this->BuildNoClean,
|
||||||
false, remainingTime);
|
false, remainingTime);
|
||||||
|
|
|
@ -489,7 +489,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
targetName,
|
targetName,
|
||||||
this->SrcFileSignature,
|
this->SrcFileSignature,
|
||||||
&cmakeFlags,
|
&cmakeFlags,
|
||||||
&output);
|
output);
|
||||||
if ( erroroc )
|
if ( erroroc )
|
||||||
{
|
{
|
||||||
cmSystemTools::SetErrorOccured();
|
cmSystemTools::SetErrorOccured();
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
|
||||||
const std::string& bindir,
|
const std::string& bindir,
|
||||||
const std::string& projectName,
|
const std::string& projectName,
|
||||||
const std::string& target, bool fast,
|
const std::string& target, bool fast,
|
||||||
std::string *output, cmMakefile *mf)
|
std::string& output, cmMakefile *mf)
|
||||||
{
|
{
|
||||||
// if this is not set, then this is a first time configure
|
// if this is not set, then this is a first time configure
|
||||||
// and there is a good chance that the try compile stuff will
|
// and there is a good chance that the try compile stuff will
|
||||||
|
@ -1675,7 +1675,7 @@ void cmGlobalGenerator::GenerateBuildCommand(
|
||||||
int cmGlobalGenerator::Build(
|
int cmGlobalGenerator::Build(
|
||||||
const std::string&, const std::string& bindir,
|
const std::string&, const std::string& bindir,
|
||||||
const std::string& projectName, const std::string& target,
|
const std::string& projectName, const std::string& target,
|
||||||
std::string *output,
|
std::string& output,
|
||||||
const std::string& makeCommandCSTR,
|
const std::string& makeCommandCSTR,
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
|
@ -1688,22 +1688,15 @@ int cmGlobalGenerator::Build(
|
||||||
*/
|
*/
|
||||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
cmSystemTools::ChangeDirectory(bindir.c_str());
|
cmSystemTools::ChangeDirectory(bindir.c_str());
|
||||||
if(output)
|
output += "Change Dir: ";
|
||||||
{
|
output += bindir;
|
||||||
*output += "Change Dir: ";
|
output += "\n";
|
||||||
*output += bindir;
|
|
||||||
*output += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
int retVal;
|
int retVal;
|
||||||
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
|
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
|
||||||
cmSystemTools::SetRunCommandHideConsole(true);
|
cmSystemTools::SetRunCommandHideConsole(true);
|
||||||
std::string outputBuffer;
|
std::string outputBuffer;
|
||||||
std::string* outputPtr = 0;
|
std::string* outputPtr = &outputBuffer;
|
||||||
if(output)
|
|
||||||
{
|
|
||||||
outputPtr = &outputBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// should we do a clean first?
|
// should we do a clean first?
|
||||||
if (clean)
|
if (clean)
|
||||||
|
@ -1711,32 +1704,23 @@ int cmGlobalGenerator::Build(
|
||||||
std::vector<std::string> cleanCommand;
|
std::vector<std::string> cleanCommand;
|
||||||
this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
|
this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
|
||||||
bindir, "clean", config, fast);
|
bindir, "clean", config, fast);
|
||||||
if(output)
|
output += "\nRun Clean Command:";
|
||||||
{
|
output += cmSystemTools::PrintSingleCommand(cleanCommand);
|
||||||
*output += "\nRun Clean Command:";
|
output += "\n";
|
||||||
*output += cmSystemTools::PrintSingleCommand(cleanCommand);
|
|
||||||
*output += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
|
if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
cmSystemTools::Error("Generator: execution of make clean failed.");
|
cmSystemTools::Error("Generator: execution of make clean failed.");
|
||||||
if (output)
|
output += *outputPtr;
|
||||||
{
|
output += "\nGenerator: execution of make clean failed.\n";
|
||||||
*output += *outputPtr;
|
|
||||||
*output += "\nGenerator: execution of make clean failed.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// return to the original directory
|
// return to the original directory
|
||||||
cmSystemTools::ChangeDirectory(cwd.c_str());
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (output)
|
output += *outputPtr;
|
||||||
{
|
|
||||||
*output += *outputPtr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now build
|
// now build
|
||||||
|
@ -1744,12 +1728,9 @@ int cmGlobalGenerator::Build(
|
||||||
this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
|
this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
|
||||||
bindir, target, config, fast, nativeOptions);
|
bindir, target, config, fast, nativeOptions);
|
||||||
std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
|
std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
|
||||||
if(output)
|
output += "\nRun Build Command:";
|
||||||
{
|
output += makeCommandStr;
|
||||||
*output += "\nRun Build Command:";
|
output += "\n";
|
||||||
*output += makeCommandStr;
|
|
||||||
*output += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
|
if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
|
@ -1758,27 +1739,21 @@ int cmGlobalGenerator::Build(
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
("Generator: execution of make failed. Make command was: ",
|
("Generator: execution of make failed. Make command was: ",
|
||||||
makeCommandStr.c_str());
|
makeCommandStr.c_str());
|
||||||
if (output)
|
output += *outputPtr;
|
||||||
{
|
output += "\nGenerator: execution of make failed. Make command was: "
|
||||||
*output += *outputPtr;
|
|
||||||
*output += "\nGenerator: execution of make failed. Make command was: "
|
|
||||||
+ makeCommandStr + "\n";
|
+ makeCommandStr + "\n";
|
||||||
}
|
|
||||||
|
|
||||||
// return to the original directory
|
// return to the original directory
|
||||||
cmSystemTools::ChangeDirectory(cwd.c_str());
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (output)
|
output += *outputPtr;
|
||||||
{
|
|
||||||
*output += *outputPtr;
|
|
||||||
}
|
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
|
|
||||||
// The SGI MipsPro 7.3 compiler does not return an error code when
|
// The SGI MipsPro 7.3 compiler does not return an error code when
|
||||||
// the source has a #error in it! This is a work-around for such
|
// the source has a #error in it! This is a work-around for such
|
||||||
// compilers.
|
// compilers.
|
||||||
if((retVal == 0) && (output->find("#error") != std::string::npos))
|
if((retVal == 0) && (output.find("#error") != std::string::npos))
|
||||||
{
|
{
|
||||||
retVal = 1;
|
retVal = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
virtual int TryCompile(const std::string& srcdir, const std::string& bindir,
|
virtual int TryCompile(const std::string& srcdir, const std::string& bindir,
|
||||||
const std::string& projectName,
|
const std::string& projectName,
|
||||||
const std::string& targetName,
|
const std::string& targetName,
|
||||||
bool fast, std::string *output, cmMakefile* mf);
|
bool fast, std::string& output, cmMakefile* mf);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ public:
|
||||||
*/
|
*/
|
||||||
int Build(const std::string& srcdir, const std::string& bindir,
|
int Build(const std::string& srcdir, const std::string& bindir,
|
||||||
const std::string& projectName, const std::string& targetName,
|
const std::string& projectName, const std::string& targetName,
|
||||||
std::string *output,
|
std::string& output,
|
||||||
const std::string& makeProgram, const std::string& config,
|
const std::string& makeProgram, const std::string& config,
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
double timeout,
|
double timeout,
|
||||||
|
|
|
@ -3510,7 +3510,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
|
||||||
const std::string& targetName,
|
const std::string& targetName,
|
||||||
bool fast,
|
bool fast,
|
||||||
const std::vector<std::string> *cmakeArgs,
|
const std::vector<std::string> *cmakeArgs,
|
||||||
std::string *output)
|
std::string& output)
|
||||||
{
|
{
|
||||||
this->Internal->IsSourceFileTryCompile = fast;
|
this->Internal->IsSourceFileTryCompile = fast;
|
||||||
// does the binary directory exist ? If not create it...
|
// does the binary directory exist ? If not create it...
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
const std::string& projectName, const std::string& targetName,
|
const std::string& projectName, const std::string& targetName,
|
||||||
bool fast,
|
bool fast,
|
||||||
const std::vector<std::string> *cmakeArgs,
|
const std::vector<std::string> *cmakeArgs,
|
||||||
std::string *output);
|
std::string& output);
|
||||||
|
|
||||||
bool GetIsSourceFileTryCompile() const;
|
bool GetIsSourceFileTryCompile() const;
|
||||||
|
|
||||||
|
|
|
@ -2757,7 +2757,7 @@ int cmake::Build(const std::string& dir,
|
||||||
projName = it.GetValue();
|
projName = it.GetValue();
|
||||||
return gen->Build("", dir,
|
return gen->Build("", dir,
|
||||||
projName, target,
|
projName, target,
|
||||||
&output,
|
output,
|
||||||
"",
|
"",
|
||||||
config, clean, false, 0,
|
config, clean, false, 0,
|
||||||
cmSystemTools::OUTPUT_PASSTHROUGH,
|
cmSystemTools::OUTPUT_PASSTHROUGH,
|
||||||
|
|
Loading…
Reference in New Issue