cmSystemTools::Error(): new overload accepting std::string

This commit is contained in:
Vitaly Stakhovsky 2019-01-23 10:12:17 -05:00
parent a7f5cd45e1
commit 99337d345b
23 changed files with 62 additions and 54 deletions

View File

@ -720,7 +720,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
ext != headerExts.end(); ++ext) {
e << " ." << *ext;
}
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
}
void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,

View File

@ -2173,7 +2173,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// handle the simple commandline arguments
std::string errormsg;
if (!this->HandleCommandLineArguments(i, args, errormsg)) {
cmSystemTools::Error(errormsg.c_str());
cmSystemTools::Error(errormsg);
return 1;
}

View File

@ -123,7 +123,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
std::ostringstream error;
error << "Parse error in cache file " << cacheFile;
error << " on line " << lineno << ". Offending entry: " << realbuffer;
cmSystemTools::Error(error.str().c_str());
cmSystemTools::Error(error.str());
}
}
this->CacheMajorVersion = 0;
@ -171,7 +171,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
<< " where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt";
cmSystemTools::Error(message.str().c_str());
cmSystemTools::Error(message.str());
}
}
return true;

View File

@ -1237,7 +1237,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return;
}

View File

@ -495,7 +495,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
}
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
}
bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,

View File

@ -83,7 +83,7 @@ bool cmExportFileGenerator::GenerateImportFile()
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = *foutPtr;

View File

@ -54,7 +54,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
<< "\" ...) "
<< "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set.";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}
}
@ -112,7 +112,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
std::string errorMessage;
if (!this->PopulateExportProperties(gt, properties, errorMessage)) {
cmSystemTools::Error(errorMessage.c_str());
cmSystemTools::Error(errorMessage);
return false;
}
@ -294,7 +294,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << fileName << "\": " << se;
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = exportFileStream;
@ -518,7 +518,7 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
e << "that is not in this export set, but " << occurrences
<< " times in others.";
}
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
}
std::string cmExportInstallFileGenerator::InstallNameDir(

View File

@ -203,7 +203,7 @@ std::string cmGeneratorTarget::GetExportName() const
std::ostringstream e;
e << "EXPORT_NAME property \"" << exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return "";
}
return exportName;
@ -4587,7 +4587,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
<< " property requirement\nof "
"dependency \""
<< theTarget->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@ -4612,7 +4612,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
"already. The INTERFACE_"
<< p << " property on\ndependency \"" << theTarget->GetName()
<< "\" is in conflict.\n";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@ -4632,7 +4632,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
e << "The INTERFACE_" << p << " property of \""
<< theTarget->GetName() << "\" does\nnot agree with the value of "
<< p << " already determined\nfor \"" << tgt->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;

View File

@ -165,7 +165,7 @@ void cmGlobVerificationManager::AddCacheEntry(
message << "\n " << std::get<0>(bt);
std::get<1>(bt).PrintTitle(message);
}
cmSystemTools::Error(message.str().c_str());
cmSystemTools::Error(message.str());
} else {
value.Backtraces.emplace_back(variable, backtrace);
}

View File

@ -364,7 +364,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
err << "CMake was unable to find a build program corresponding to \""
<< this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
<< "probably need to select a different build tool.";
cmSystemTools::Error(err.str().c_str());
cmSystemTools::Error(err.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@ -1282,7 +1282,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
<< "duplicate custom targets. "
<< "Consider using a Makefiles generator or fix the project to not "
<< "use duplicate target names.";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}

View File

@ -93,7 +93,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
message += prevTool;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return false;
} else {
/* store the toolset that is being used for this build */
@ -178,7 +178,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
if (output.empty()) {
std::string msg =
"No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\".";
cmSystemTools::Error(msg.c_str());
cmSystemTools::Error(msg);
tsd = "";
} else {
tsd += output.back();
@ -189,7 +189,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
tryPath = cmSystemTools::CollapseCombinedPath(tsd, ts);
if (!cmSystemTools::FileExists(tryPath)) {
std::string msg = "GHS toolset \"" + tryPath + "\" not found.";
cmSystemTools::Error(msg.c_str());
cmSystemTools::Error(msg);
tsd = "";
} else {
tsd = tryPath;

View File

@ -149,7 +149,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
m += target->GetName();
m += " depends on unknown target: ";
m += name;
cmSystemTools::Error(m.c_str());
cmSystemTools::Error(m);
}
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}

View File

@ -127,7 +127,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
std::ostringstream e;
e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
<< "\"";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return;
}

