cmGlobalGenerator: use cmStrCat in ::Build

Also replace some single-char strings with character literals.
This commit is contained in:
Ben Boeckel 2023-05-16 10:50:03 -04:00
parent 81d45dabc4
commit 465ab8d872

View File

@ -2096,16 +2096,13 @@ int cmGlobalGenerator::Build(
* Run an executable command and put the stdout in output. * Run an executable command and put the stdout in output.
*/ */
cmWorkingDirectory workdir(bindir); cmWorkingDirectory workdir(bindir);
output += "Change Dir: "; output += cmStrCat("Change Dir: ", bindir, '\n');
output += bindir;
output += "\n";
if (workdir.Failed()) { if (workdir.Failed()) {
cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::SetRunCommandHideConsole(hideconsole);
std::string err = cmStrCat("Failed to change directory: ", std::string err = cmStrCat("Failed to change directory: ",
std::strerror(workdir.GetLastResult())); std::strerror(workdir.GetLastResult()));
cmSystemTools::Error(err); cmSystemTools::Error(err);
output += err; output += cmStrCat(err, '\n');
output += "\n";
return 1; return 1;
} }
std::string realConfig = config; std::string realConfig = config;
@ -2134,9 +2131,8 @@ int cmGlobalGenerator::Build(
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
{ "clean" }, realConfig, jobs, verbose, { "clean" }, realConfig, jobs, verbose,
buildOptions); buildOptions);
output += "\nRun Clean Command:"; output +=
output += cleanCommand.front().Printable(); cmStrCat("\nRun Clean Command:", cleanCommand.front().Printable(), '\n');
output += "\n";
if (cleanCommand.size() != 1) { if (cleanCommand.size() != 1) {
this->GetCMakeInstance()->IssueMessage(MessageType::INTERNAL_ERROR, this->GetCMakeInstance()->IssueMessage(MessageType::INTERNAL_ERROR,
"The generator did not produce " "The generator did not produce "
@ -2149,8 +2145,8 @@ int cmGlobalGenerator::Build(
nullptr, outputflag, timeout)) { nullptr, outputflag, timeout)) {
cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::SetRunCommandHideConsole(hideconsole);
cmSystemTools::Error("Generator: execution of make clean failed."); cmSystemTools::Error("Generator: execution of make clean failed.");
output += *outputPtr; output +=
output += "\nGenerator: execution of make clean failed.\n"; cmStrCat(*outputPtr, "\nGenerator: execution of make clean failed.\n");
return 1; return 1;
} }
@ -2177,9 +2173,10 @@ int cmGlobalGenerator::Build(
cmSystemTools::Error( cmSystemTools::Error(
"Generator: execution of make failed. Make command was: " + "Generator: execution of make failed. Make command was: " +
makeCommandStr); makeCommandStr);
output += *outputPtr; output +=
output += "\nGenerator: execution of make failed. Make command was: " + cmStrCat(*outputPtr,
makeCommandStr + "\n"; "\nGenerator: execution of make failed. Make command was: ",
makeCommandStr, '\n');
return 1; return 1;
} }