summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-22 14:34:40 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-22 14:38:10 (GMT)
commit9b334397f55b70689ff1d8f7d6767a34834e85b6 (patch)
treebc33e4dc90eef2c351e278219bc9743d40af632c /Source/cmVisualStudio10TargetGenerator.cxx
parent130dbe4a5d49baa4404a399860bd3a6182783ece (diff)
downloadCMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.zip
CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.gz
CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.bz2
Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx86
1 files changed, 33 insertions, 53 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 8d4908d..c5cf9a7 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -364,10 +364,9 @@ void cmVisualStudio10TargetGenerator::Generate()
return;
}
}
- std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
- path += "/";
- path += this->Name;
- path += ProjectFileExtension;
+ std::string path =
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->Name, ProjectFileExtension);
cmGeneratedFileStream BuildFileStream(path);
const std::string PathToProjectFile = path;
BuildFileStream.SetCopyIfDifferent(true);
@@ -628,9 +627,8 @@ void cmVisualStudio10TargetGenerator::Generate()
std::string propsTemplate =
GetCMakeFilePath("Templates/MSBuild/nasm.props.in");
- std::string propsLocal;
- propsLocal += this->DefaultArtifactDir;
- propsLocal += "\\nasm.props";
+ std::string propsLocal =
+ cmStrCat(this->DefaultArtifactDir, "\\nasm.props");
ConvertToWindowsSlash(propsLocal);
this->Makefile->ConfigureFile(propsTemplate, propsLocal, false, true,
true);
@@ -1272,8 +1270,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
e1.Element("PlatformToolset", toolset);
}
- std::string postfixName = cmSystemTools::UpperCase(config);
- postfixName += "_POSTFIX";
+ std::string postfixName =
+ cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX");
std::string assemblyName = this->GeneratorTarget->GetOutputName(
config, cmStateEnums::RuntimeBinaryArtifact);
if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
@@ -1378,9 +1376,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
// preventing dependent rebuilds.
this->ForceOld(sourcePath);
} else {
- std::string error = "Could not create file: [";
- error += sourcePath;
- error += "] ";
+ std::string error =
+ cmStrCat("Could not create file: [", sourcePath, "] ");
cmSystemTools::Error(error + cmSystemTools::GetLastSystemError());
}
}
@@ -1549,11 +1546,9 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
// Write out group file
- std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
- path += "/";
- path += this->Name;
- path += computeProjectFileExtension(this->GeneratorTarget);
- path += ".filters";
+ std::string path = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->Name,
+ computeProjectFileExtension(this->GeneratorTarget), ".filters");
cmGeneratedFileStream fout(path);
fout.SetCopyIfDifferent(true);
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
@@ -2234,8 +2229,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
for (std::string const& config : this->Configurations) {
std::string configUpper = cmSystemTools::UpperCase(config);
std::string configDefines = defines;
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += configUpper;
+ std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
if (const char* ccdefs = sf.GetProperty(defPropName)) {
if (!configDefines.empty()) {
configDefines += ";";
@@ -2425,17 +2419,14 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
e1.WritePlatformConfigTag(
"IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
} else {
- std::string intermediateDir =
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- intermediateDir += "/";
- intermediateDir += config;
- intermediateDir += "/";
+ std::string intermediateDir = cmStrCat(
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
+ config, '/');
std::string outDir;
std::string targetNameFull;
if (ttype == cmStateEnums::OBJECT_LIBRARY) {
outDir = intermediateDir;
- targetNameFull = this->GeneratorTarget->GetName();
- targetNameFull += ".lib";
+ targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib");
} else {
outDir = this->GeneratorTarget->GetDirectory(config) + "/";
targetNameFull = this->GeneratorTarget->GetFullName(config);
@@ -2715,9 +2706,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
// Add a definition for the configuration name.
- std::string configDefine = "CMAKE_INTDIR=\"";
- configDefine += configName;
- configDefine += "\"";
+ std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
clOptions.AddDefine(configDefine);
if (const std::string* exportMacro =
this->GeneratorTarget->GetExportMacro()) {
@@ -3012,9 +3001,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
cudaOptions.AddDefines(targetDefines);
// Add a definition for the configuration name.
- std::string configDefine = "CMAKE_INTDIR=\"";
- configDefine += configName;
- configDefine += "\"";
+ std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
cudaOptions.AddDefine(configDefine);
if (const std::string* exportMacro =
this->GeneratorTarget->GetExportMacro()) {
@@ -3429,9 +3416,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkType = "EXE";
}
std::string flags;
- std::string linkFlagVarBase = "CMAKE_";
- linkFlagVarBase += linkType;
- linkFlagVarBase += "_LINKER_FLAGS";
+ std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS");
flags += " ";
flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase);
std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
@@ -3443,8 +3428,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
flags += " ";
flags += targetLinkFlags;
}
- std::string flagsProp = "LINK_FLAGS_";
- flagsProp += CONFIG;
+ std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
if (const char* flagsConfig =
this->GeneratorTarget->GetProperty(flagsProp)) {
flags += " ";
@@ -3484,9 +3468,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
break;
}
}
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += linkLanguage;
- standardLibsVar += "_STANDARD_LIBRARIES";
+ std::string standardLibsVar =
+ cmStrCat("CMAKE_", linkLanguage, "_STANDARD_LIBRARIES");
std::string const& libs = this->Makefile->GetSafeDefinition(standardLibsVar);
cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec);
linkOptions.AddFlag("AdditionalDependencies", libVec);
@@ -3550,13 +3533,12 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkOptions.AddFlag("GenerateDebugInformation", "false");
- std::string pdb = this->GeneratorTarget->GetPDBDirectory(config);
- pdb += "/";
- pdb += targetNames.PDB;
- std::string imLib = this->GeneratorTarget->GetDirectory(
- config, cmStateEnums::ImportLibraryArtifact);
- imLib += "/";
- imLib += targetNames.ImportLibrary;
+ std::string pdb = cmStrCat(this->GeneratorTarget->GetPDBDirectory(config),
+ '/', targetNames.PDB);
+ std::string imLib =
+ cmStrCat(this->GeneratorTarget->GetDirectory(
+ config, cmStateEnums::ImportLibraryArtifact),
+ '/', targetNames.ImportLibrary);
linkOptions.AddFlag("ImportLibrary", imLib);
linkOptions.AddFlag("ProgramDataBaseFile", pdb);
@@ -3938,10 +3920,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
if (p) {
path = p;
} else {
- path = lg->GetCurrentBinaryDirectory();
- path += "/";
- path += dt->GetName();
- path += computeProjectFileExtension(dt);
+ path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
+ computeProjectFileExtension(dt));
}
ConvertToWindowsSlash(path);
Elem e2(e1, "ProjectReference");
@@ -4748,8 +4728,8 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
const char* relativeFilePath) const
{
// Always search in the standard modules location.
- std::string path = cmSystemTools::GetCMakeRoot() + "/";
- path += relativeFilePath;
+ std::string path =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), '/', relativeFilePath);
ConvertToWindowsSlash(path);
return path;