View File

@ -1794,7 +1794,7 @@ static void AddVisibilityCompileOption(std::string& flags,
std::ostringstream e;
e << "Target " << target->GetName() << " uses unsupported value \"" << prop
<< "\" for " << flagDefine << ".";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return;
}
std::string option = std::string(opt) + prop;
@ -2800,7 +2800,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return;
}
@ -2838,7 +2838,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return;
}

View File

@ -194,7 +194,7 @@ protected:
message += includeFile;
message += " for file ";
message += info->FullPath;
cmSystemTools::Error(message.c_str(), nullptr);
cmSystemTools::Error(message);
}
continue;
}

View File

@ -111,7 +111,7 @@ static bool AddToSourceGroup(cmMakefile* makefile, std::string const& fileName,
ost << ": " << property;
ost << ": Could not find or create the source group ";
ost << cmQtAutoGen::Quoted(groupName);
cmSystemTools::Error(ost.str().c_str());
cmSystemTools::Error(ost.str());
return false;
}
}
@ -941,7 +941,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
if (!qrc.Generated) {
std::string error;
if (!RccListInputs(qrc.QrcFile, qrc.Resources, error)) {
cmSystemTools::Error(error.c_str());
cmSystemTools::Error(error);
return false;
}
}
@ -1219,7 +1219,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
if (!cmSystemTools::MakeDirectory(this->Dir.Info)) {
std::string emsg = ("AutoGen: Could not create directory: ");
emsg += Quoted(this->Dir.Info);
cmSystemTools::Error(emsg.c_str());
cmSystemTools::Error(emsg);
return false;
}
@ -1307,7 +1307,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
} else {
std::string err = "AutoGen: Could not write file ";
err += this->AutogenTarget.InfoFile;
cmSystemTools::Error(err.c_str());
cmSystemTools::Error(err);
return false;
}
@ -1347,7 +1347,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
} else {
std::string err = "AutoRcc: Could not write file ";
err += qrc.InfoFile;
cmSystemTools::Error(err.c_str());
cmSystemTools::Error(err);
return false;
}
}
@ -1512,7 +1512,7 @@ std::pair<bool, std::string> GetQtExecutable(
msg += target->GetName();
msg += "): ";
msg += err;
cmSystemTools::Error(msg.c_str());
cmSystemTools::Error(msg);
return std::make_pair(false, "");
}

View File

@ -270,6 +270,13 @@ void cmSystemTools::Error(const char* m1, const char* m2, const char* m3,
cmSystemTools::Message(message.c_str(), "Error");
}
void cmSystemTools::Error(const std::string& m)
{
std::string message = "CMake Error: " + m;
cmSystemTools::s_ErrorOccured = true;
cmSystemTools::Message(message.c_str(), "Error");
}
void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
{
s_InterruptCallback = f;
@ -338,7 +345,7 @@ void cmSystemTools::ReportLastSystemError(const char* msg)
std::string m = msg;
m += ": System Error: ";
m += Superclass::GetLastSystemError();
cmSystemTools::Error(m.c_str());
cmSystemTools::Error(m);
}
bool cmSystemTools::IsInternallyOn(const char* val)
@ -549,7 +556,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += arg.substr(1);
cmSystemTools::Error(error.c_str());
cmSystemTools::Error(error);
} else {
std::string line;
cmSystemTools::GetLineFromStream(responseFile, line);
@ -1651,7 +1658,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
e += outFileName;
e += "\": ";
e += cmSystemTools::GetLastSystemError();
cmSystemTools::Error(e.c_str());
cmSystemTools::Error(e);
return false;
}
cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone;
@ -1684,7 +1691,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
}
}
if (!a) {
cmSystemTools::Error(a.GetError().c_str());
cmSystemTools::Error(a.GetError());
return false;
}
return true;
@ -3120,7 +3127,7 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
if (errorMessage) {
*errorMessage = std::move(e);
} else {
cmSystemTools::Error(e.c_str());
cmSystemTools::Error(e);
}
return false;
}
@ -3141,7 +3148,7 @@ bool cmSystemTools::CreateLink(const std::string& origName,
if (errorMessage) {
*errorMessage = std::move(e);
} else {
cmSystemTools::Error(e.c_str());
cmSystemTools::Error(e);
}
return false;
}

