Commit 3020354f authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'string-cleanup'

23e8364a Source: std::string related cleanup
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Sebastian Holtermann's avatarSebastian Holtermann <sebholt@web.de>
Merge-request: !3324
parents 736f9d18 23e8364a
......@@ -122,8 +122,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
}
const char* sourceDirectory = argv[2].c_str();
const char* projectName = nullptr;
std::string sourceDirectory = argv[2];
std::string projectName;
std::string targetName;
std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0]
std::vector<std::string> compileDefs;
......@@ -309,7 +309,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
doing = DoingNone;
} else if (i == 3) {
this->SrcFileSignature = false;
projectName = argv[i].c_str();
projectName = argv[i];
} else if (i == 4 && !this->SrcFileSignature) {
targetName = argv[i];
} else {
......@@ -480,7 +480,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// we need to create a directory and CMakeLists file etc...
// first create the directories
sourceDirectory = this->BinaryDirectory.c_str();
sourceDirectory = this->BinaryDirectory;
// now create a CMakeLists.txt file in that directory
FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w");
......@@ -950,7 +950,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
<< " '" << copyFile << "'\n";
/* clang-format on */
if (!this->FindErrorMessage.empty()) {
emsg << this->FindErrorMessage.c_str();
emsg << this->FindErrorMessage;
}
if (copyFileError.empty()) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, emsg.str());
......
......@@ -280,8 +280,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
xml.StartElement("Build");
this->AppendTarget(xml, "all", nullptr, make.c_str(), lgs[0],
compiler.c_str(), makeArgs);
this->AppendTarget(xml, "all", nullptr, make, lgs[0], compiler, makeArgs);
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
......@@ -294,8 +293,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg,
compiler.c_str(), makeArgs);
this->AppendTarget(xml, targetName, nullptr, make, lg, compiler,
makeArgs);
}
} break;
case cmStateEnums::UTILITY:
......@@ -310,8 +309,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
break;
}
this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg,
compiler.c_str(), makeArgs);
this->AppendTarget(xml, targetName, nullptr, make, lg, compiler,
makeArgs);
break;
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
......@@ -319,12 +318,12 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
cmGeneratorTarget* gt = target;
this->AppendTarget(xml, targetName, gt, make.c_str(), lg,
compiler.c_str(), makeArgs);
this->AppendTarget(xml, targetName, gt, make, lg, compiler,
makeArgs);
std::string fastTarget = targetName;
fastTarget += "/fast";
this->AppendTarget(xml, fastTarget, gt, make.c_str(), lg,
compiler.c_str(), makeArgs);
this->AppendTarget(xml, fastTarget, gt, make, lg, compiler,
makeArgs);
} break;
default:
break;
......@@ -378,7 +377,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
std::string const& fullPath = s->GetFullPath();
// Check file position relative to project root dir.
const std::string& relative =
const std::string relative =
cmSystemTools::RelativePath(lg->GetSourceDirectory(), fullPath);
// Do not add this file if it has ".." in relative path and
// if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on.
......@@ -454,7 +453,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
}
// Add CMakeLists.txt
tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/");
tree.BuildUnit(xml, mf->GetHomeDirectory() + "/");
xml.EndElement(); // Project
xml.EndElement(); // CodeBlocks_project_file
......@@ -489,8 +488,8 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(
cmXMLWriter& xml, const std::string& targetName, cmGeneratorTarget* target,
const char* make, const cmLocalGenerator* lg, const char* compiler,
const std::string& makeFlags)
const std::string& make, const cmLocalGenerator* lg,
const std::string& compiler, const std::string& makeFlags)
{
cmMakefile const* makefile = lg->GetMakefile();
std::string makefileName = lg->GetCurrentBinaryDirectory();
......@@ -613,25 +612,23 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
xml.StartElement("Build");
xml.Attribute(
"command",
this->BuildMakeCommand(make, makefileName.c_str(), targetName, makeFlags));
this->BuildMakeCommand(make, makefileName, targetName, makeFlags));
xml.EndElement();
xml.StartElement("CompileFile");
xml.Attribute("command",
this->BuildMakeCommand(make, makefileName.c_str(), "\"$file\"",
makeFlags));
xml.Attribute(
"command",
this->BuildMakeCommand(make, makefileName, "\"$file\"", makeFlags));
xml.EndElement();
xml.StartElement("Clean");
xml.Attribute(
"command",
this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
"command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags));
xml.EndElement();
xml.StartElement("DistClean");
xml.Attribute(
"command",
this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags));
"command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags));
xml.EndElement();
xml.EndElement(); // MakeCommands
......@@ -725,8 +722,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
// Create the command line for building the given target using the selected
// make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
const std::string& make, const char* makefile, const std::string& target,
const std::string& makeFlags)
const std::string& make, const std::string& makefile,
const std::string& target, const std::string& makeFlags)
{
std::string command = make;
if (!makeFlags.empty()) {
......@@ -747,7 +744,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
} else if (generator == "MinGW Makefiles") {
// no escaping of spaces in this case, see
// https://gitlab.kitware.com/cmake/cmake/issues/10014
std::string makefileName = makefile;
std::string const& makefileName = makefile;
command += " -f \"";
command += makefileName;
command += "\" ";
......
......@@ -42,12 +42,13 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmGeneratorTarget* target);
std::string BuildMakeCommand(const std::string& make, const char* makefile,
std::string BuildMakeCommand(const std::string& make,
const std::string& makefile,
const std::string& target,
const std::string& makeFlags);
void AppendTarget(cmXMLWriter& xml, const std::string& targetName,
cmGeneratorTarget* target, const char* make,
const cmLocalGenerator* lg, const char* compiler,
cmGeneratorTarget* target, const std::string& make,
const cmLocalGenerator* lg, const std::string& compiler,
const std::string& makeFlags);
};
......
......@@ -48,7 +48,7 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
const std::string& makeProgram =
mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> locations;
std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
std::string makeloc = cmSystemTools::GetProgramPath(makeProgram);
locations.push_back(this->FindMinGW(makeloc));
locations.push_back(makeloc);
locations.push_back("/mingw/bin");
......@@ -77,8 +77,8 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
!(1 == l.size() && l[0] == "NONE")) {
cmSystemTools::Error(
"CMAKE_AR was not found, please set to archive program. ",
mf->GetDefinition("CMAKE_AR"));
"CMAKE_AR was not found, please set to archive program. " +
mf->GetSafeDefinition("CMAKE_AR"));
}
}
......
......@@ -574,7 +574,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
static std::string const k_DYNDEP_ = ".dyndep-";
std::string::size_type pos = this->NinjaVersion.find(k_DYNDEP_);
if (pos != std::string::npos) {
const char* fv = this->NinjaVersion.c_str() + pos + k_DYNDEP_.size();
const char* fv = &this->NinjaVersion[pos + k_DYNDEP_.size()];
cmSystemTools::StringToULong(fv, &this->NinjaSupportsDyndeps);
}
}
......@@ -1254,7 +1254,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
for (std::string const& i : unknownExplicitDepends) {
// verify the file is in the build directory
std::string const absDepPath =
cmSystemTools::CollapseFullPath(i, rootBuildDirectory.c_str());
cmSystemTools::CollapseFullPath(i, rootBuildDirectory);
bool const inBuildDir =
cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory);
if (inBuildDir) {
......
......@@ -169,7 +169,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
{
if (this->CommandDatabase == nullptr) {
std::string commandDatabaseName =
std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
this->GetCMakeInstance()->GetHomeOutputDirectory() +
"/compile_commands.json";
this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName);
*this->CommandDatabase << "[" << std::endl;
......
......@@ -45,7 +45,6 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
cmake* cm, std::string const& platformInGeneratorName)
: cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
{
this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
this->MasmEnabled = false;
this->NasmEnabled = false;
......@@ -54,21 +53,20 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
{
free(this->IntelProjectVersion);
}
// Package GUID of Intel Visual Fortran plugin to VS IDE
#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
const std::string& cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
{
if (!this->IntelProjectVersion) {
if (this->IntelProjectVersion.empty()) {
// Compute the version of the Intel plugin to the VS IDE.
// If the key does not exist then use a default guess.
std::string intelVersion;
std::string vskey = this->GetRegistryBase();
vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
cmSystemTools::ReadRegistryValue(vskey, intelVersion,
cmSystemTools::KeyWOW64_32);
unsigned int intelVersionNumber = ~0u;
sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
......@@ -81,7 +79,7 @@ const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
} else {
// Version <= 9: use ProductVersion from registry.
}
this->IntelProjectVersion = strdup(intelVersion.c_str());
this->IntelProjectVersion = intelVersion;
}
return this->IntelProjectVersion;
}
......@@ -237,7 +235,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand(
GeneratedMakeCommand makeCommand;
makeCommand.RequiresOutputForward = requiresOutputForward;
makeCommand.Add(makeProgramSelected);
makeCommand.Add(std::string(projectName) + ".sln");
makeCommand.Add(projectName + ".sln");
makeCommand.Add((clean ? "/clean" : "/build"));
makeCommand.Add((config.empty() ? "Debug" : config));
makeCommand.Add("/project");
......@@ -270,7 +268,7 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
cmMakefile* mf)
{
mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION",
this->GetIntelProjectVersion());
this->GetIntelProjectVersion().c_str());
return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf);
}
......@@ -615,7 +613,7 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
{
std::string const& guidStoreName = name + "_GUID_CMAKE";
if (const char* storedGUID =
this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) {
this->CMakeInstance->GetCacheDefinition(guidStoreName)) {
return std::string(storedGUID);
}
// Compute a GUID that is deterministic but unique to the build tree.
......
......@@ -86,7 +86,7 @@ public:
return false;
}
const char* GetIntelProjectVersion();
const std::string& GetIntelProjectVersion();
bool FindMakeProgram(cmMakefile* mf) override;
......@@ -163,7 +163,7 @@ protected:
bool NasmEnabled;
private:
char* IntelProjectVersion;
std::string IntelProjectVersion;
std::string DevEnvCommand;
bool DevEnvCommandInitialized;
std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
......
......@@ -188,8 +188,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
commandLine.push_back("--check-stamp-list");
commandLine.push_back(stampList.c_str());
commandLine.push_back("--vs-solution-file");
std::string const sln = std::string(lg->GetBinaryDirectory()) + "/" +
lg->GetProjectName() + ".sln";
std::string const sln =
lg->GetBinaryDirectory() + "/" + lg->GetProjectName() + ".sln";
commandLine.push_back(sln);
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
......
......@@ -202,7 +202,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
}
}
}
if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) {
if (!versionFile.empty() && cmSystemTools::FileExists(versionFile)) {
parser.ParseFile(versionFile.c_str());
} else if (cmSystemTools::FileExists(
"/Applications/Xcode.app/Contents/version.plist")) {
......@@ -479,7 +479,7 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
this->CurrentXCodeHackMakefile = root->GetCurrentBinaryDirectory();
this->CurrentXCodeHackMakefile += "/CMakeScripts";
cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str());
cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile);
this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make";
}
......@@ -600,7 +600,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
this->CurrentReRunCMakeMakefile = root->GetCurrentBinaryDirectory();
this->CurrentReRunCMakeMakefile += "/CMakeScripts";
cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str());
cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile);
this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile);
makefileStream.SetCopyIfDifferent(true);
......@@ -1026,8 +1026,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
std::string path = this->RelativeToSource(fullpath);
std::string name = cmSystemTools::GetFilenameName(path);
const char* sourceTree =
(cmSystemTools::FileIsFullPath(path.c_str()) ? "<absolute>"
: "SOURCE_ROOT");
cmSystemTools::FileIsFullPath(path) ? "<absolute>" : "SOURCE_ROOT";
fileRef->AddAttribute("name", this->CreateString(name));
fileRef->AddAttribute("path", this->CreateString(path));
fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
......@@ -1588,7 +1587,7 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
std::string::size_type offset = 0;
while (regex.find(flags.c_str() + offset)) {
while (regex.find(&flags[offset])) {
const std::string::size_type startPos = offset + regex.start(matchIndex);
const std::string::size_type endPos = offset + regex.end(matchIndex);
const std::string::size_type size = endPos - startPos;
......@@ -1641,7 +1640,7 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
{
std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
dir += "/CMakeScripts";
cmSystemTools::MakeDirectory(dir.c_str());
cmSystemTools::MakeDirectory(dir);
std::string makefile = dir;
makefile += "/";
makefile += target->GetName();
......@@ -1700,7 +1699,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
} else {
std::ostringstream str;
str << "_buildpart_" << count++;
tname[&ccg.GetCC()] = std::string(target->GetName()) + str.str();
tname[&ccg.GetCC()] = target->GetName() + str.str();
makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
}
}
......@@ -1824,8 +1823,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string llang = gtgt->GetLinkerLanguage(configName);
if (binary && llang.empty()) {
cmSystemTools::Error(
"CMake can not determine linker language for target: ",
gtgt->GetName().c_str());
"CMake can not determine linker language for target: " +
gtgt->GetName());
return;
}
std::string const& langForPreprocessor = llang;
......@@ -3014,10 +3013,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (auto& CurrentConfigurationType : this->CurrentConfigurationTypes) {
for (const std::string& CurrentConfigurationType :
this->CurrentConfigurationTypes) {
cmXCodeObject* buildStyle =
this->CreateObject(cmXCodeObject::PBXBuildStyle);
const char* name = CurrentConfigurationType.c_str();
const std::string& name = CurrentConfigurationType;
buildStyle->AddAttribute("name", this->CreateString(name));
buildStyle->SetComment(name);
cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
......@@ -3263,8 +3263,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
{
cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile);
if (!makefileStream) {
cmSystemTools::Error("Could not create",
this->CurrentXCodeHackMakefile.c_str());
cmSystemTools::Error("Could not create " + this->CurrentXCodeHackMakefile);
return;
}
makefileStream.SetCopyIfDifferent(true);
......@@ -3401,7 +3400,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
xcodeDir += "/";
xcodeDir += root->GetProjectName();
xcodeDir += ".xcodeproj";
cmSystemTools::MakeDirectory(xcodeDir.c_str());
cmSystemTools::MakeDirectory(xcodeDir);
std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
cmGeneratedFileStream fout(xcodeProjFile);
fout.SetCopyIfDifferent(true);
......
......@@ -70,7 +70,7 @@ void cmLocalNinjaGenerator::Generate()
this->WritePools(this->GetRulesFileStream());
const std::string showIncludesPrefix =
const std::string& showIncludesPrefix =
this->GetMakefile()->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
if (!showIncludesPrefix.empty()) {
cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(),
......
......@@ -108,7 +108,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Get the language to use for linking this library.
std::string linkLanguage = "CUDA";
std::string const objExt =
std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
// Build list of dependencies.
......
......@@ -1430,7 +1430,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends(
}
// Loop over all library dependencies.
const char* cfg = this->LocalGenerator->GetConfigName().c_str();
const std::string& cfg = this->LocalGenerator->GetConfigName();
if (cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(cfg)) {
std::vector<std::string> const& libDeps = cli->GetDepends();
......@@ -1635,7 +1635,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
{
std::string frameworkPath;
std::string linkPath;
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli =
this->GeneratorTarget->GetLinkInformation(config);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
......
......@@ -605,7 +605,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
// First and very important step is to make sure while inside this
// step our link language is set to CUDA
std::string cudaLinkLanguage = "CUDA";
std::string const objExt =
std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
std::string const cfgName = this->GetConfigName();
......
......@@ -813,7 +813,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
<< cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
<< " target " << this->GetTargetName() << "\n\n";
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands, config);
for (cmSourceFile const* sf : customCommands) {
......@@ -1093,7 +1094,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
if (compilePP) {
// In case compilation requires flags that are incompatible with
// preprocessing, include them here.
std::string const postFlag = this->Makefile->GetSafeDefinition(
std::string const& postFlag = this->Makefile->GetSafeDefinition(
"CMAKE_" + language + "_POSTPROCESS_FLAG");
this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
}
......@@ -1342,8 +1343,7 @@ void cmNinjaTargetGenerator::EnsureDirectoryExists(
cmSystemTools::MakeDirectory(path);
} else {
cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
std::string fullPath =
std::string(gg->GetCMakeInstance()->GetHomeOutputDirectory());
std::string fullPath = gg->GetCMakeInstance()->GetHomeOutputDirectory();
// Also ensures their is a trailing slash.
gg->StripNinjaOutputPathPrefixAsSuffix(fullPath);
fullPath += path;
......
......@@ -293,8 +293,8 @@ protected:
// Make sure we don't visit the same file more than once.
info->DependDone = true;
const char* path = info->FullPath.c_str();
if (!path) {
const std::string& path = info->FullPath;
if (path.empty()) {
cmSystemTools::Error(
"Attempt to find dependencies for file without path!");
return;
......@@ -356,7 +356,7 @@ protected:
if (!found) {
// Couldn't find any dependency information.
if (this->ComplainFileRegularExpression.find(info->IncludeName)) {
cmSystemTools::Error("error cannot find dependencies for ", path);
cmSystemTools::Error("error cannot find dependencies for " + path);
} else {
// Destroy the name of the file so that it won't be output as a
// dependency.
......
......@@ -146,7 +146,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
const char* compileOutput =
this->Makefile->GetDefinition(this->OutputVariable);
if (compileOutput) {
runOutputContents = std::string(compileOutput) + runOutputContents;
runOutputContents = compileOutput + runOutputContents;
}
this->Makefile->AddDefinition(this->OutputVariable,
runOutputContents.c_str());
......@@ -167,7 +167,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
int retVal = -1;
std::string finalCommand;
const std::string emulator =
const std::string& emulator =
this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR");
if (!emulator.empty()) {
std::vector<std::string> emulatorWithArgs;
......@@ -233,7 +233,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
this->RunResultVariable + "__TRYRUN_OUTPUT";
bool error = false;
if (this->Makefile->GetDefinition(this->RunResultVariable) == nullptr) {
if (!this->Makefile->GetDefinition(this->RunResultVariable)) {
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
std::string comment;
......@@ -255,8 +255,8 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
}
// is the output from the executable used ?
if (out != nullptr) {
if (this->Makefile->GetDefinition(internalRunOutputName) == nullptr) {
if (out) {
if (!this->Makefile->GetDefinition(internalRunOutputName)) {
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
std::string comment;
......@@ -304,7 +304,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
comment += " to\n"
" the exit code (in many cases 0 for success), otherwise "
"enter \"FAILED_TO_RUN\".\n";
if (out != nullptr) {
if (out) {
comment += internalRunOutputName;
comment +=
"\n contains the text the executable "
......@@ -335,7 +335,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
<< this->Makefile->GetDefinition(this->RunResultVariable)
<< "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n";
if (out != nullptr) {
if (out) {
file << "set( " << internalRunOutputName << " \n \""
<< this->Makefile->GetDefinition(internalRunOutputName)
<< "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n";
......@@ -348,7 +348,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
"please set the following cache variables "
"appropriately:\n";
errorMessage += " " + this->RunResultVariable + " (advanced)\n";
if (out != nullptr) {
if (out) {
errorMessage += " " + internalRunOutputName + " (advanced)\n";
}
errorMessage += detailsString;
......@@ -356,7 +356,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
return;
}
if (out != nullptr) {
if (out) {
(*out) = this->Makefile->GetDefinition(internalRunOutputName);
}
}
......@@ -2858,7 +2858,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// Get compile flags for CUDA in this directory.
std::string CONFIG = cmSystemTools::UpperCase(configName);
std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG;
std::string configFlagsVar = "CMAKE_CUDA_FLAGS_" + CONFIG;
std::string flags = this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS") +
" " + this->Makefile->GetSafeDefinition(configFlagsVar);
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
......@@ -3075,7 +3075,7 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
Options& masmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
std::string configFlagsVar = "CMAKE_ASM_MASM_FLAGS_" + CONFIG;
std::string flags =
this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS") + " " +
this->Makefile->GetSafeDefinition(configFlagsVar);
......@@ -3428,7 +3428,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string standardLibsVar = "CMAKE_";
standardLibsVar += linkLanguage;
standardLibsVar += "_STANDARD_LIBRARIES";
std::string const libs = this->Makefile->GetSafeDefinition(standardLibsVar);
std::string const& libs = this->Makefile->GetSafeDefinition(standardLibsVar);
cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec);
linkOptions.AddFlag("AdditionalDependencies", libVec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment