diff options
Diffstat (limited to 'Source')
44 files changed, 229 insertions, 172 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 39cb7e6..6c6b3a0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 20190207) +set(CMake_VERSION_PATCH 20190211) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 9102e3e..c1b6eea 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -85,8 +85,8 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl @@ -198,8 +198,8 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 398ebd3..f522ce2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -61,9 +61,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) std::string output; int returnValue = 0; - bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, - &output, &returnValue, 0, - cmSystemTools::OUTPUT_NONE); + bool status = cmSystemTools::RunSingleCommand( + command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE); cmsys::ofstream logFile(logFileName.c_str(), std::ios::app); logFile << command << std::endl; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 013ad81..7a3742b 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -244,8 +244,8 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, int exit_code = 1; bool result = cmSystemTools::RunSingleCommand( - command.str().c_str(), output, output, &exit_code, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!result || exit_code) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 57c0545..b4c05ab 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -278,7 +278,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( std::string output; int retVal = 1; bool resB = cmSystemTools::RunSingleCommand( - ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); @@ -647,8 +647,8 @@ int cmCPackGenerator::RunPreinstallTarget( std::string output; int retVal = 1; bool resB = cmSystemTools::RunSingleCommand( - buildCommand.c_str(), &output, &output, &retVal, - installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero()); + buildCommand, &output, &output, &retVal, installDirectory.c_str(), + this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 37ea66e..c77eebc 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -302,8 +302,8 @@ int cmCPackNSISGenerator::PackageFiles() std::string output; int retVal = 1; bool res = cmSystemTools::RunSingleCommand( - nsisCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << nsisCmd << std::endl @@ -407,8 +407,8 @@ int cmCPackNSISGenerator::InitializeInternal() std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand( - nsisCmd.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs"); if (!resS || retVal || @@ -749,7 +749,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( std::string output; int retVal = -1; int res = cmSystemTools::RunSingleCommand( - cmd.c_str(), &output, &output, &retVal, dirName.c_str(), + cmd, &output, &output, &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, cmDuration::zero()); if (!res || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 486633c..85248c6 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -155,8 +155,8 @@ int cmCPackOSXX11Generator::PackageFiles() bool res = false; while (numTries > 0) { res = cmSystemTools::RunSingleCommand( - dmgCmd.str().c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (res && !retVal) { numTries = -1; break; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 246178d..3d93c48 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -295,8 +295,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() bool res = false; while (numTries > 0) { res = cmSystemTools::RunSingleCommand( - dmgCmd.str().c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); if (res && !retVal) { numTries = -1; break; diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index a556e0c..94b5b5f 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -145,8 +145,8 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command) std::string output; int retVal = 1; bool res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, nullptr, - this->GeneratorVerbose, cmDuration::zero()); + command, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl); if (!res || retVal) { cmGeneratedFileStream ofs(tmpFile); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 2fd4c7a..3856569 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -118,7 +118,7 @@ public: : CM(cm) { cmSystemTools::SetMessageCallback( - [&s](const char* msg, const char* /*unused*/) { + [&s](const std::string& msg, const char* /*unused*/) { s += msg; s += "\n"; }); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 6b57c43..2cbdc4e 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -607,9 +607,8 @@ int cmCTestScriptHandler::CheckOutSourceDir() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << this->CVSCheckOut << std::endl); res = cmSystemTools::RunSingleCommand( - this->CVSCheckOut.c_str(), &output, &output, &retVal, - this->CTestRoot.c_str(), this->HandlerVerbose, - cmDuration::zero() /*this->TimeOut*/); + this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(), + this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { cmSystemTools::Error("Unable to perform cvs checkout:\n", output.c_str()); @@ -675,7 +674,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " << fullCommand << std::endl); res = cmSystemTools::RunSingleCommand( - fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(), + fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(), @@ -779,7 +778,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command << std::endl); res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), + command, &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!this->CMOutFile.empty()) { @@ -818,7 +817,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command << std::endl); res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), + command, &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); // did something critical fail in ctest diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index cf2652a..c9783e4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1486,7 +1486,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) int retVal = 0; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << it << std::endl, this->Quiet); - if (!cmSystemTools::RunSingleCommand(it.c_str(), nullptr, nullptr, &retVal, + if (!cmSystemTools::RunSingleCommand(it, nullptr, nullptr, &retVal, nullptr, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0) { diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index f2982a6..745c6bb 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -150,7 +150,7 @@ int main(int argc, char const* const* argv) } cmSystemTools::SetMessageCallback( - [myform](const char* message, const char* title) { + [myform](const std::string& message, const char* title) { myform->AddError(message, title); }); diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h index ddb67de..7842905 100644 --- a/Source/CursesDialog/cmCursesForm.h +++ b/Source/CursesDialog/cmCursesForm.h @@ -9,6 +9,8 @@ #include "cmsys/FStream.hxx" +#include <string> + class cmCursesForm { public: @@ -34,7 +36,7 @@ public: // Description: // During a CMake run, an error handle should add errors // to be displayed afterwards. - virtual void AddError(const char*, const char*) {} + virtual void AddError(const std::string&, const char*) {} // Description: // Turn debugging on. This will create ccmakelog.txt. diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index b9a7c85..076ee3d 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -642,7 +642,8 @@ int cmCursesMainForm::Generate() return 0; } -void cmCursesMainForm::AddError(const char* message, const char* /*unused*/) +void cmCursesMainForm::AddError(const std::string& message, + const char* /*unused*/) { this->Errors.emplace_back(message); } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index cc6482f..c09ce2a 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -81,7 +81,7 @@ public: * During a CMake run, an error handle should add errors * to be displayed afterwards. */ - void AddError(const char* message, const char* title) override; + void AddError(const std::string& message, const char* title) override; /** * Used to do a configure. If argument is specified, it does only the check diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index bf7726e..c90c142 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -25,7 +25,7 @@ QCMake::QCMake(QObject* p) cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetMessageCallback( - [this](const char* msg, const char* title) { + [this](std::string const& msg, const char* title) { this->messageCallback(msg, title); }); cmSystemTools::SetStdoutCallback( @@ -356,9 +356,9 @@ void QCMake::progressCallback(const char* msg, float percent) QCoreApplication::processEvents(); } -void QCMake::messageCallback(const char* msg, const char* /*title*/) +void QCMake::messageCallback(std::string const& msg, const char* /*title*/) { - emit this->errorMessage(QString::fromLocal8Bit(msg)); + emit this->errorMessage(QString::fromStdString(msg)); QCoreApplication::processEvents(); } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index ef4d2a1..8492606 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -169,7 +169,7 @@ protected: bool interruptCallback(); void progressCallback(const char* msg, float percent); - void messageCallback(const char* msg, const char* title); + void messageCallback(std::string const& msg, const char* title); void stdoutCallback(std::string const& msg); void stderrCallback(std::string const& msg); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 345ecaa..9e90547 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -247,8 +247,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - const std::string makeArgs = + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& makeArgs = mf->GetSafeDefinition("CMAKE_CODEBLOCKS_MAKE_ARGUMENTS"); cmXMLWriter xml(fout); diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 0773edc..6fe8c14 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -628,8 +628,8 @@ std::string cmExtraCodeLiteGenerator::GetConfigurationName( std::string cmExtraCodeLiteGenerator::GetBuildCommand( const cmMakefile* mf, const std::string& targetName) const { - std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string buildCommand = make; // Default std::ostringstream ss; if (generator == "NMake Makefiles" || generator == "Ninja") { @@ -669,8 +669,8 @@ std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand( const cmMakefile* mf) const { std::string buildCommand; - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); if (generator == "Unix Makefiles" || generator == "MinGW Makefiles") { std::ostringstream ss; #if defined(_WIN32) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 30067b7..a6ce8b7 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -878,8 +878,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets"); xml.StartElement("buildTargets"); emmited.clear(); - const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - const std::string makeArgs = + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& makeArgs = mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS"); cmGlobalGenerator* generator = @@ -1074,7 +1074,8 @@ void cmExtraEclipseCDT4Generator::AppendStorageScanners( cmXMLWriter& xml, const cmMakefile& makefile) { // we need the "make" and the C (or C++) compiler which are used, Alex - std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& make = + makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER"); std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1"); if (compiler.empty()) { diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 23ba6b7..76de75d 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -75,8 +75,8 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, cmGeneratedFileStream& fout) const { cmMakefile const* mf = lg->GetMakefile(); - const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - const std::string makeArgs = + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& makeArgs = mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); std::string const& homeOutputDir = lg->GetBinaryDirectory(); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 739a177..59cfdca 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -168,7 +168,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( const std::vector<cmLocalGenerator*>& lgs, const cmMakefile* mf, cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags) { - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler; if (!lgs.empty()) { this->AppendTarget(fout, "all", lgs[0], nullptr, make.c_str(), mf, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 3562e7e..08441a8 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -447,7 +447,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) cmSystemTools::IsOn( this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) || cmSystemTools::IsOn( - this->Makefile->GetDefinition("GHS_NO_SOURCE_GROUP_FILE")); + this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE")); if (useProjectFile || sg.empty()) { fout = &fout_proj; } else { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e56dc4c..8e7ca12 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -682,8 +682,9 @@ void cmGlobalGenerator::EnableLanguage( std::string compilerEnv = "CMAKE_"; compilerEnv += lang; compilerEnv += "_COMPILER_ENV_VAR"; - std::string envVar = mf->GetRequiredDefinition(compilerEnv); - std::string envVarValue = mf->GetRequiredDefinition(compilerName); + const std::string& envVar = mf->GetRequiredDefinition(compilerEnv); + const std::string& envVarValue = + mf->GetRequiredDefinition(compilerName); std::string env = envVar; env += "="; env += envVarValue; diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 3c24556..606febe 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -45,7 +45,8 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage( std::vector<std::string> const& l, cmMakefile* mf, bool optional) { this->FindMakeProgram(mf); - std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& makeProgram = + mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> locations; std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str()); locations.push_back(this->FindMinGW(makeloc)); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index c6d46e9..e218b4b 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -23,7 +23,8 @@ void cmGlobalMinGWMakefileGenerator::EnableLanguage( std::vector<std::string> const& l, cmMakefile* mf, bool optional) { this->FindMakeProgram(mf); - std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string& makeProgram = + mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> locations; locations.push_back(cmSystemTools::GetProgramPath(makeProgram)); locations.push_back("/mingw/bin"); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 59701a1..5cee9d3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -825,7 +825,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent indent, return; } - std::string ranlib = + const std::string& ranlib = this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB"); if (ranlib.empty()) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 938098d..ba3c574 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1364,9 +1364,9 @@ void cmLocalGenerator::OutputLinkLibraries( std::string linkLanguage = cli.GetLinkLanguage(); - std::string libPathFlag = + const std::string& libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = + const std::string& libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Add standard libraries for this language. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7c67192..b809be4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -927,7 +927,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags( std::string extraLinkOptionsBuildTypeDef = rootLinkerFlags + "_" + configTypeUpper; - std::string extraLinkOptionsBuildType = + const std::string& extraLinkOptionsBuildType = this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef); return extraLinkOptionsBuildType; @@ -943,21 +943,18 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( std::string extraLinkOptions; if (target->GetType() == cmStateEnums::EXECUTABLE) { extraLinkOptions = - this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + - std::string(" ") + + this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + " " + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName); } if (target->GetType() == cmStateEnums::SHARED_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") + - std::string(" ") + - GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); + " " + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); } if (target->GetType() == cmStateEnums::MODULE_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") + - std::string(" ") + - GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName); + " " + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName); } const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3d22f57..f246da2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1984,7 +1984,9 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, // over changes in CMakeLists.txt, making the information stale and // hence useless. target->ClearDependencyInformation(*this); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (excludeFromAll || + (type != cmStateEnums::INTERFACE_LIBRARY && + this->GetPropertyAsBool("EXCLUDE_FROM_ALL"))) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -2424,16 +2426,18 @@ bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const cmSystemTools::SameFile(fileName, this->GetHomeOutputDirectory()); } -std::string cmMakefile::GetRequiredDefinition(const std::string& name) const +const std::string& cmMakefile::GetRequiredDefinition( + const std::string& name) const { - const char* ret = this->GetDefinition(name); - if (!ret) { + static std::string const empty; + const std::string* def = GetDef(name); + if (!def) { cmSystemTools::Error("Error required internal CMake variable not " "set, cmake may not be built correctly.\n", "Missing variable is:\n", name.c_str()); - return std::string(); + return empty; } - return std::string(ret); + return *def; } bool cmMakefile::IsDefinitionSet(const std::string& name) const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 70a5689..fce90f2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -436,7 +436,7 @@ public: const char* GetDefinition(const std::string&) const; const std::string* GetDef(const std::string&) const; const std::string& GetSafeDefinition(const std::string&) const; - std::string GetRequiredDefinition(const std::string& name) const; + const std::string& GetRequiredDefinition(const std::string& name) const; bool IsDefinitionSet(const std::string&) const; /** * Get the list of all variables in the current space. If argument diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 9372ed5..cb595fd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -654,19 +654,20 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string cmdVar; if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"; } else if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_PTX_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION"; } else { - cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"; } - std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar); + const std::string& compileRule = + this->Makefile->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileRule, compileCommands); } else { - const std::string cmdVar = - std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; - std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar); + const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT"; + const std::string& compileRule = + this->Makefile->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileRule, compileCommands); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5d76dc2..b525dac 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -493,7 +493,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) if (explicitPP) { // Lookup the explicit preprocessing rule. std::string const ppVar = "CMAKE_" + lang + "_PREPROCESS_SOURCE"; - std::string const ppCmd = + std::string const& ppCmd = this->GetMakefile()->GetRequiredDefinition(ppVar); // Explicit preprocessing always uses a depfile. @@ -671,19 +671,18 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) std::string cmdVar; if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"; } else if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_PTX_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION"; } else { - cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"; } - std::string compileCmd = mf->GetRequiredDefinition(cmdVar); + const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileCmd, compileCmds); } else { - const std::string cmdVar = - std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; - std::string compileCmd = mf->GetRequiredDefinition(cmdVar); + const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT"; + const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileCmd, compileCmds); } @@ -1213,20 +1212,19 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( std::string cmdVar; if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"; } else if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_PTX_COMPILATION")) { - cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION"; } else { - cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); + cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"; } - std::string compileCmd = + const std::string& compileCmd = this->GetMakefile()->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileCmd, compileCmds); } else { - const std::string cmdVar = - std::string("CMAKE_") + language + "_COMPILE_OBJECT"; - std::string compileCmd = + const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT"; + const std::string& compileCmd = this->GetMakefile()->GetRequiredDefinition(cmdVar); cmSystemTools::ExpandListArgument(compileCmd, compileCmds); } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 796974c..6231aab 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -14,7 +14,7 @@ class cmExecutionStatus; -static std::string escape_arg(const std::string& arg) +static std::string EscapeArg(const std::string& arg) { // replace ";" with "\;" so output argument lists will split correctly std::string escapedArg; @@ -27,6 +27,81 @@ static std::string escape_arg(const std::string& arg) return escapedArg; } +namespace { +enum insideValues +{ + NONE, + SINGLE, + MULTI +}; + +typedef std::map<std::string, bool> options_map; +typedef std::map<std::string, std::string> single_map; +typedef std::map<std::string, std::vector<std::string>> multi_map; +typedef std::set<std::string> options_set; +} + +// function to be called every time, a new key word was parsed or all +// parameters where parsed. +static void DetectKeywordsMissingValues(insideValues currentState, + const std::string& currentArgName, + int& argumentsFound, + options_set& keywordsMissingValues) +{ + if (currentState == SINGLE || + (currentState == MULTI && argumentsFound == 0)) { + keywordsMissingValues.insert(currentArgName); + } + + argumentsFound = 0; +} + +static void PassParsedArguments(const std::string& prefix, + cmMakefile& makefile, + const options_map& options, + const single_map& singleValArgs, + const multi_map& multiValArgs, + const std::vector<std::string>& unparsed, + const options_set& keywordsMissingValues) +{ + for (auto const& iter : options) { + makefile.AddDefinition(prefix + iter.first, + iter.second ? "TRUE" : "FALSE"); + } + + for (auto const& iter : singleValArgs) { + if (!iter.second.empty()) { + makefile.AddDefinition(prefix + iter.first, iter.second.c_str()); + } else { + makefile.RemoveDefinition(prefix + iter.first); + } + } + + for (auto const& iter : multiValArgs) { + if (!iter.second.empty()) { + makefile.AddDefinition(prefix + iter.first, + cmJoin(cmMakeRange(iter.second), ";").c_str()); + } else { + makefile.RemoveDefinition(prefix + iter.first); + } + } + + if (!unparsed.empty()) { + makefile.AddDefinition(prefix + "UNPARSED_ARGUMENTS", + cmJoin(cmMakeRange(unparsed), ";").c_str()); + } else { + makefile.RemoveDefinition(prefix + "UNPARSED_ARGUMENTS"); + } + + if (!keywordsMissingValues.empty()) { + makefile.AddDefinition( + prefix + "KEYWORDS_MISSING_VALUES", + cmJoin(cmMakeRange(keywordsMissingValues), ";").c_str()); + } else { + makefile.RemoveDefinition(prefix + "KEYWORDS_MISSING_VALUES"); + } +} + bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { @@ -67,9 +142,6 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, // define the result maps holding key/value pairs for // options, single values and multi values - typedef std::map<std::string, bool> options_map; - typedef std::map<std::string, std::string> single_map; - typedef std::map<std::string, std::vector<std::string>> multi_map; options_map options; single_map singleValArgs; multi_map multiValArgs; @@ -114,12 +186,7 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, multiValArgs[iter]; // default initialize } - enum insideValues - { - NONE, - SINGLE, - MULTI - } insideValues = NONE; + insideValues insideValues = NONE; std::string currentArgName; list.clear(); @@ -155,10 +222,15 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, } } + options_set keywordsMissingValues; + int multiArgumentsFound = 0; + // iterate over the arguments list and fill in the values where applicable for (std::string const& arg : list) { const options_map::iterator optIter = options.find(arg); if (optIter != options.end()) { + DetectKeywordsMissingValues(insideValues, currentArgName, + multiArgumentsFound, keywordsMissingValues); insideValues = NONE; optIter->second = true; continue; @@ -166,6 +238,8 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, const single_map::iterator singleIter = singleValArgs.find(arg); if (singleIter != singleValArgs.end()) { + DetectKeywordsMissingValues(insideValues, currentArgName, + multiArgumentsFound, keywordsMissingValues); insideValues = SINGLE; currentArgName = arg; continue; @@ -173,6 +247,8 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, const multi_map::iterator multiIter = multiValArgs.find(arg); if (multiIter != multiValArgs.end()) { + DetectKeywordsMissingValues(insideValues, currentArgName, + multiArgumentsFound, keywordsMissingValues); insideValues = MULTI; currentArgName = arg; continue; @@ -184,15 +260,18 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, insideValues = NONE; break; case MULTI: + ++multiArgumentsFound; if (parseFromArgV) { - multiValArgs[currentArgName].push_back(escape_arg(arg)); + multiValArgs[currentArgName].push_back(EscapeArg(arg)); } else { multiValArgs[currentArgName].push_back(arg); } break; default: + multiArgumentsFound = 0; + if (parseFromArgV) { - unparsed.push_back(escape_arg(arg)); + unparsed.push_back(EscapeArg(arg)); } else { unparsed.push_back(arg); } @@ -200,36 +279,11 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args, } } - // now iterate over the collected values and update their definition - // within the current scope. undefine if necessary. - - for (auto const& iter : options) { - this->Makefile->AddDefinition(prefix + iter.first, - iter.second ? "TRUE" : "FALSE"); - } - for (auto const& iter : singleValArgs) { - if (!iter.second.empty()) { - this->Makefile->AddDefinition(prefix + iter.first, iter.second.c_str()); - } else { - this->Makefile->RemoveDefinition(prefix + iter.first); - } - } - - for (auto const& iter : multiValArgs) { - if (!iter.second.empty()) { - this->Makefile->AddDefinition( - prefix + iter.first, cmJoin(cmMakeRange(iter.second), ";").c_str()); - } else { - this->Makefile->RemoveDefinition(prefix + iter.first); - } - } + DetectKeywordsMissingValues(insideValues, currentArgName, + multiArgumentsFound, keywordsMissingValues); - if (!unparsed.empty()) { - this->Makefile->AddDefinition(prefix + "UNPARSED_ARGUMENTS", - cmJoin(cmMakeRange(unparsed), ";").c_str()); - } else { - this->Makefile->RemoveDefinition(prefix + "UNPARSED_ARGUMENTS"); - } + PassParsedArguments(prefix, *this->Makefile, options, singleValArgs, + multiValArgs, unparsed, keywordsMissingValues); return true; } diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index e740c05..719e6b1 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -97,7 +97,7 @@ void cmServer::ProcessRequest(cmConnection* connection, } cmSystemTools::SetMessageCallback( - [&request](const char* msg, const char* title) { + [&request](const std::string& msg, const char* title) { reportMessage(msg, title, request); }); @@ -165,15 +165,14 @@ void cmServer::reportProgress(const char* msg, float progress, } } -void cmServer::reportMessage(const char* msg, const char* title, +void cmServer::reportMessage(const std::string& msg, const char* title, const cmServerRequest& request) { - assert(msg); std::string titleString; if (title) { titleString = title; } - request.ReportMessage(std::string(msg), titleString); + request.ReportMessage(msg, titleString); } cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) diff --git a/Source/cmServer.h b/Source/cmServer.h index e1ed27a..3edc887 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -121,7 +121,7 @@ public: private: static void reportProgress(const char* msg, float progress, const cmServerRequest& request); - static void reportMessage(const char* msg, const char* title, + static void reportMessage(const std::string& msg, const char* title, const cmServerRequest& request); // Handle requests: diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 01758ee..9f041bc 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -52,9 +52,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args, // try to find the hostname for this computer if (!cmSystemTools::IsOff(hostname_cmd)) { std::string host; - cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, nullptr, - nullptr, nullptr, - cmSystemTools::OUTPUT_NONE); + cmSystemTools::RunSingleCommand(hostname_cmd, &host, nullptr, nullptr, + nullptr, cmSystemTools::OUTPUT_NONE); // got the hostname if (!host.empty()) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index aa4e3f9..2d7bce4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -323,16 +323,16 @@ void cmSystemTools::Stdout(const std::string& s) } } -void cmSystemTools::Message(const char* m1, const char* title) +void cmSystemTools::Message(const std::string& m, const char* title) { if (s_DisableMessages) { return; } if (s_MessageCallback) { - s_MessageCallback(m1, title); + s_MessageCallback(m, title); return; } - std::cerr << m1 << std::endl << std::flush; + std::cerr << m << std::endl << std::flush; } void cmSystemTools::ReportLastSystemError(const char* msg) @@ -866,7 +866,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, return result; } -bool cmSystemTools::RunSingleCommand(const char* command, +bool cmSystemTools::RunSingleCommand(const std::string& command, std::string* captureStdOut, std::string* captureStdErr, int* retVal, const char* dir, OutputOption outputflag, @@ -876,7 +876,8 @@ bool cmSystemTools::RunSingleCommand(const char* command, outputflag = OUTPUT_NONE; } - std::vector<std::string> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = + cmSystemTools::ParseArguments(command.c_str()); if (args.empty()) { return false; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 0f92fe2..88758a6 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -56,7 +56,7 @@ public: */ static std::string TrimWhitespace(const std::string& s); - using MessageCallback = std::function<void(const char*, const char*)>; + using MessageCallback = std::function<void(const std::string&, const char*)>; /** * Set the function used by GUIs to display error messages * Function gets passed: message as a const char*, @@ -74,11 +74,7 @@ public: /** * Display a message. */ - static void Message(const char* m, const char* title = nullptr); - static void Message(const std::string& m, const char* title = nullptr) - { - Message(m.c_str(), title); - } + static void Message(const std::string& m, const char* title = nullptr); using OutputCallback = std::function<void(std::string const&)>; @@ -224,7 +220,7 @@ public: OUTPUT_FORWARD, OUTPUT_PASSTHROUGH }; - static bool RunSingleCommand(const char* command, + static bool RunSingleCommand(const std::string& command, std::string* captureStdOut = nullptr, std::string* captureStdErr = nullptr, int* retVal = nullptr, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 0f7323d..d863339 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -188,8 +188,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, finalCommand += runArgs; } bool worked = cmSystemTools::RunSingleCommand( - finalCommand.c_str(), out, out, &retVal, nullptr, - cmSystemTools::OUTPUT_NONE, cmDuration::zero()); + finalCommand, out, out, &retVal, nullptr, cmSystemTools::OUTPUT_NONE, + cmDuration::zero()); // set the run var char retChar[16]; const char* retStr; diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 231bca4..b59a587 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -79,7 +79,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, } // The source exists. - std::string cmakeCFGout = + const std::string& cmakeCFGout = this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR"); std::string utilityDirectory = this->Makefile->GetCurrentBinaryDirectory(); std::string exePath; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 890b74e..a49246b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -142,8 +142,8 @@ static std::string cmakemainGetStack(cmake* cm) return msg; } -static void cmakemainMessageCallback(const char* m, const char* /*unused*/, - cmake* cm) +static void cmakemainMessageCallback(const std::string& m, + const char* /*unused*/, cmake* cm) { std::cerr << m << cmakemainGetStack(cm) << std::endl << std::flush; } @@ -319,9 +319,10 @@ int do_cmake(int ac, char const* const* av) cmake cm(role, mode); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); - cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { - cmakemainMessageCallback(msg, title, &cm); - }); + cmSystemTools::SetMessageCallback( + [&cm](const std::string& msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); cm.SetProgressCallback([&cm](const char* msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); @@ -499,9 +500,10 @@ static int do_build(int ac, char const* const* av) } cmake cm(cmake::RoleInternal, cmState::Unknown); - cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { - cmakemainMessageCallback(msg, title, &cm); - }); + cmSystemTools::SetMessageCallback( + [&cm](const std::string& msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); cm.SetProgressCallback([&cm](const char* msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); @@ -541,9 +543,10 @@ static int do_open(int ac, char const* const* av) } cmake cm(cmake::RoleInternal, cmState::Unknown); - cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { - cmakemainMessageCallback(msg, title, &cm); - }); + cmSystemTools::SetMessageCallback( + [&cm](const std::string& msg, const char* title) { + cmakemainMessageCallback(msg, title, &cm); + }); cm.SetProgressCallback([&cm](const char* msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index d20c5d2..4415ba6 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -826,7 +826,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) cmWrap('"', cmMakeRange(args).advance(3), '"', " "); int retval = 0; if (cmSystemTools::RunSingleCommand( - command.c_str(), nullptr, nullptr, &retval, directory.c_str(), + command, nullptr, nullptr, &retval, directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, cmDuration::zero())) { return retval; } |