View File

@ -70,6 +70,7 @@ public:
*/
static void Error(const char* m, const char* m2 = nullptr,
const char* m3 = nullptr, const char* m4 = nullptr);
static void Error(const std::string& m);
/**
* Display a message.

View File

@ -121,7 +121,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// now try running the command if it compiled
if (!res) {
if (this->OutputFile.empty()) {
cmSystemTools::Error(this->FindErrorMessage.c_str());
cmSystemTools::Error(this->FindErrorMessage);
} else {
// "run" it and capture the output
std::string runOutputContents;
@ -354,7 +354,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
errorMessage += " " + internalRunOutputName + " (advanced)\n";
}
errorMessage += detailsString;
cmSystemTools::Error(errorMessage.c_str());
cmSystemTools::Error(errorMessage);
return;
}

View File

@ -57,7 +57,7 @@ bool cmVariableRequiresCommand::InitialPass(
"One or more of the required variables is advanced."
" To set the variable, you must turn on advanced mode in cmake.";
}
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
}
return true;

View File

@ -60,7 +60,7 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
error << "Error in cmake code at\nUnknown:0:\n"
<< "A command failed during the invocation of callback \""
<< data->Command << "\".";
cmSystemTools::Error(error.str().c_str());
cmSystemTools::Error(error.str());
data->InCallback = false;
return;
}

View File

@ -1172,7 +1172,7 @@ int cmake::DoPreConfigureChecks()
}
err << "Specify --help for usage, or press the help button on the CMake "
"GUI.";
cmSystemTools::Error(err.str().c_str());
cmSystemTools::Error(err.str());
return -2;
}
@ -1190,7 +1190,7 @@ int cmake::DoPreConfigureChecks()
message += cacheStart;
message += "\" used to generate cache. ";
message += "Re-run cmake with a different source directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return -2;
}
} else {
@ -1400,7 +1400,7 @@ int cmake::ActualConfigure()
message += *genName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return -2;
}
}
@ -1424,7 +1424,7 @@ int cmake::ActualConfigure()
message += *instance;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return -2;
}
} else {
@ -1443,7 +1443,7 @@ int cmake::ActualConfigure()
message += *platformName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return -2;
}
} else {
@ -1461,7 +1461,7 @@ int cmake::ActualConfigure()
message += *tsName;
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
"directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
cmSystemTools::Error(message);
return -2;
}
} else {

View File

@ -123,7 +123,7 @@ void CMakeCommandUsage(const char* program)
;
/* clang-format on */
cmSystemTools::Error(errorStream.str().c_str());
cmSystemTools::Error(errorStream.str());
}
static bool cmTarFilesFrom(std::string const& file,
@ -132,14 +132,14 @@ static bool cmTarFilesFrom(std::string const& file,
if (cmSystemTools::FileIsDirectory(file)) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' is a directory";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}
cmsys::ifstream fin(file.c_str());
if (!fin) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' not found";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
}
std::string line;
@ -153,7 +153,7 @@ static bool cmTarFilesFrom(std::string const& file,
std::ostringstream e;
e << "-E tar --files-from='" << file << "' file invalid line:\n"
<< line << "\n";
cmSystemTools::Error(e.str().c_str());
cmSystemTools::Error(e.str());
return false;
} else {
files.push_back(line);
@ -1173,7 +1173,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (server.Serve(&errorMessage)) {
return 0;
}
cmSystemTools::Error(errorMessage.c_str());
cmSystemTools::Error(errorMessage);
#else
static_cast<void>(supportExperimental);
static_cast<void>(isDebug);