summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx153
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx10
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx6
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx12
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx11
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx17
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx9
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.cxx2
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx32
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.cxx6
-rw-r--r--Source/CPack/cmCPackCygwinSourceGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackInnoSetupGenerator.cxx8
-rw-r--r--Source/cmCallVisualStudioMacro.cxx4
-rw-r--r--Source/cmExportBuildFileGenerator.cxx4
-rw-r--r--Source/cmExportInstallFileGenerator.cxx4
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx2
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.cxx3
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.cxx6
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx3
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx462
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx41
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx56
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx50
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx16
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx54
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx32
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx13
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx44
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx144
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx5
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx6
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx42
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx3
-rw-r--r--Source/cmMachO.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx3
-rw-r--r--Source/cmQtAutoMocUic.cxx2
-rw-r--r--Source/cmVSSetupHelper.cxx11
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx525
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx49
-rw-r--r--Source/cmVisualStudioSlnData.cxx4
-rw-r--r--Source/cmVisualStudioSlnParser.cxx59
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.cxx28
42 files changed, 1018 insertions, 929 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 1ea78fd..5077596 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -7,6 +7,7 @@
#include <cm/memory>
#include <cm/string_view>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmsys/Directory.hxx"
#include "cmsys/Encoding.hxx"
@@ -54,7 +55,7 @@ int cmCPackWIXGenerator::InitializeInternal()
bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
- std::string logFileName = this->CPackTopLevel + "/wix.log";
+ std::string logFileName = cmStrCat(this->CPackTopLevel, "/wix.log");
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Running WiX command: " << command << std::endl);
@@ -62,8 +63,9 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
std::string output;
int returnValue = 0;
- bool status = cmSystemTools::RunSingleCommand(
- command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE);
+ bool status =
+ cmSystemTools::RunSingleCommand(command, &output, &output, &returnValue,
+ nullptr, cmSystemTools::OUTPUT_NONE);
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
logFile << command << std::endl;
@@ -102,22 +104,22 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
}
std::ostringstream command;
- command << QuotePath(executable);
- command << " -nologo";
- command << " -arch " << arch;
- command << " -out " << QuotePath(objectFile);
+ command << QuotePath(executable)
+ << " -nologo"
+ " -arch "
+ << arch << " -out " << QuotePath(objectFile);
for (std::string const& ext : CandleExtensions) {
command << " -ext " << QuotePath(ext);
}
if (!cmHasSuffix(sourceFile, this->CPackTopLevel)) {
- command << " " << QuotePath("-I" + this->CPackTopLevel);
+ command << ' ' << QuotePath(cmStrCat("-I", this->CPackTopLevel));
}
AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
- command << " " << QuotePath(sourceFile);
+ command << ' ' << QuotePath(sourceFile);
return RunWiXCommand(command.str());
}
@@ -130,9 +132,10 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
}
std::ostringstream command;
- command << QuotePath(executable);
- command << " -nologo";
- command << " -out " << QuotePath(CMakeToWixPath(packageFileNames.at(0)));
+ command << QuotePath(executable)
+ << " -nologo"
+ " -out "
+ << QuotePath(CMakeToWixPath(packageFileNames.at(0)));
for (std::string const& ext : this->LightExtensions) {
command << " -ext " << QuotePath(ext);
@@ -145,7 +148,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command);
- command << " " << objectFiles;
+ command << ' ' << objectFiles;
return RunWiXCommand(command.str());
}
@@ -196,7 +199,8 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
}
if (!GetOption("CPACK_WIX_LICENSE_RTF")) {
- std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
+ std::string licenseFilename =
+ cmStrCat(this->CPackTopLevel, "/License.rtf");
SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename);
if (!CreateLicenseFile()) {
@@ -293,14 +297,14 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
usedBaseNames.insert(uniqueBaseName);
std::string objectFilename =
- this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj";
+ cmStrCat(this->CPackTopLevel, '/', uniqueBaseName, ".wixobj");
if (!RunCandleCommand(CMakeToWixPath(sourceFilename),
CMakeToWixPath(objectFilename))) {
return false;
}
- objectFiles << " " << QuotePath(CMakeToWixPath(objectFilename));
+ objectFiles << ' ' << QuotePath(CMakeToWixPath(objectFilename));
}
AppendUserSuppliedExtraObjects(objectFiles);
@@ -311,8 +315,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
{
cmValue cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
- if (!cpackWixExtraSources)
+ if (!cpackWixExtraSources) {
return;
+ }
cmExpandList(cpackWixExtraSources, this->WixSources);
}
@@ -320,8 +325,9 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
{
cmValue cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
- if (!cpackWixExtraObjects)
+ if (!cpackWixExtraObjects) {
return;
+ }
cmList expandedExtraObjects{ cpackWixExtraObjects };
@@ -332,7 +338,8 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
- std::string includeFilename = this->CPackTopLevel + "/cpack_variables.wxi";
+ std::string includeFilename =
+ cmStrCat(this->CPackTopLevel, "/cpack_variables.wxi");
cmWIXSourceWriter includeFile(this->Logger, includeFilename,
this->ComponentGuidType,
@@ -356,7 +363,8 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
{
- std::string includeFilename = this->CPackTopLevel + "/properties.wxi";
+ std::string includeFilename =
+ cmStrCat(this->CPackTopLevel, "/properties.wxi");
cmWIXSourceWriter includeFile(this->Logger, includeFilename,
this->ComponentGuidType,
@@ -405,7 +413,8 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile()
{
- std::string includeFilename = this->CPackTopLevel + "/product_fragment.wxi";
+ std::string includeFilename =
+ cmStrCat(this->CPackTopLevel, "/product_fragment.wxi");
cmWIXSourceWriter includeFile(this->Logger, includeFilename,
this->ComponentGuidType,
@@ -444,7 +453,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
// if install folder is supposed to be set absolutely, the default
// component guid "*" cannot be used
std::string directoryDefinitionsFilename =
- this->CPackTopLevel + "/directories.wxs";
+ cmStrCat(this->CPackTopLevel, "/directories.wxs");
this->WixSources.push_back(directoryDefinitionsFilename);
@@ -466,7 +475,8 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
directoryDefinitions.BeginInstallationPrefixDirectory(GetRootFolderId(),
installRoot);
- std::string fileDefinitionsFilename = this->CPackTopLevel + "/files.wxs";
+ std::string fileDefinitionsFilename =
+ cmStrCat(this->CPackTopLevel, "/files.wxs");
this->WixSources.push_back(fileDefinitionsFilename);
@@ -477,7 +487,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
- this->CPackTopLevel + "/features.wxs";
+ cmStrCat(this->CPackTopLevel, "/features.wxs");
this->WixSources.push_back(featureDefinitionsFilename);
@@ -536,7 +546,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string componentPath = cmStrCat(toplevel, '/', component.Name);
- std::string const componentFeatureId = "CM_C_" + component.Name;
+ std::string const componentFeatureId = cmStrCat("CM_C_", component.Name);
cmWIXShortcuts featureShortcuts;
AddComponentsToFeature(componentPath, componentFeatureId,
@@ -556,7 +566,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
bool emitUninstallShortcut = true;
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
emitUninstallShortcut = false;
} else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
emittedShortcutTypes.end()) {
@@ -613,7 +623,7 @@ std::string cmCPackWIXGenerator::GetRootFolderId() const
result = *rootFolderId;
}
- if (GetArchitecture() == "x86") {
+ if (GetArchitecture() == "x86"_s) {
cmSystemTools::ReplaceString(result, "<64>", "");
} else {
cmSystemTools::ReplaceString(result, "<64>", "64");
@@ -636,7 +646,7 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
return false;
}
- std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
+ std::string mainSourceFilePath = cmStrCat(this->CPackTopLevel, "/main.wxs");
if (!ConfigureFile(wixTemplate, mainSourceFilePath)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -656,7 +666,7 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
{
for (auto const& i : ComponentGroups) {
cmCPackComponentGroup const& group = i.second;
- if (group.ParentGroup == 0) {
+ if (group.ParentGroup == nullptr) {
featureDefinitions.EmitFeatureForComponentGroup(group, *this->Patch);
}
}
@@ -757,7 +767,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
case cmWIXShortcuts::START_MENU: {
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
directoryId = "ProgramMenuFolder";
} else {
directoryId = "PROGRAM_MENU_FOLDER";
@@ -788,13 +798,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
std::string idSuffix;
if (!cpackComponentName.empty()) {
- idSuffix += "_";
+ idSuffix += '_';
idSuffix += cpackComponentName;
}
std::string componentId = "CM_SHORTCUT";
- if (idPrefix.size()) {
- componentId += "_" + idPrefix;
+ if (!idPrefix.empty()) {
+ componentId += cmStrCat('_', idPrefix);
}
componentId += idSuffix;
@@ -810,7 +820,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
this->Patch->ApplyFragment(componentId, fileDefinitions);
std::string registryKey =
- std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
+ cmStrCat("Software\\", cpackVendor, '\\', cpackPackageName);
shortcuts.EmitShortcuts(type, registryKey, cpackComponentName,
fileDefinitions);
@@ -818,9 +828,9 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
if (type == cmWIXShortcuts::START_MENU) {
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != ".") {
- fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
- idSuffix);
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != "."_s) {
+ fileDefinitions.EmitRemoveFolder(
+ cmStrCat("CM_REMOVE_PROGRAM_MENU_FOLDER", idSuffix));
}
}
@@ -851,10 +861,10 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
std::string extension = GetRightmostExtension(licenseSourceFilename);
- if (extension == ".rtf") {
+ if (extension == ".rtf"_s) {
cmSystemTools::CopyAFile(licenseSourceFilename.c_str(),
licenseDestinationFilename.c_str());
- } else if (extension == ".txt") {
+ } else if (extension == ".txt"_s) {
cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
@@ -923,19 +933,18 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) {
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
- if (fileName == "." || fileName == "..") {
+ if (fileName == "."_s || fileName == ".."_s) {
continue;
}
- std::string fullPath = topdir + "/" + fileName;
+ std::string fullPath = cmStrCat(topdir, '/', fileName);
- std::string relativePath =
- cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str());
+ std::string relativePath = cmSystemTools::RelativePath(toplevel, fullPath);
std::string id = PathToId(relativePath);
- if (cmSystemTools::FileIsDirectory(fullPath.c_str())) {
- std::string subDirectoryId = std::string("CM_D") + id;
+ if (cmSystemTools::FileIsDirectory(fullPath)) {
+ std::string subDirectoryId = cmStrCat("CM_D", id);
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", subDirectoryId);
@@ -965,7 +974,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
std::string const& textLabel = packageExecutables[j];
if (cmSystemTools::LowerCase(fileName) ==
- cmSystemTools::LowerCase(executableName) + ".exe") {
+ cmStrCat(cmSystemTools::LowerCase(executableName), ".exe")) {
cmWIXShortcut shortcut;
shortcut.label = textLabel;
shortcut.workingDirectoryId = directoryId;
@@ -988,12 +997,12 @@ bool cmCPackWIXGenerator::RequireOption(std::string const& name,
value = *tmp;
return true;
- } else {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Required variable " << name << " not set" << std::endl);
-
- return false;
}
+
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Required variable " << name << " not set" << std::endl);
+
+ return false;
}
std::string cmCPackWIXGenerator::GetArchitecture() const
@@ -1001,11 +1010,10 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
std::string void_p_size;
RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size);
- if (void_p_size == "8") {
+ if (void_p_size == "8"_s) {
return "x64";
- } else {
- return "x86";
}
+ return "x86";
}
std::string cmCPackWIXGenerator::GenerateGUID()
@@ -1034,7 +1042,7 @@ std::string cmCPackWIXGenerator::GenerateGUID()
std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
{
- return std::string("\"") + path + '"';
+ return cmStrCat('"', path, '"');
}
std::string cmCPackWIXGenerator::GetRightmostExtension(
@@ -1042,7 +1050,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
{
std::string extension;
- std::string::size_type i = filename.rfind(".");
+ std::string::size_type i = filename.rfind('.');
if (i != std::string::npos) {
extension = filename.substr(i);
}
@@ -1052,9 +1060,10 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
std::string cmCPackWIXGenerator::PathToId(std::string const& path)
{
- id_map_t::const_iterator i = PathToIdMap.find(path);
- if (i != PathToIdMap.end())
+ auto i = PathToIdMap.find(path);
+ if (i != PathToIdMap.end()) {
return i->second;
+ }
std::string id = CreateNewIdForPath(path);
return id;
@@ -1063,7 +1072,7 @@ std::string cmCPackWIXGenerator::PathToId(std::string const& path)
std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
{
std::vector<std::string> components;
- cmSystemTools::SplitPath(path.c_str(), components, false);
+ cmSystemTools::SplitPath(path, components, false);
size_t replacementCount = 0;
@@ -1071,8 +1080,9 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
std::string currentComponent;
for (size_t i = 1; i < components.size(); ++i) {
- if (i != 1)
+ if (i != 1) {
identifier += '.';
+ }
currentComponent =
NormalizeComponentForId(components[i], replacementCount);
@@ -1088,18 +1098,19 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
}
std::ostringstream result;
- result << idPrefix << "_" << identifier;
+ result << idPrefix << '_' << identifier;
size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
if (ambiguityCount > 999) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while trying to generate a unique Id for '"
- << path << "'" << std::endl);
+ << path << '\'' << std::endl);
return std::string();
- } else if (ambiguityCount > 1) {
- result << "_" << ambiguityCount;
+ }
+ if (ambiguityCount > 1) {
+ result << '_' << ambiguityCount;
}
std::string resultString = result.str();
@@ -1157,8 +1168,9 @@ void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
extension_set_t& extensions)
{
cmValue variableContent = GetOption(variableName);
- if (!variableContent)
+ if (!variableContent) {
return;
+ }
cmList list{ variableContent };
extensions.insert(list.begin(), list.end());
@@ -1182,7 +1194,8 @@ void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName,
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Invalid element in CPACK_WIX_CUSTOM_XMLNS ignored: "
- << "\"" << str << "\"" << std::endl);
+ "\""
+ << str << '"' << std::endl);
}
}
std::ostringstream oss;
@@ -1197,13 +1210,14 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
std::ostream& stream)
{
cmValue variableContent = GetOption(variableName);
- if (!variableContent)
+ if (!variableContent) {
return;
+ }
cmList list{ variableContent };
for (std::string const& i : list) {
- stream << " " << QuotePath(i);
+ stream << ' ' << QuotePath(i);
}
}
@@ -1222,6 +1236,7 @@ std::string cmCPackWIXGenerator::RelativePathWithoutComponentPrefix(
void cmCPackWIXGenerator::InjectXmlNamespaces(cmWIXSourceWriter& sourceWriter)
{
for (auto& ns : this->CustomXmlNamespaces) {
- sourceWriter.AddAttributeUnlessEmpty("xmlns:" + ns.first, ns.second);
+ sourceWriter.AddAttributeUnlessEmpty(cmStrCat("xmlns:", ns.first),
+ ns.second);
}
}
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index 2261a66..0ebe2f4 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -102,13 +102,14 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
"Write",
"WriteAttributes",
"WriteExtendedAttributes",
- 0
+ nullptr
};
size_t i = 0;
while (validAttributes[i]) {
- if (name == validAttributes[i++])
+ if (name == validAttributes[i++]) {
return true;
+ }
}
return false;
@@ -118,9 +119,8 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
std::string const& name)
{
if (!this->IsBooleanAttribute(name)) {
- std::ostringstream message;
- message << "Unknown boolean attribute '" << name << "'";
- this->ReportError(entry, message.str());
+ this->ReportError(entry,
+ cmStrCat("Unknown boolean attribute '", name, '\''));
}
this->SourceWriter.AddAttribute(name, "yes");
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 0a83ca2..a655d86 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXDirectoriesSourceWriter.h"
+#include <cmext/string_view>
+
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
: cmWIXSourceWriter(logger, filename, componentGuidType)
@@ -14,7 +16,7 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
BeginElement("Directory");
AddAttribute("Id", "ProgramMenuFolder");
- if (startMenuFolder != ".") {
+ if (startMenuFolder != "."_s) {
BeginElement("Directory");
AddAttribute("Id", "PROGRAM_MENU_FOLDER");
AddAttribute("Name", startMenuFolder);
@@ -53,7 +55,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
std::vector<std::string> installRoot;
- cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
+ cmSystemTools::SplitPath(installRootString, installRoot);
if (!installRoot.empty() && installRoot.back().empty()) {
installRoot.pop_back();
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index a7a0648..78c2208 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXFeaturesSourceWriter.h"
+#include "cmStringAlgorithms.h"
+
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
: cmWIXSourceWriter(logger, filename, componentGuidType)
@@ -17,7 +19,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY"));
std::string registryKey =
- std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+ cmStrCat(R"(Software\Kitware\CMake\Packages\)", package);
BeginElement("RegistryValue");
AddAttribute("Root", "HKLM");
@@ -35,7 +37,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
cmCPackComponentGroup const& group, cmWIXPatch& patch)
{
BeginElement("Feature");
- AddAttribute("Id", "CM_G_" + group.Name);
+ AddAttribute("Id", cmStrCat("CM_G_", group.Name));
if (group.IsExpandedByDefault) {
AddAttribute("Display", "expand");
@@ -44,7 +46,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
AddAttributeUnlessEmpty("Title", group.DisplayName);
AddAttributeUnlessEmpty("Description", group.Description);
- patch.ApplyFragment("CM_G_" + group.Name, *this);
+ patch.ApplyFragment(cmStrCat("CM_G_", group.Name), *this);
for (cmCPackComponentGroup* subgroup : group.Subgroups) {
EmitFeatureForComponentGroup(*subgroup, patch);
@@ -61,7 +63,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
cmCPackComponent const& component, cmWIXPatch& patch)
{
BeginElement("Feature");
- AddAttribute("Id", "CM_C_" + component.Name);
+ AddAttribute("Id", cmStrCat("CM_C_", component.Name));
AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description);
@@ -78,7 +80,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
AddAttribute("Level", "2");
}
- patch.ApplyFragment("CM_C_" + component.Name, *this);
+ patch.ApplyFragment(cmStrCat("CM_C_", component.Name), *this);
EndElement("Feature");
}
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
index 122ffaf..c65449c 100644
--- a/Source/CPack/WiX/cmWIXPatch.cxx
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -14,7 +14,7 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
cmWIXPatchParser parser(Fragments, Logger);
if (!parser.ParseFile(patchFilePath.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Failed parsing XML patch file: '" << patchFilePath << "'"
+ "Failed parsing XML patch file: '" << patchFilePath << '\''
<< std::endl);
return false;
}
@@ -25,9 +25,10 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
void cmWIXPatch::ApplyFragment(std::string const& id,
cmWIXSourceWriter& writer)
{
- cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
- if (i == Fragments.end())
+ auto i = Fragments.find(id);
+ if (i == Fragments.end()) {
return;
+ }
const cmWIXPatchElement& fragment = i->second;
for (auto const& attr : fragment.attributes) {
@@ -75,9 +76,9 @@ bool cmWIXPatch::CheckForUnappliedFragments()
fragmentList += ", ";
}
- fragmentList += "'";
+ fragmentList += '\'';
fragmentList += fragment.first;
- fragmentList += "'";
+ fragmentList += '\'';
}
if (!fragmentList.empty()) {
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 8b26c4e..136eaac 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -5,6 +5,7 @@
#include <utility>
#include <cm/memory>
+#include <cmext/string_view>
#include <cm3p/expat.h>
@@ -20,9 +21,7 @@ cmWIXPatchNode::Type cmWIXPatchElement::type()
return cmWIXPatchNode::ELEMENT;
}
-cmWIXPatchNode::~cmWIXPatchNode()
-{
-}
+cmWIXPatchNode::~cmWIXPatchNode() = default;
cmWIXPatchElement::cmWIXPatchElement() = default;
cmWIXPatchElement::~cmWIXPatchElement() = default;
@@ -39,13 +38,13 @@ cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
{
if (State == BEGIN_DOCUMENT) {
- if (name == "CPackWiXPatch") {
+ if (name == "CPackWiXPatch"_s) {
State = BEGIN_FRAGMENTS;
} else {
ReportValidationError("Expected root element 'CPackWiXPatch'");
}
} else if (State == BEGIN_FRAGMENTS) {
- if (name == "CPackWiXFragment") {
+ if (name == "CPackWiXFragment"_s) {
State = INSIDE_FRAGMENT;
StartFragment(atts);
} else {
@@ -78,7 +77,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
const std::string key = attributes[i];
const std::string value = attributes[i + 1];
- if (key == "Id") {
+ if (key == "Id"_s) {
if (Fragments.find(value) != Fragments.end()) {
std::ostringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
@@ -98,7 +97,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
const std::string key = attributes[i];
const std::string value = attributes[i + 1];
- if (key != "Id") {
+ if (key != "Id"_s) {
new_element->attributes[key] = value;
}
}
@@ -108,7 +107,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
void cmWIXPatchParser::EndElement(const std::string& name)
{
if (State == INSIDE_FRAGMENT) {
- if (name == "CPackWiXFragment") {
+ if (name == "CPackWiXFragment"_s) {
State = BEGIN_FRAGMENTS;
ElementStack.clear();
} else {
@@ -142,7 +141,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while processing XML patch file at "
- << line << ":" << column << ": " << msg << std::endl);
+ << line << ':' << column << ": " << msg << std::endl);
Valid = false;
}
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index d7e534a..8a63239 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -135,7 +135,7 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
{
- File << "\\" << keyword;
+ File << '\\' << keyword;
}
void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
@@ -158,7 +158,8 @@ void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
// Do not emit byte order mark (BOM)
if (c == 0xFEFF) {
return;
- } else if (c <= 0xFFFF) {
+ }
+ if (c <= 0xFFFF) {
EmitUnicodeSurrogate(c);
} else {
c -= 0x10000;
@@ -175,12 +176,12 @@ void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
} else {
File << (c - 65536);
}
- File << "?";
+ File << '?';
}
void cmWIXRichTextFormatWriter::EmitInvalidCodepoint(int c)
{
ControlWord("cf1 ");
- File << "[INVALID-BYTE-" << int(c) << "]";
+ File << "[INVALID-BYTE-" << c << ']';
ControlWord("cf0 ");
}
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
index c3eb219..1cfb6c1 100644
--- a/Source/CPack/WiX/cmWIXShortcut.cxx
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -20,7 +20,7 @@ bool cmWIXShortcuts::EmitShortcuts(
std::string const& cpackComponentName,
cmWIXFilesSourceWriter& fileDefinitions) const
{
- shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
+ auto i = this->Shortcuts.find(type);
if (i == this->Shortcuts.end()) {
return false;
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index 8e9bfdf..82dc019 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -34,7 +34,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
cmCPackLogger(cmCPackLog::LOG_ERROR,
Elements.size() - 1
<< " WiX elements were still open when closing '"
- << SourceFilename << "'" << std::endl);
+ << SourceFilename << '\'' << std::endl);
return;
}
@@ -44,12 +44,12 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
void cmWIXSourceWriter::BeginElement(std::string const& name)
{
if (State == BEGIN) {
- File << ">";
+ File << '>';
}
- File << "\n";
+ File << '\n';
Indent(Elements.size());
- File << "<" << name;
+ File << '<' << name;
Elements.push_back(name);
State = BEGIN;
@@ -60,7 +60,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
if (Elements.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not end WiX element with no open elements in '"
- << SourceFilename << "'" << std::endl);
+ << SourceFilename << '\'' << std::endl);
return;
}
@@ -68,14 +68,14 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
cmCPackLogger(cmCPackLog::LOG_ERROR,
"WiX element <"
<< Elements.back() << "> can not be closed by </" << name
- << "> in '" << SourceFilename << "'" << std::endl);
+ << "> in '" << SourceFilename << '\'' << std::endl);
return;
}
if (State == DEFAULT) {
- File << "\n";
+ File << '\n';
Indent(Elements.size() - 1);
- File << "</" << Elements.back() << ">";
+ File << "</" << Elements.back() << '>';
} else {
File << "/>";
}
@@ -87,17 +87,17 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
void cmWIXSourceWriter::AddTextNode(std::string const& text)
{
if (State == BEGIN) {
- File << ">";
+ File << '>';
}
if (Elements.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not add text without open WiX element in '"
- << SourceFilename << "'" << std::endl);
+ << SourceFilename << '\'' << std::endl);
return;
}
- File << this->EscapeAttributeValue(text);
+ File << cmWIXSourceWriter::EscapeAttributeValue(text);
State = DEFAULT;
}
@@ -105,12 +105,12 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
std::string const& content)
{
if (State == BEGIN) {
- File << ">";
+ File << '>';
}
- File << "\n";
+ File << '\n';
Indent(Elements.size());
- File << "<?" << target << " " << content << "?>";
+ File << "<?" << target << ' ' << content << "?>";
State = DEFAULT;
}
@@ -118,7 +118,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
void cmWIXSourceWriter::AddAttribute(std::string const& key,
std::string const& value)
{
- File << " " << key << "=\"" << EscapeAttributeValue(value) << '"';
+ File << ' ' << key << "=\"" << EscapeAttributeValue(value) << '"';
}
void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
@@ -144,7 +144,7 @@ std::string cmWIXSourceWriter::CreateGuidFromComponentId(
void cmWIXSourceWriter::WriteXMLDeclaration()
{
- File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+ File << R"(<?xml version="1.0" encoding="UTF-8"?>)" << std::endl;
}
void cmWIXSourceWriter::Indent(size_t count)
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
index fabf4c5..fcb79a2 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
@@ -44,9 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
cmGeneratedFileStream ofs(manifestFile);
for (std::string const& file : files) {
// remove the temp dir and replace with /usr
- ofs << file.substr(tempdir.size()) << "\n";
+ ofs << file.substr(tempdir.size()) << '\n';
}
- ofs << manifest << "\n";
+ ofs << manifest << '\n';
}
// add the manifest file to the list of all files
files.push_back(manifestFile);
@@ -60,7 +60,7 @@ const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
this->OutputExtension = "-";
cmValue patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if (!patchNumber) {
- this->OutputExtension += "1";
+ this->OutputExtension += '1';
cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
<< std::endl);
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
index a5863ff..f025a6c 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
@@ -98,7 +98,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n");
- outerTarFile += "1";
+ outerTarFile += '1';
} else {
outerTarFile += patch;
}
@@ -150,7 +150,7 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n");
- this->OutputExtension += "1";
+ this->OutputExtension += '1';
} else {
this->OutputExtension += patch;
}
diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx
index ada9a5b..b8bf070 100644
--- a/Source/CPack/cmCPackInnoSetupGenerator.cxx
+++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx
@@ -106,7 +106,7 @@ int cmCPackInnoSetupGenerator::PackageFiles()
const cmList extraScripts(GetOption("CPACK_INNOSETUP_EXTRA_SCRIPTS"));
for (const std::string& i : extraScripts) {
- includeDirectives.push_back(cmStrCat(
+ includeDirectives.emplace_back(cmStrCat(
"#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel))));
}
}
@@ -142,7 +142,7 @@ int cmCPackInnoSetupGenerator::PackageFiles()
const cmList codeFiles(GetOption("CPACK_INNOSETUP_CODE_FILES"));
for (const std::string& i : codeFiles) {
- codeIncludes.push_back(cmStrCat(
+ codeIncludes.emplace_back(cmStrCat(
"#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel))));
}
}
@@ -781,7 +781,7 @@ bool cmCPackInnoSetupGenerator::ConfigureISScript()
// Create internal variables
std::vector<std::string> setupSection;
for (const auto& i : setupDirectives) {
- setupSection.push_back(cmStrCat(i.first, '=', TranslateBool(i.second)));
+ setupSection.emplace_back(cmStrCat(i.first, '=', TranslateBool(i.second)));
}
// Also create comments if the sections are empty
@@ -1082,7 +1082,7 @@ std::string cmCPackInnoSetupGenerator::ISKeyValueLine(
std::vector<std::string> keys;
for (const char* i : availableKeys) {
if (params.count(i)) {
- keys.push_back(cmStrCat(i, ": ", params.at(i)));
+ keys.emplace_back(cmStrCat(i, ": ", params.at(i)));
}
}
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 94b6e18..292b9a3 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -4,6 +4,8 @@
#include <sstream>
+#include <cmext/string_view>
+
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -305,7 +307,7 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
//! we perhaps looking for any and all solutions?
bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
{
- if (slnFile == "ALL" || slnName == "ALL") {
+ if (slnFile == "ALL"_s || slnName == "ALL"_s) {
return true;
}
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 8d3960c..fd35786 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -419,7 +419,7 @@ std::string cmExportBuildFileGenerator::GetFileSetDirectories(
resultVector.push_back(
cmStrCat("\"$<$<CONFIG:", config, ">:", dest, ">\""));
} else {
- resultVector.push_back(cmStrCat('"', dest, '"'));
+ resultVector.emplace_back(cmStrCat('"', dest, '"'));
break;
}
}
@@ -478,7 +478,7 @@ std::string cmExportBuildFileGenerator::GetFileSetFiles(cmGeneratorTarget* gte,
resultVector.push_back(
cmStrCat("\"$<$<CONFIG:", config, ">:", escapedFile, ">\""));
} else {
- resultVector.push_back(cmStrCat('"', escapedFile, '"'));
+ resultVector.emplace_back(cmStrCat('"', escapedFile, '"'));
}
}
}
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 264c947..6cf3a09 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -616,7 +616,7 @@ std::string cmExportInstallFileGenerator::GetFileSetDirectories(
resultVector.push_back(
cmStrCat("\"$<$<CONFIG:", config, ">:", dest, ">\""));
} else {
- resultVector.push_back(cmStrCat('"', dest, '"'));
+ resultVector.emplace_back(cmStrCat('"', dest, '"'));
break;
}
}
@@ -690,7 +690,7 @@ std::string cmExportInstallFileGenerator::GetFileSetFiles(
resultVector.push_back(
cmStrCat("\"$<$<CONFIG:", config, ">:", escapedFile, ">\""));
} else {
- resultVector.push_back(cmStrCat('"', escapedFile, '"'));
+ resultVector.emplace_back(cmStrCat('"', escapedFile, '"'));
}
}
}
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 2453bfc..4ba53ec 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -670,7 +670,7 @@ bool cmGlobalGhsMultiGenerator::AddCheckTarget()
}
// Add the cache file.
- listFiles.push_back(cmStrCat(
+ listFiles.emplace_back(cmStrCat(
this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeCache.txt"));
// Print not implemented warning.
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index f1d4d09..44980d6 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -5,6 +5,7 @@
#include <ostream>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -45,7 +46,7 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
std::string const& lang,
cmValue envVar) const
{
- if (lang == "CXX" || lang == "C") {
+ if (lang == "CXX"_s || lang == "C"_s) {
/* clang-format off */
os <<
"To use the JOM generator with Visual C++, cmake must be run from a "
diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx
index e543aea..26b30fd 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.cxx
+++ b/Source/cmGlobalMSYSMakefileGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalMSYSMakefileGenerator.h"
+#include <cmext/string_view>
+
#include "cmsys/FStream.hxx"
#include "cmMakefile.h"
@@ -31,7 +33,7 @@ std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
while (fin) {
fin >> path;
fin >> mount;
- if (mount == "/mingw") {
+ if (mount == "/mingw"_s) {
mingwBin = cmStrCat(path, "/bin");
}
}
@@ -45,7 +47,7 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
- !(1 == l.size() && l[0] == "NONE")) {
+ !(1 == l.size() && l[0] == "NONE"_s)) {
cmSystemTools::Error(
"CMAKE_AR was not found, please set to archive program. " +
mf->GetSafeDefinition("CMAKE_AR"));
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index cb53850..424c4bd 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -5,6 +5,7 @@
#include <ostream>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmsys/RegularExpression.hxx"
@@ -88,7 +89,7 @@ cmDocumentationEntry cmGlobalNMakeMakefileGenerator::GetDocumentation()
void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(
std::ostream& os, std::string const& lang, cmValue envVar) const
{
- if (lang == "CXX" || lang == "C") {
+ if (lang == "CXX"_s || lang == "C"_s) {
/* clang-format off */
os <<
"To use the NMake generator with Visual C++, cmake must be run from a "
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index f1d04e5..7a852f8 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -9,6 +9,7 @@
#include <utility>
#include <cm/memory>
+#include <cmext/string_view>
#include <cm3p/json/reader.h>
#include <cm3p/json/value.h>
@@ -83,10 +84,10 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
{
if (this->SystemIsWindowsCE && ts.empty() &&
this->DefaultPlatformToolset.empty()) {
- std::ostringstream e;
- e << this->GetName() << " Windows CE version '" << this->SystemVersion
- << "' requires CMAKE_GENERATOR_TOOLSET to be set.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(this->GetName(), " Windows CE version '", this->SystemVersion,
+ "' requires CMAKE_GENERATOR_TOOLSET to be set."));
return false;
}
@@ -105,16 +106,17 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
if (!this->CustomFlagTableDir.empty() &&
!(cmSystemTools::FileIsFullPath(this->CustomFlagTableDir) &&
cmSystemTools::FileIsDirectory(this->CustomFlagTableDir))) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset\n"
- " customFlagTableDir=" << this->CustomFlagTableDir << "\n"
- "that is not an absolute path to an existing directory.";
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset\n"
+ " customFlagTableDir=",
+ this->CustomFlagTableDir,
+ "\n"
+ "that is not an absolute path to an existing directory."));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -125,7 +127,8 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
// differing from the "false" and "true" values used in older toolsets.
// A VS 2015 update changed it back. Parse the "link.xml" file to
// discover which one we need.
- std::string const link_xml = this->VCTargetsPath + "/1033/link.xml";
+ std::string const link_xml =
+ cmStrCat(this->VCTargetsPath, "/1033/link.xml");
cmsys::ifstream fin(link_xml.c_str());
std::string line;
while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
@@ -140,24 +143,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
this->SupportsUnityBuilds =
this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 ||
(this->Version == cmGlobalVisualStudioGenerator::VSVersion::VS15 &&
- cmSystemTools::PathExists(this->VCTargetsPath +
- "/Microsoft.Cpp.Unity.targets"));
+ cmSystemTools::PathExists(
+ cmStrCat(this->VCTargetsPath, "/Microsoft.Cpp.Unity.targets")));
if (this->GeneratorToolsetCuda.empty()) {
// Find the highest available version of the CUDA tools.
std::vector<std::string> cudaTools;
std::string bcDir;
if (this->GeneratorToolsetCudaCustomDir.empty()) {
- bcDir = this->VCTargetsPath + "/BuildCustomizations";
+ bcDir = cmStrCat(this->VCTargetsPath, "/BuildCustomizations");
} else {
- bcDir = this->GetPlatformToolsetCudaCustomDirString() +
- this->GetPlatformToolsetCudaVSIntegrationSubdirString() +
- "extras\\visual_studio_integration\\MSBuildExtensions";
+ bcDir = cmStrCat(this->GetPlatformToolsetCudaCustomDirString(),
+ this->GetPlatformToolsetCudaVSIntegrationSubdirString(),
+ "extras\\visual_studio_integration\\MSBuildExtensions");
cmSystemTools::ConvertToUnixSlashes(bcDir);
}
cmsys::Glob gl;
gl.SetRelative(bcDir.c_str());
- if (gl.FindFiles(bcDir + "/CUDA *.props")) {
+ if (gl.FindFiles(cmStrCat(bcDir, "/CUDA *.props"))) {
cudaTools = gl.GetFiles();
}
if (!cudaTools.empty()) {
@@ -168,18 +171,19 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
} else if (!this->GeneratorToolsetCudaCustomDir.empty()) {
// Generate an error if Visual Studio integration files are not found
// inside of custom cuda toolset.
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset\n"
- " cuda=" << this->GeneratorToolsetCudaCustomDir << "\n"
- "cannot detect Visual Studio integration files in path\n"
- " " << bcDir;
-
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset\n"
+ " cuda=",
+ this->GeneratorToolsetCudaCustomDir,
+ "\n"
+ "cannot detect Visual Studio integration files in path\n"
+ " ",
+ bcDir));
// Clear the configured tool-set
this->GeneratorToolsetCuda.clear();
@@ -187,32 +191,31 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
}
if (!this->GeneratorToolsetVersion.empty() &&
- this->GeneratorToolsetVersion != "Test Toolset Version") {
+ this->GeneratorToolsetVersion != "Test Toolset Version"_s) {
// If a specific minor version of the toolset was requested, verify that it
// is compatible to the major version and that is exists on disk.
// If not clear the value.
std::string versionToolset = this->GeneratorToolsetVersion;
cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]");
if (regex.find(versionToolset)) {
- versionToolset = "v" + versionToolset.erase(2, 1);
+ versionToolset = cmStrCat('v', versionToolset.erase(2, 1));
} else {
// Version not recognized. Clear it.
versionToolset.clear();
}
if (!cmHasPrefix(versionToolset, this->GetPlatformToolsetString())) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset and version specification\n"
- " " << this->GetPlatformToolsetString() << ",version=" <<
- this->GeneratorToolsetVersion << "\n"
- "contains an invalid version specification."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset and version specification\n"
+ " ",
+ this->GetPlatformToolsetString(),
+ ",version=", this->GeneratorToolsetVersion,
+ "\n"
+ "contains an invalid version specification."));
// Clear the configured tool-set
this->GeneratorToolsetVersion.clear();
@@ -232,40 +235,40 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
this->GeneratorToolsetVersionProps = std::move(auxProps);
break;
case AuxToolset::PropsMissing: {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset and version specification\n"
- " " << this->GetPlatformToolsetString() << ",version=" <<
- this->GeneratorToolsetVersion << "\n"
- "does not seem to be installed at\n" <<
- " " << auxProps;
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset and version specification\n"
+ " ",
+ this->GetPlatformToolsetString(),
+ ",version=", this->GeneratorToolsetVersion,
+ "\n"
+ "does not seem to be installed at\n"
+ " ",
+ auxProps));
// Clear the configured tool-set
this->GeneratorToolsetVersion.clear();
this->GeneratorToolsetVersionProps = {};
} break;
case AuxToolset::PropsIndeterminate: {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset and version specification\n"
- " " << this->GetPlatformToolsetString() << ",version=" <<
- this->GeneratorToolsetVersion << "\n"
- "has multiple matches installed at\n" <<
- " " << auxProps << "\n" <<
- "The toolset and version specification must resolve \n" <<
- "to a single installed toolset";
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset and version specification\n"
+ " ",
+ this->GetPlatformToolsetString(),
+ ",version=", this->GeneratorToolsetVersion,
+ "\n"
+ "has multiple matches installed at\n",
+ " ", auxProps, "\n",
+ "The toolset and version specification must resolve \n"
+ "to a single installed toolset"));
// Clear the configured tool-set
this->GeneratorToolsetVersion.clear();
@@ -319,47 +322,47 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
for (; fi != fields.end(); ++fi) {
std::string::size_type pos = fi->find('=');
if (pos == fi->npos) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset specification\n"
- " " << ts << "\n"
- "that contains a field after the first ',' with no '='."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset specification\n"
+ " ",
+ ts,
+ "\n"
+ "that contains a field after the first ',' with no '='."));
return false;
}
std::string const key = fi->substr(0, pos);
std::string const value = fi->substr(pos + 1);
if (!handled.insert(key).second) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset specification\n"
- " " << ts << "\n"
- "that contains duplicate field key '" << key << "'."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset specification\n"
+ " ",
+ ts,
+ "\n"
+ "that contains duplicate field key '",
+ key, "'."));
return false;
}
if (!this->ProcessGeneratorToolsetField(key, value)) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given toolset specification\n"
- " " << ts << "\n"
- "that contains invalid field '" << *fi << "'."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given toolset specification\n"
+ " ",
+ ts,
+ "\n"
+ "that contains invalid field '",
+ *fi, "'."));
return false;
}
}
@@ -370,7 +373,7 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
- if (key == "cuda") {
+ if (key == "cuda"_s) {
/* test if cuda toolset is path to custom dir or cuda version */
auto pos = value.find_first_not_of("0123456789.");
if (pos != std::string::npos) {
@@ -395,16 +398,16 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
}
return true;
}
- if (key == "customFlagTableDir") {
+ if (key == "customFlagTableDir"_s) {
this->CustomFlagTableDir = value;
cmSystemTools::ConvertToUnixSlashes(this->CustomFlagTableDir);
return true;
}
- if (key == "version") {
+ if (key == "version"_s) {
this->GeneratorToolsetVersion = value;
return true;
}
- if (key == "VCTargetsPath") {
+ if (key == "VCTargetsPath"_s) {
this->CustomVCTargetsPath = value;
ConvertToWindowsSlashes(this->CustomVCTargetsPath);
return true;
@@ -414,34 +417,35 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
{
- if (this->SystemName == "Windows") {
+ if (this->SystemName == "Windows"_s) {
if (!this->InitializeWindows(mf)) {
return false;
}
- } else if (this->SystemName == "WindowsCE") {
+ } else if (this->SystemName == "WindowsCE"_s) {
this->SystemIsWindowsCE = true;
if (!this->InitializeWindowsCE(mf)) {
return false;
}
- } else if (this->SystemName == "WindowsPhone") {
+ } else if (this->SystemName == "WindowsPhone"_s) {
this->SystemIsWindowsPhone = true;
if (!this->InitializeWindowsPhone(mf)) {
return false;
}
- } else if (this->SystemName == "WindowsStore") {
+ } else if (this->SystemName == "WindowsStore"_s) {
this->SystemIsWindowsStore = true;
if (!this->InitializeWindowsStore(mf)) {
return false;
}
- } else if (this->SystemName == "Android") {
+ } else if (this->SystemName == "Android"_s) {
if (this->PlatformInGeneratorName) {
- std::ostringstream e;
- e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
- << "specifies a platform too: '" << this->GetName() << "'";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR ",
+ "specifies a platform too: '", this->GetName(), '\''));
return false;
}
- if (mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM") == "Tegra-Android") {
+ if (mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM") ==
+ "Tegra-Android"_s) {
if (!this->InitializeTegraAndroid(mf)) {
return false;
}
@@ -464,10 +468,10 @@ bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
{
if (this->PlatformInGeneratorName) {
- std::ostringstream e;
- e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
- << "specifies a platform too: '" << this->GetName() << "'";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR ",
+ "specifies a platform too: '", this->GetName(), '\''));
return false;
}
@@ -485,17 +489,17 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
{
- std::ostringstream e;
- e << this->GetName() << " does not support Windows Phone.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(this->GetName(), " does not support Windows Phone."));
return false;
}
bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
{
- std::ostringstream e;
- e << this->GetName() << " does not support Windows Store.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(this->GetName(), " does not support Windows Store."));
return false;
}
@@ -519,15 +523,15 @@ bool cmGlobalVisualStudio10Generator::InitializeTegraAndroid(cmMakefile* mf)
bool cmGlobalVisualStudio10Generator::InitializeAndroid(cmMakefile* mf)
{
- std::ostringstream e;
- e << this->GetName() << " does not support Android.";
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat(this->GetName(), " does not support Android."));
return false;
}
bool cmGlobalVisualStudio10Generator::InitializePlatform(cmMakefile* mf)
{
- if (this->SystemName == "Windows" || this->SystemName == "WindowsStore") {
+ if (this->SystemName == "Windows"_s ||
+ this->SystemName == "WindowsStore"_s) {
if (!this->InitializePlatformWindows(mf)) {
return false;
}
@@ -565,7 +569,7 @@ bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const
{
- if (this->SystemVersion == "8.0") {
+ if (this->SystemVersion == "8.0"_s) {
return "CE800";
}
return "";
@@ -607,29 +611,30 @@ void cmGlobalVisualStudio10Generator::Generate()
}
if (this->LongestSource.Length > 0) {
cmLocalGenerator* lg = this->LongestSource.Target->GetLocalGenerator();
- std::ostringstream e;
- /* clang-format off */
- e <<
- "The binary and/or source directory paths may be too long to generate "
- "Visual Studio 10 files for this project. "
- "Consider choosing shorter directory names to build this project with "
- "Visual Studio 10. "
- "A more detailed explanation follows."
- "\n"
- "There is a bug in the VS 10 IDE that renders property dialog fields "
- "blank for files referenced by full path in the project file. "
- "However, CMake must reference at least one file by full path:\n"
- " " << this->LongestSource.SourceFile->GetFullPath() << "\n"
- "This is because some Visual Studio tools would append the relative "
- "path to the end of the referencing directory path, as in:\n"
- " " << lg->GetCurrentBinaryDirectory() << "/"
- << this->LongestSource.SourceRel << "\n"
- "and then incorrectly complain that the file does not exist because "
- "the path length is too long for some internal buffer or API. "
- "To avoid this problem CMake must use a full path for this file "
- "which then triggers the VS 10 property dialog bug.";
- /* clang-format on */
- lg->IssueMessage(MessageType::WARNING, e.str());
+ lg->IssueMessage(
+ MessageType::WARNING,
+ cmStrCat(
+ "The binary and/or source directory paths may be too long to generate "
+ "Visual Studio 10 files for this project. "
+ "Consider choosing shorter directory names to build this project with "
+ "Visual Studio 10. "
+ "A more detailed explanation follows."
+ "\n"
+ "There is a bug in the VS 10 IDE that renders property dialog fields "
+ "blank for files referenced by full path in the project file. "
+ "However, CMake must reference at least one file by full path:\n"
+ " ",
+ this->LongestSource.SourceFile->GetFullPath(),
+ "\n"
+ "This is because some Visual Studio tools would append the relative "
+ "path to the end of the referencing directory path, as in:\n"
+ " ",
+ lg->GetCurrentBinaryDirectory(), '/', this->LongestSource.SourceRel,
+ "\n"
+ "and then incorrectly complain that the file does not exist because "
+ "the path length is too long for some internal buffer or API. "
+ "To avoid this problem CMake must use a full path for this file "
+ "which then triggers the VS 10 property dialog bug."));
}
if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue(
"CMAKE_VS_NUGET_PACKAGE_RESTORE")) {
@@ -641,10 +646,10 @@ void cmGlobalVisualStudio10Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
for (std::string const& it : lang) {
- if (it == "ASM_NASM") {
+ if (it == "ASM_NASM"_s) {
this->NasmEnabled = true;
}
- if (it == "CUDA") {
+ if (it == "CUDA"_s) {
this->CudaEnabled = true;
}
}
@@ -830,8 +835,8 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand()
bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
{
// Skip this in special cases within our own test suite.
- if (this->GetPlatformName() == "Test Platform" ||
- this->GetPlatformToolsetString() == "Test Toolset") {
+ if (this->GetPlatformName() == "Test Platform"_s ||
+ this->GetPlatformToolsetString() == "Test Toolset"_s) {
return true;
}
@@ -843,11 +848,11 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
wd = cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
"/CMakeFiles");
}
- wd += "/";
+ wd += '/';
wd += cmVersion::GetCMakeVersion();
// We record the result persistently in a file.
- std::string const txt = wd + "/VCTargetsPath.txt";
+ std::string const txt = cmStrCat(wd, "/VCTargetsPath.txt");
// If we have a recorded result, use it.
{
@@ -861,8 +866,8 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
// Prepare the work directory.
if (!cmSystemTools::MakeDirectory(wd)) {
- std::string e = "Failed to make directory:\n " + wd;
- mf->IssueMessage(MessageType::FATAL_ERROR, e);
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Failed to make directory:\n ", wd));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -870,7 +875,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
// Generate a project file for MSBuild to tell us the VCTargetsPath value.
std::string const vcxproj = "VCTargetsPath.vcxproj";
{
- std::string const vcxprojAbs = wd + "/" + vcxproj;
+ std::string const vcxprojAbs = cmStrCat(wd, '/', vcxproj);
cmsys::ofstream fout(vcxprojAbs.c_str());
cmXMLWriter xw(fout);
@@ -889,7 +894,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
cmXMLElement eig(eprj, "ItemGroup");
eig.Attribute("Label", "ProjectConfigurations");
cmXMLElement epc(eig, "ProjectConfiguration");
- epc.Attribute("Include", "Debug|" + this->GetPlatformName());
+ epc.Attribute("Include", cmStrCat("Debug|", this->GetPlatformName()));
cmXMLElement(epc, "Configuration").Content("Debug");
cmXMLElement(epc, "Platform").Content(this->GetPlatformName());
}
@@ -899,19 +904,19 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
cmXMLElement(epg, "ProjectGuid")
.Content("{F3FC6D86-508D-3FB1-96D2-995F08B142EC}");
cmXMLElement(epg, "Keyword")
- .Content(mf->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"
+ .Content(mf->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"_s
? "Android"
: "Win32Proj");
cmXMLElement(epg, "Platform").Content(this->GetPlatformName());
- if (this->GetSystemName() == "WindowsPhone") {
+ if (this->GetSystemName() == "WindowsPhone"_s) {
cmXMLElement(epg, "ApplicationType").Content("Windows Phone");
cmXMLElement(epg, "ApplicationTypeRevision")
.Content(this->GetApplicationTypeRevision());
- } else if (this->GetSystemName() == "WindowsStore") {
+ } else if (this->GetSystemName() == "WindowsStore"_s) {
cmXMLElement(epg, "ApplicationType").Content("Windows Store");
cmXMLElement(epg, "ApplicationTypeRevision")
.Content(this->GetApplicationTypeRevision());
- } else if (this->GetSystemName() == "Android") {
+ } else if (this->GetSystemName() == "Android"_s) {
cmXMLElement(epg, "ApplicationType").Content("Android");
cmXMLElement(epg, "ApplicationTypeRevision")
.Content(this->GetApplicationTypeRevision());
@@ -920,10 +925,10 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
cmXMLElement(epg, "WindowsTargetPlatformVersion")
.Content(this->WindowsTargetPlatformVersion);
}
- if (this->GetSystemName() != "Android") {
- if (this->GetPlatformName() == "ARM64") {
+ if (this->GetSystemName() != "Android"_s) {
+ if (this->GetPlatformName() == "ARM64"_s) {
cmXMLElement(epg, "WindowsSDKDesktopARM64Support").Content("true");
- } else if (this->GetPlatformName() == "ARM") {
+ } else if (this->GetPlatformName() == "ARM"_s) {
cmXMLElement(epg, "WindowsSDKDesktopARMSupport").Content("true");
}
}
@@ -970,10 +975,9 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
std::vector<std::string> cmd;
cmd.push_back(this->GetMSBuildCommand());
cmd.push_back(vcxproj);
- cmd.push_back("/p:Configuration=Debug");
- cmd.push_back(cmStrCat("/p:Platform=", this->GetPlatformName()));
- cmd.push_back(std::string("/p:VisualStudioVersion=") +
- this->GetIDEVersion());
+ cmd.emplace_back("/p:Configuration=Debug");
+ cmd.emplace_back(cmStrCat("/p:Platform=", this->GetPlatformName()));
+ cmd.emplace_back(cmStrCat("/p:VisualStudioVersion=", this->GetIDEVersion()));
std::string out;
int ret = 0;
cmsys::RegularExpression regex("\n *VCTargetsPath=([^%\r\n]+)[\r\n]");
@@ -1049,7 +1053,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
break;
}
std::string proj = project.GetRelativePath();
- if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
+ if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj"_s) {
useDevEnv = true;
}
}
@@ -1080,7 +1084,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
makeCommand.Add(makeProgramSelected);
cm::optional<cmSlnProjectEntry> proj = cm::nullopt;
- if (tname == "clean") {
+ if (tname == "clean"_s) {
makeCommand.Add(cmStrCat(projectName, ".sln"));
makeCommand.Add("/t:Clean");
} else {
@@ -1104,7 +1108,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
requiresRestore = false;
} else if (cmValue cached =
this->CMakeInstance->GetState()->GetCacheEntryValue(
- tname + "_REQUIRES_VS_PACKAGE_RESTORE")) {
+ cmStrCat(tname, "_REQUIRES_VS_PACKAGE_RESTORE"))) {
requiresRestore = cached.IsOn();
} else {
// There are no package references defined.
@@ -1164,7 +1168,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
std::string extension =
cmSystemTools::GetFilenameLastExtension(proj->GetRelativePath());
extension = cmSystemTools::LowerCase(extension);
- if (extension == ".csproj") {
+ if (extension == ".csproj"_s) {
// Use correct platform name
platform =
slnData.GetConfigurationTarget(tname, plainConfig, platform);
@@ -1271,7 +1275,7 @@ std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion()
std::string cmGlobalVisualStudio10Generator::GetApplicationTypeRevision() const
{
- if (this->GetSystemName() == "Android") {
+ if (this->GetSystemName() == "Android"_s) {
return this->GetAndroidApplicationTypeRevision();
}
@@ -1302,23 +1306,23 @@ static unsigned int cmLoadFlagTableSpecial(Json::Value entry,
if (specials.isArray()) {
for (auto const& special : specials) {
std::string s = special.asString();
- if (s == "UserValue") {
+ if (s == "UserValue"_s) {
value |= cmIDEFlagTable::UserValue;
- } else if (s == "UserIgnored") {
+ } else if (s == "UserIgnored"_s) {
value |= cmIDEFlagTable::UserIgnored;
- } else if (s == "UserRequired") {
+ } else if (s == "UserRequired"_s) {
value |= cmIDEFlagTable::UserRequired;
- } else if (s == "Continue") {
+ } else if (s == "Continue"_s) {
value |= cmIDEFlagTable::Continue;
- } else if (s == "SemicolonAppendable") {
+ } else if (s == "SemicolonAppendable"_s) {
value |= cmIDEFlagTable::SemicolonAppendable;
- } else if (s == "UserFollowing") {
+ } else if (s == "UserFollowing"_s) {
value |= cmIDEFlagTable::UserFollowing;
- } else if (s == "CaseInsensitive") {
+ } else if (s == "CaseInsensitive"_s) {
value |= cmIDEFlagTable::CaseInsensitive;
- } else if (s == "SpaceAppendable") {
+ } else if (s == "SpaceAppendable"_s) {
value |= cmIDEFlagTable::SpaceAppendable;
- } else if (s == "CommaAppendable") {
+ } else if (s == "CommaAppendable"_s) {
value |= cmIDEFlagTable::CommaAppendable;
}
}
@@ -1537,22 +1541,22 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if (toolset == "v142") {
+ if (toolset == "v142"_s) {
return "v142";
}
- if (toolset == "v141") {
+ if (toolset == "v141"_s) {
return "v141";
}
- if (useToolset == "v140") {
+ if (useToolset == "v140"_s) {
return "v140";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
@@ -1563,22 +1567,22 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if (useToolset == "v142") {
+ if (useToolset == "v142"_s) {
return "v142";
}
- if (useToolset == "v141") {
+ if (useToolset == "v141"_s) {
return "v141";
}
- if (useToolset == "v140") {
+ if (useToolset == "v140"_s) {
return "v140";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
@@ -1589,17 +1593,17 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if ((useToolset == "v140") || (useToolset == "v141") ||
- (useToolset == "v142")) {
+ if ((useToolset == "v140"_s) || (useToolset == "v141"_s) ||
+ (useToolset == "v142"_s)) {
return "v14";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
@@ -1610,17 +1614,17 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if ((useToolset == "v140") || (useToolset == "v141") ||
- (useToolset == "v142")) {
+ if ((useToolset == "v140"_s) || (useToolset == "v141"_s) ||
+ (useToolset == "v142"_s)) {
return "v14";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
@@ -1631,22 +1635,22 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if (useToolset == "v142") {
+ if (useToolset == "v142"_s) {
return "v142";
}
- if (useToolset == "v141") {
+ if (useToolset == "v141"_s) {
return "v141";
}
- if (useToolset == "v140") {
+ if (useToolset == "v140"_s) {
return "v140";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
@@ -1657,17 +1661,17 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const
std::string const& toolset = this->GetPlatformToolsetString();
std::string const useToolset = this->CanonicalToolsetName(toolset);
- if ((useToolset == "v140") || (useToolset == "v141") ||
- (useToolset == "v142")) {
+ if ((useToolset == "v140"_s) || (useToolset == "v141"_s) ||
+ (useToolset == "v142"_s)) {
return "v14";
}
- if (useToolset == "v120") {
+ if (useToolset == "v120"_s) {
return "v12";
}
- if (useToolset == "v110") {
+ if (useToolset == "v110"_s) {
return "v11";
}
- if (useToolset == "v100") {
+ if (useToolset == "v100"_s) {
return "v10";
}
return "";
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index c4e1e11..0ec5e8b 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -3,10 +3,11 @@
#include "cmGlobalVisualStudio11Generator.h"
#include <cstring>
-#include <sstream>
#include <utility>
#include <vector>
+#include <cmext/string_view>
+
#include "cmGlobalGenerator.h"
#include "cmGlobalVisualStudioGenerator.h"
#include "cmMakefile.h"
@@ -25,7 +26,7 @@ void cmGlobalVisualStudio11Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
for (std::string const& it : lang) {
- if (it == "ASM_MARMASM") {
+ if (it == "ASM_MARMASM"_s) {
this->MarmasmEnabled = true;
}
}
@@ -36,16 +37,18 @@ void cmGlobalVisualStudio11Generator::EnableLanguage(
bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
{
if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
- std::ostringstream e;
+ std::string e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName() << " supports Windows Phone '8.0', but not '"
- << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
+ e = cmStrCat(this->GetName(), " supports Windows Phone '8.0', but not '",
+ this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
} else {
- e << "A Windows Phone component with CMake requires both the Windows "
- << "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
- << "' SDK. Please make sure that you have both installed";
+ e = cmStrCat(
+ "A Windows Phone component with CMake requires both the Windows "
+ "Desktop SDK as well as the Windows Phone '",
+ this->SystemVersion,
+ "' SDK. Please make sure that you have both installed");
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
return true;
@@ -54,16 +57,18 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
{
if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
- std::ostringstream e;
+ std::string e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName() << " supports Windows Store '8.0', but not '"
- << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
+ e = cmStrCat(this->GetName(), " supports Windows Store '8.0', but not '",
+ this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
} else {
- e << "A Windows Store component with CMake requires both the Windows "
- << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
- << "' SDK. Please make sure that you have both installed";
+ e = cmStrCat(
+ "A Windows Store component with CMake requires both the Windows "
+ "Desktop SDK as well as the Windows Store '",
+ this->SystemVersion,
+ "' SDK. Please make sure that you have both installed");
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
return true;
@@ -72,7 +77,7 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
std::string& toolset) const
{
- if (this->SystemVersion == "8.0") {
+ if (this->SystemVersion == "8.0"_s) {
if (this->IsWindowsPhoneToolsetInstalled() &&
this->IsWindowsDesktopToolsetInstalled()) {
toolset = "v110_wp80";
@@ -87,7 +92,7 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
std::string& toolset) const
{
- if (this->SystemVersion == "8.0") {
+ if (this->SystemVersion == "8.0"_s) {
if (this->IsWindowsStoreToolsetInstalled() &&
this->IsWindowsDesktopToolsetInstalled()) {
toolset = "v110";
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index b7af31b..1f1a2c3 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -6,6 +6,8 @@
#include <sstream>
#include <vector>
+#include <cmext/string_view>
+
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmGlobalVisualStudioGenerator.h"
@@ -63,7 +65,7 @@ public:
cmDocumentationEntry GetDocumentation() const override
{
- return { std::string(vs12generatorName) + " [arch]",
+ return { cmStrCat(vs12generatorName, " [arch]"),
"Deprecated. Generates Visual Studio 2013 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\"." };
}
@@ -78,8 +80,8 @@ public:
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
- names.push_back(vs12generatorName + std::string(" ARM"));
- names.push_back(vs12generatorName + std::string(" Win64"));
+ names.emplace_back(cmStrCat(vs12generatorName, " ARM"));
+ names.emplace_back(cmStrCat(vs12generatorName, " Win64"));
return names;
}
@@ -137,8 +139,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName(
bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
- if (key == "host" &&
- (value == "x64" || value == "x86" || value == "ARM64")) {
+ if (key == "host"_s &&
+ (value == "x64"_s || value == "x86"_s || value == "ARM64"_s)) {
this->GeneratorToolsetHostArchitecture = value;
return true;
}
@@ -149,18 +151,20 @@ bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField(
bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
{
if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
- std::ostringstream e;
+ std::string e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName()
- << " supports Windows Phone '8.0' and '8.1', but "
- "not '"
- << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
+ e = cmStrCat(this->GetName(),
+ " supports Windows Phone '8.0' and '8.1', but "
+ "not '",
+ this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
} else {
- e << "A Windows Phone component with CMake requires both the Windows "
- << "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
- << "' SDK. Please make sure that you have both installed";
+ e = cmStrCat(
+ "A Windows Phone component with CMake requires both the Windows "
+ "Desktop SDK as well as the Windows Phone '",
+ this->SystemVersion,
+ "' SDK. Please make sure that you have both installed");
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
return true;
@@ -169,18 +173,20 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
{
if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
- std::ostringstream e;
+ std::string e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName()
- << " supports Windows Store '8.0' and '8.1', but "
- "not '"
- << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
+ e = cmStrCat(this->GetName(),
+ " supports Windows Store '8.0' and '8.1', but "
+ "not '",
+ this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
} else {
- e << "A Windows Store component with CMake requires both the Windows "
- << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
- << "' SDK. Please make sure that you have both installed";
+ e = cmStrCat(
+ "A Windows Store component with CMake requires both the Windows "
+ "Desktop SDK as well as the Windows Store '",
+ this->SystemVersion,
+ "' SDK. Please make sure that you have both installed");
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
return true;
@@ -189,7 +195,7 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
bool cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset(
std::string& toolset) const
{
- if (this->SystemVersion == "8.1") {
+ if (this->SystemVersion == "8.1"_s) {
if (this->IsWindowsPhoneToolsetInstalled() &&
this->IsWindowsDesktopToolsetInstalled()) {
toolset = "v120_wp81";
@@ -204,7 +210,7 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset(
bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
std::string& toolset) const
{
- if (this->SystemVersion == "8.1") {
+ if (this->SystemVersion == "8.1"_s) {
if (this->IsWindowsStoreToolsetInstalled() &&
this->IsWindowsDesktopToolsetInstalled()) {
toolset = "v120";
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 4300d5c..9f1926d 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -6,6 +6,7 @@
#include <sstream>
#include <cm/vector>
+#include <cmext/string_view>
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
@@ -66,7 +67,7 @@ public:
cmDocumentationEntry GetDocumentation() const override
{
- return { std::string(vs14generatorName) + " [arch]",
+ return { cmStrCat(vs14generatorName, " [arch]"),
"Generates Visual Studio 2015 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\"." };
}
@@ -81,8 +82,8 @@ public:
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
- names.push_back(vs14generatorName + std::string(" ARM"));
- names.push_back(vs14generatorName + std::string(" Win64"));
+ names.emplace_back(cmStrCat(vs14generatorName, " ARM"));
+ names.emplace_back(cmStrCat(vs14generatorName, " Win64"));
return names;
}
@@ -160,11 +161,11 @@ bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion(
"given platform specification containing a\n"
" version=" << *this->GeneratorPlatformVersion << "\n"
"field. The version field is not supported when targeting\n"
- " " << this->SystemName << " " << this->SystemVersion << "\n"
+ " " << this->SystemName << ' ' << this->SystemVersion << '\n'
;
/* clang-format on */
if (reason) {
- e << *reason << ".";
+ e << *reason << '.';
}
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
@@ -172,19 +173,21 @@ bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion(
bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
{
- std::ostringstream e;
if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
+ std::string e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName()
- << " supports Windows Store '8.0', '8.1' and "
- "'10.0', but not '"
- << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
+ e = cmStrCat(this->GetName(),
+ " supports Windows Store '8.0', '8.1' and "
+ "'10.0', but not '",
+ this->SystemVersion, "'. Check CMAKE_SYSTEM_VERSION.");
} else {
- e << "A Windows Store component with CMake requires both the Windows "
- << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
- << "' SDK. Please make sure that you have both installed";
+ e = cmStrCat(
+ "A Windows Store component with CMake requires both the Windows "
+ "Desktop SDK as well as the Windows Store '",
+ this->SystemVersion,
+ "' SDK. Please make sure that you have both installed");
}
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
return true;
@@ -198,7 +201,7 @@ bool cmGlobalVisualStudio14Generator::InitializeAndroid(cmMakefile*)
bool cmGlobalVisualStudio14Generator::ProcessGeneratorPlatformField(
std::string const& key, std::string const& value)
{
- if (key == "version") {
+ if (key == "version"_s) {
this->GeneratorPlatformVersion = value;
return true;
}
@@ -231,7 +234,7 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
return false;
}
- if (this->SystemName == "WindowsStore") {
+ if (this->SystemName == "WindowsStore"_s) {
mf->IssueMessage(
MessageType::FATAL_ERROR,
"Could not find an appropriate version of the Windows 10 SDK"
@@ -250,10 +253,11 @@ void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion(
this->WindowsTargetPlatformVersion = version;
if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion,
this->SystemVersion)) {
- std::ostringstream e;
- e << "Selecting Windows SDK version " << this->WindowsTargetPlatformVersion
- << " to target Windows " << this->SystemVersion << ".";
- mf->DisplayStatus(e.str(), -1);
+ mf->DisplayStatus(cmStrCat("Selecting Windows SDK version ",
+ this->WindowsTargetPlatformVersion,
+ " to target Windows ", this->SystemVersion,
+ '.'),
+ -1);
}
mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
this->WindowsTargetPlatformVersion);
@@ -333,7 +337,7 @@ struct NoWindowsH
{
bool operator()(std::string const& p)
{
- return !cmSystemTools::FileExists(p + "/um/windows.h", true);
+ return !cmSystemTools::FileExists(cmStrCat(p, "/um/windows.h"), true);
}
};
class WindowsSDKTooRecent
@@ -361,7 +365,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion(
std::string const& ver = *this->GeneratorPlatformVersion;
// VS 2019 and above support specifying plain "10.0".
- if (this->Version >= VSVersion::VS16 && ver == "10.0") {
+ if (this->Version >= VSVersion::VS16 && ver == "10.0"_s) {
return ver;
}
}
@@ -400,7 +404,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion(
std::vector<std::string> sdks;
// Grab the paths of the different SDKs that are installed
for (std::string const& i : win10Roots) {
- std::string path = i + "/Include/*";
+ std::string path = cmStrCat(i, "/Include/*");
cmSystemTools::GlobDirs(path, sdks);
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index bcb26cc..8375b72 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -86,7 +86,7 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
{
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
for (std::string const& i : configs) {
- fout << "\t\t" << i << " = " << i << "\n";
+ fout << "\t\t" << i << " = " << i << '\n';
}
fout << "\tEndGlobalSection\n";
}
@@ -136,9 +136,9 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
<< uname << ".vcproj" << "\", \"{"
<< this->GetGUID(uname) << "}\"\n"
<< "\tProjectSection(ProjectDependencies) = postProject\n"
- << "\t\t{" << guid << "} = {" << guid << "}\n"
- << "\tEndProjectSection\n"
- << "EndProject\n";
+ "\t\t{" << guid << "} = {" << guid << "}\n"
+ "\tEndProjectSection\n"
+ "EndProject\n";
/* clang-format on */
}
}
@@ -209,19 +209,19 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
cmList mapConfig;
const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
- if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(i))) {
+ if (cmValue m = target.GetProperty(
+ cmStrCat("MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(i)))) {
mapConfig.assign(*m);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|"
+ fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << '|'
<< platformName << std::endl;
auto ci = configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|"
+ fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << '|'
<< platformName << std::endl;
}
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 203bb09..b2657a7 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -158,7 +158,7 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
std::string vskey;
// Search in standard location.
- vskey = this->GetRegistryBase() + ";InstallDir";
+ vskey = cmStrCat(this->GetRegistryBase(), ";InstallDir");
if (cmSystemTools::ReadRegistryValue(vskey, vscmd,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(vscmd);
@@ -189,25 +189,25 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
const std::string& location)
{
std::string extension = cmSystemTools::GetFilenameLastExtension(location);
- if (extension == ".vbproj") {
+ if (extension == ".vbproj"_s) {
return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
}
- if (extension == ".csproj") {
+ if (extension == ".csproj"_s) {
return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
}
- if (extension == ".fsproj") {
+ if (extension == ".fsproj"_s) {
return "F2A71F9B-5D33-465A-A702-920D77279786";
}
- if (extension == ".vdproj") {
+ if (extension == ".vdproj"_s) {
return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
}
- if (extension == ".dbproj") {
+ if (extension == ".dbproj"_s) {
return "C8D11400-126E-41CD-887F-60BD40844F9E";
}
- if (extension == ".wixproj") {
+ if (extension == ".wixproj"_s) {
return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
}
- if (extension == ".pyproj") {
+ if (extension == ".pyproj"_s) {
return "888888A0-9F3D-457C-B088-3A5042F75D52";
}
return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
@@ -252,14 +252,14 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand(
continue;
}
bool clean = false;
- if (realTarget == "clean") {
+ if (realTarget == "clean"_s) {
clean = true;
realTarget = "ALL_BUILD";
}
GeneratedMakeCommand makeCommand;
makeCommand.RequiresOutputForward = requiresOutputForward;
makeCommand.Add(makeProgramSelected);
- makeCommand.Add(projectName + ".sln");
+ makeCommand.Add(cmStrCat(projectName, ".sln"));
makeCommand.Add((clean ? "/clean" : "/build"));
makeCommand.Add((config.empty() ? "Debug" : config));
makeCommand.Add("/project");
@@ -459,7 +459,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
dir = root->MaybeRelativeToCurBinDir(dir);
- if (dir == ".") {
+ if (dir == "."_s) {
dir.clear(); // msbuild cannot handle ".\" prefix
}
this->WriteProject(fout, *vcprojName, dir, target);
@@ -483,12 +483,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
}
if (cumulativePath.empty()) {
- cumulativePath = "CMAKE_FOLDER_GUID_" + iter;
+ cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter);
} else {
- VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" +
- iter);
+ VisualStudioFolders[cumulativePath].insert(
+ cmStrCat(cumulativePath, '/', iter));
- cumulativePath = cumulativePath + "/" + iter;
+ cumulativePath = cmStrCat(cumulativePath, '/', iter);
}
}
@@ -552,7 +552,8 @@ std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
std::ostream& fout, cmLocalGenerator* root)
{
- std::string const guid = this->GetGUID(root->GetProjectName() + ".sln");
+ std::string const guid =
+ this->GetGUID(cmStrCat(root->GetProjectName(), ".sln"));
bool extensibilityGlobalsOverridden = false;
bool extensibilityAddInsOverridden = false;
const std::vector<std::string> propKeys =
@@ -572,14 +573,15 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
}
if (!name.empty()) {
bool addGuid = false;
- if (name == "ExtensibilityGlobals" && sectionType == "postSolution") {
+ if (name == "ExtensibilityGlobals"_s &&
+ sectionType == "postSolution"_s) {
addGuid = true;
extensibilityGlobalsOverridden = true;
- } else if (name == "ExtensibilityAddIns" &&
- sectionType == "postSolution") {
+ } else if (name == "ExtensibilityAddIns"_s &&
+ sectionType == "postSolution"_s) {
extensibilityAddInsOverridden = true;
}
- fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
+ fout << "\tGlobalSection(" << name << ") = " << sectionType << '\n';
cmValue p = root->GetMakefile()->GetProperty(it);
cmList keyValuePairs{ *p };
for (std::string const& itPair : keyValuePairs) {
@@ -589,8 +591,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
cmTrimWhitespace(itPair.substr(0, posEqual));
const std::string value =
cmTrimWhitespace(itPair.substr(posEqual + 1));
- fout << "\t\t" << key << " = " << value << "\n";
- if (key == "SolutionGuid") {
+ fout << "\t\t" << key << " = " << value << '\n';
+ if (key == "SolutionGuid"_s) {
addGuid = false;
}
}
@@ -679,7 +681,7 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
{
- std::string const& guidStoreName = name + "_GUID_CMAKE";
+ std::string const& guidStoreName = cmStrCat(name, "_GUID_CMAKE");
if (cmValue storedGUID =
this->CMakeInstance->GetCacheDefinition(guidStoreName)) {
return *storedGUID;
@@ -704,9 +706,7 @@ void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig(
const std::string& suffix, std::string& dir)
{
if (!config.empty()) {
- dir += prefix;
- dir += config;
- dir += suffix;
+ dir += cmStrCat(prefix, config, suffix);
}
}
@@ -727,7 +727,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
// check if target <t> is part of default build
if (target->GetName() == t) {
const std::string propertyName =
- "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD";
+ cmStrCat("CMAKE_VS_INCLUDE_", t, "_TO_DEFAULT_BUILD");
// inspect CMAKE_VS_INCLUDE_<t>_TO_DEFAULT_BUILD properties
for (std::string const& i : configs) {
cmValue propertyValue =
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index acb20d1..2e87502 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -304,7 +304,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
for (const auto& gi : generators) {
stampFile = cmStrCat(gi->GetMakefile()->GetCurrentBinaryDirectory(),
"/CMakeFiles/generate.stamp");
- fout << stampFile << "\n";
+ fout << stampFile << '\n';
stamps.push_back(stampFile);
}
}
@@ -341,7 +341,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
std::string argS = cmStrCat("-S", lg.GetSourceDirectory());
std::string argB = cmStrCat("-B", lg.GetBinaryDirectory());
std::string const sln =
- lg.GetBinaryDirectory() + "/" + lg.GetProjectName() + ".sln";
+ cmStrCat(lg.GetBinaryDirectory(), '/', lg.GetProjectName(), ".sln");
cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
{ cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-list",
stampList, "--vs-solution-file", sln });
@@ -364,7 +364,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
lg.AddCustomCommandToOutput(std::move(cc), true)) {
gt->AddSource(file->ResolveFullPath());
} else {
- cmSystemTools::Error("Error adding rule for " + stamps[0]);
+ cmSystemTools::Error(cmStrCat("Error adding rule for ", stamps[0]));
}
}
@@ -392,8 +392,8 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
{
fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
for (std::string const& i : configs) {
- fout << "\t\t" << i << "|" << this->GetPlatformName() << " = " << i << "|"
- << this->GetPlatformName() << "\n";
+ fout << "\t\t" << i << '|' << this->GetPlatformName() << " = " << i << '|'
+ << this->GetPlatformName() << '\n';
}
fout << "\tEndGlobalSection\n";
}
@@ -409,33 +409,33 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
cmList mapConfig;
const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
- if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(i))) {
+ if (cmValue m = target.GetProperty(
+ cmStrCat("MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(i)))) {
mapConfig.assign(*m);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
- << ".ActiveCfg = " << dstConfig << "|"
+ fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+ << ".ActiveCfg = " << dstConfig << '|'
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
- << "\n";
+ << '\n';
auto ci = configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
- << ".Build.0 = " << dstConfig << "|"
+ fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+ << ".Build.0 = " << dstConfig << '|'
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
- << "\n";
+ << '\n';
}
if (this->NeedsDeploy(target, dstConfig)) {
- fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
- << ".Deploy.0 = " << dstConfig << "|"
+ fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+ << ".Deploy.0 = " << dstConfig << '|'
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
- << "\n";
+ << '\n';
}
}
}
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index e396405..de2153d 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -9,6 +9,7 @@
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmGlobalVisualStudioGenerator.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVisualStudioWCEPlatformParser.h"
@@ -63,7 +64,7 @@ public:
cmDocumentationEntry GetDocumentation() const override
{
- return { std::string(vs9generatorName) + " [arch]",
+ return { cmStrCat(vs9generatorName, " [arch]"),
"Deprecated. Generates Visual Studio 2008 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\"." };
}
@@ -71,21 +72,21 @@ public:
std::vector<std::string> GetGeneratorNames() const override
{
std::vector<std::string> names;
- names.push_back(vs9generatorName);
+ names.emplace_back(vs9generatorName);
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
- names.push_back(vs9generatorName + std::string(" Win64"));
- names.push_back(vs9generatorName + std::string(" IA64"));
+ names.emplace_back(cmStrCat(vs9generatorName, " Win64"));
+ names.emplace_back(cmStrCat(vs9generatorName, " IA64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for (std::string const& i : availablePlatforms) {
- names.push_back("Visual Studio 9 2008 " + i);
+ names.emplace_back(cmStrCat("Visual Studio 9 2008 ", i));
}
return names;
}
@@ -144,7 +145,7 @@ std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
cmSystemTools::ConvertToUnixSlashes(base);
// 9.0 macros folder:
- path = base + "/VSMacros80";
+ path = cmStrCat(base, "/VSMacros80");
// *NOT* a typo; right now in Visual Studio 2008 beta the macros
// folder is VSMacros80... They may change it to 90 before final
// release of 2008 or they may not... we'll have to keep our eyes
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 4d7571a..5305fec 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -12,6 +12,7 @@
#include <cm/iterator>
#include <cm/memory>
+#include <cmext/string_view>
#include <windows.h>
@@ -78,9 +79,9 @@ bool cmGlobalVisualStudioGenerator::SetGeneratorPlatform(std::string const& p,
if (!this->InitializePlatform(mf)) {
return false;
}
- if (this->GetPlatformName() == "x64") {
+ if (this->GetPlatformName() == "x64"_s) {
mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
- } else if (this->GetPlatformName() == "Itanium") {
+ } else if (this->GetPlatformName() == "Itanium"_s) {
mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
}
mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
@@ -184,8 +185,8 @@ std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
std::string cmGlobalVisualStudioGenerator::GetRegistryBase(const char* version)
{
- std::string key = R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\)";
- return key + version;
+ return cmStrCat(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\)",
+ version);
}
void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
@@ -242,12 +243,12 @@ void cmGlobalVisualStudioGenerator::ComputeTargetObjectDirectory(
std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt);
if (!tgtDir.empty()) {
dir += tgtDir;
- dir += "/";
+ dir += '/';
}
const char* cd = this->GetCMakeCFGIntDir();
if (cd && *cd) {
dir += cd;
- dir += "/";
+ dir += '/';
}
gt->ObjectDirectory = dir;
}
@@ -274,7 +275,7 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
std::string src = cmStrCat(cmSystemTools::GetCMakeRoot(),
"/Templates/" CMAKE_VSMACROS_FILENAME);
- std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
+ std::string dst = cmStrCat(dir, "/CMakeMacros/" CMAKE_VSMACROS_FILENAME);
// Copy the macros file to the user directory only if the
// destination does not exist or the source location is newer.
@@ -285,8 +286,8 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) {
if (!cmSystemTools::CopyFileAlways(src, dst)) {
std::ostringstream oss;
- oss << "Could not copy from: " << src << std::endl;
- oss << " to: " << dst << std::endl;
+ oss << "Could not copy from: " << src << std::endl
+ << " to: " << dst << std::endl;
cmSystemTools::Message(oss.str(), "Warning");
}
}
@@ -309,7 +310,8 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
// - there were .sln/.vcproj files changed during generation
//
if (!dir.empty()) {
- std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
+ std::string macrosFile =
+ cmStrCat(dir, "/CMakeMacros/" CMAKE_VSMACROS_FILENAME);
std::string nextSubkeyName;
if (cmSystemTools::FileExists(macrosFile) &&
IsVisualStudioMacrosFileRegistered(
@@ -518,9 +520,9 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
}
root->GetMakefile()->IssueMessage(
MessageType::AUTHOR_WARNING,
- "Directory property VS_STARTUP_PROJECT specifies target "
- "'" +
- startup + "' that does not exist. Ignoring.");
+ cmStrCat("Directory property VS_STARTUP_PROJECT specifies target "
+ "'",
+ startup, "' that does not exist. Ignoring."));
}
// default, if not specified
@@ -546,7 +548,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
LONG result = ERROR_SUCCESS;
DWORD index = 0;
- keyname = regKeyBase + "\\OtherProjects7";
+ keyname = cmStrCat(regKeyBase, "\\OtherProjects7");
hkey = nullptr;
result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
@@ -638,7 +640,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
// as the name of the next subkey.
nextAvailableSubKeyName = std::to_string(index);
- keyname = regKeyBase + "\\RecordingProject7";
+ keyname = cmStrCat(regKeyBase, "\\RecordingProject7");
hkey = nullptr;
result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
@@ -684,7 +686,7 @@ void WriteVSMacrosFileRegistryEntry(const std::string& nextAvailableSubKeyName,
const std::string& macrosFile,
const std::string& regKeyBase)
{
- std::string keyname = regKeyBase + "\\OtherProjects7";
+ std::string keyname = cmStrCat(regKeyBase, "\\OtherProjects7");
HKEY hkey = nullptr;
LONG result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
@@ -819,7 +821,7 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
// Intel Fortran .vfproj files do support the resource compiler.
languages.erase("RC");
- return languages.size() == 1 && *languages.begin() == "Fortran";
+ return languages.size() == 1 && *languages.begin() == "Fortran"_s;
}
bool cmGlobalVisualStudioGenerator::IsInSolution(
@@ -905,10 +907,10 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(),
configName.c_str());
cmSystemTools::MakeDirectory(obj_dir_expanded);
- std::string const objs_file = obj_dir_expanded + "/objects.txt";
+ std::string const objs_file = cmStrCat(obj_dir_expanded, "/objects.txt");
cmGeneratedFileStream fout(objs_file.c_str());
if (!fout) {
- cmSystemTools::Error("could not open " + objs_file);
+ cmSystemTools::Error(cmStrCat("could not open ", objs_file));
return;
}
@@ -919,7 +921,7 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
// It must exist because we populated the mapping just above.
const auto& v = mapping[it];
assert(!v.empty());
- std::string objFile = obj_dir + v;
+ std::string objFile = cmStrCat(obj_dir, v);
objs.push_back(objFile);
}
std::vector<cmSourceFile const*> externalObjectSources;
@@ -975,7 +977,7 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir,
const std::string& projectName,
bool dryRun)
{
- std::string sln = bindir + "/" + projectName + ".sln";
+ std::string sln = cmStrCat(bindir, '/', projectName, ".sln");
if (dryRun) {
return cmSystemTools::FileExists(sln, true);
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 9fe66d3..52e6d42 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -211,7 +211,7 @@ static const char* cmVS15GenName(const std::string& name, std::string& genName)
if (cmHasLiteralPrefix(p, " 2017")) {
p += 5;
}
- genName = std::string(vs15generatorName) + p;
+ genName = cmStrCat(vs15generatorName, p);
return p;
}
@@ -250,7 +250,7 @@ public:
cmDocumentationEntry GetDocumentation() const override
{
- return { std::string(vs15generatorName) + " [arch]",
+ return { cmStrCat(vs15generatorName, " [arch]"),
"Generates Visual Studio 2017 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\"." };
}
@@ -265,8 +265,8 @@ public:
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
std::vector<std::string> names;
- names.push_back(vs15generatorName + std::string(" ARM"));
- names.push_back(vs15generatorName + std::string(" Win64"));
+ names.emplace_back(cmStrCat(vs15generatorName, " ARM"));
+ names.emplace_back(cmStrCat(vs15generatorName, " Win64"));
return names;
}
@@ -306,7 +306,7 @@ static const char* cmVS16GenName(const std::string& name, std::string& genName)
if (cmHasLiteralPrefix(p, " 2019")) {
p += 5;
}
- genName = std::string(vs16generatorName) + p;
+ genName = cmStrCat(vs16generatorName, p);
return p;
}
@@ -320,7 +320,7 @@ static const char* cmVS17GenName(const std::string& name, std::string& genName)
if (cmHasLiteralPrefix(p, " 2022")) {
p += 5;
}
- genName = std::string(vs17generatorName) + p;
+ genName = cmStrCat(vs17generatorName, p);
return p;
}
@@ -524,20 +524,21 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
if (!this->GeneratorInstanceVersion.empty()) {
std::string const majorStr = VSVersionToMajorString(this->Version);
cmsys::RegularExpression versionRegex(
- cmStrCat("^", majorStr, R"(\.[0-9]+\.[0-9]+\.[0-9]+$)"));
+ cmStrCat('^', majorStr, R"(\.[0-9]+\.[0-9]+\.[0-9]+$)"));
if (!versionRegex.find(this->GeneratorInstanceVersion)) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given instance specification\n"
- " " << i << "\n"
- "but the version field is not 4 integer components"
- " starting in " << majorStr << "."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given instance specification\n"
+ " ",
+ i,
+ "\n"
+ "but the version field is not 4 integer components"
+ " starting in ",
+ majorStr, '.'));
return false;
}
}
@@ -566,14 +567,13 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
return false;
}
} else if (!this->vsSetupAPIHelper.GetVSInstanceInfo(vsInstance)) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "could not find any instance of Visual Studio.\n";
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "could not find any instance of Visual Studio.\n"));
return false;
}
@@ -619,47 +619,47 @@ bool cmGlobalVisualStudioVersionedGenerator::ParseGeneratorInstance(
for (; fi != fields.end(); ++fi) {
std::string::size_type pos = fi->find('=');
if (pos == fi->npos) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given instance specification\n"
- " " << is << "\n"
- "that contains a field after the first ',' with no '='."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given instance specification\n"
+ " ",
+ is,
+ "\n"
+ "that contains a field after the first ',' with no '='."));
return false;
}
std::string const key = fi->substr(0, pos);
std::string const value = fi->substr(pos + 1);
if (!handled.insert(key).second) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given instance specification\n"
- " " << is << "\n"
- "that contains duplicate field key '" << key << "'."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given instance specification\n"
+ " ",
+ is,
+ "\n"
+ "that contains duplicate field key '",
+ key, "'."));
return false;
}
if (!this->ProcessGeneratorInstanceField(key, value)) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "given instance specification\n"
- " " << is << "\n"
- "that contains invalid field '" << *fi << "'."
- ;
- /* clang-format on */
- mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("Generator\n"
+ " ",
+ this->GetName(),
+ "\n"
+ "given instance specification\n"
+ " ",
+ is,
+ "\n"
+ "that contains invalid field '",
+ *fi, "'."));
return false;
}
}
@@ -677,7 +677,7 @@ void cmGlobalVisualStudioVersionedGenerator::SetVSVersionVar(cmMakefile* mf)
bool cmGlobalVisualStudioVersionedGenerator::ProcessGeneratorInstanceField(
std::string const& key, std::string const& value)
{
- if (key == "version") {
+ if (key == "version"_s) {
this->GeneratorInstanceVersion = value;
return true;
}
@@ -868,13 +868,13 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset(
// Accept known SxS props file names using four version components
// in VS versions later than the current.
- if (version == "14.28.16.9" && vcToolsetVersion == "14.28.29910") {
+ if (version == "14.28.16.9"_s && vcToolsetVersion == "14.28.29910"_s) {
return AuxToolset::Default;
}
- if (version == "14.29.16.10" && vcToolsetVersion == "14.29.30037") {
+ if (version == "14.29.16.10"_s && vcToolsetVersion == "14.29.30037"_s) {
return AuxToolset::Default;
}
- if (version == "14.29.16.11" && vcToolsetVersion == "14.29.30133") {
+ if (version == "14.29.16.11"_s && vcToolsetVersion == "14.29.30133"_s) {
return AuxToolset::Default;
}
@@ -956,8 +956,8 @@ bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const
"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
"Windows Kits\\Installed Roots;KitsRoot81",
win81Root, cmSystemTools::KeyWOW64_32)) {
- return cmSystemTools::FileExists(win81Root + "/include/um/windows.h",
- true);
+ return cmSystemTools::FileExists(
+ cmStrCat(win81Root, "/include/um/windows.h"), true);
}
return false;
}
@@ -990,29 +990,29 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand()
if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17) {
if (VSIsArm64Host()) {
if (VSHasDotNETFrameworkArm64()) {
- msbuild = vs + "/MSBuild/Current/Bin/arm64/MSBuild.exe";
+ msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/arm64/MSBuild.exe");
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
}
}
if (VSIsWindows11OrGreater()) {
- msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe";
+ msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/amd64/MSBuild.exe");
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
}
}
} else {
- msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe";
+ msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/amd64/MSBuild.exe");
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
}
}
}
- msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe";
+ msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/MSBuild.exe");
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
}
- msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe";
+ msbuild = cmStrCat(vs, "/MSBuild/15.0/Bin/MSBuild.exe");
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
}
@@ -1029,7 +1029,7 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindDevEnvCommand()
// Ask Visual Studio Installer tool.
std::string vs;
if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
- devenv = vs + "/Common7/IDE/devenv.com";
+ devenv = cmStrCat(vs, "/Common7/IDE/devenv.com");
if (cmSystemTools::FileExists(devenv)) {
return devenv;
}
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index ed44e6b..ca7a1b9 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -4,6 +4,9 @@
#include <ostream>
+#include <cm/string_view>
+#include <cmext/string_view>
+
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
@@ -46,7 +49,7 @@ void cmGlobalWatcomWMakeGenerator::EnableLanguage(
bool cmGlobalWatcomWMakeGenerator::SetSystemName(std::string const& s,
cmMakefile* mf)
{
- if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86") {
+ if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86"_s) {
mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl");
}
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 8fe6677..165f0fd 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalVisualStudio10Generator.h"
+#include <cmext/string_view>
+
#include <cm3p/expat.h>
#include "cmGlobalGenerator.h"
@@ -37,7 +39,7 @@ public:
if (!this->GUID.empty()) {
return;
}
- if ("ProjectGUID" == name || "ProjectGuid" == name) {
+ if (name == "ProjectGUID"_s || name == "ProjectGuid"_s) {
this->DoGUID = true;
}
}
@@ -93,7 +95,7 @@ void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
// save the GUID in the cache
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
- guidStoreName, parser.GUID.c_str(), "Stored GUID", cmStateEnums::INTERNAL);
+ guidStoreName, parser.GUID, "Stored GUID", cmStateEnums::INTERNAL);
}
const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 24ef5c2..ef8a7e2 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -283,7 +283,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
file->ResolveFullPath();
return file;
}
- cmSystemTools::Error("Error adding rule for " + makefileIn);
+ cmSystemTools::Error(cmStrCat("Error adding rule for ", makefileIn));
return nullptr;
}
@@ -673,8 +673,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
: target->GetLinkerLanguage(configName));
if (linkLanguage.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: " +
- target->GetName());
+ cmStrCat("CMake can not determine linker language for target: ",
+ target->GetName()));
return;
}
langForClCompile = linkLanguage;
@@ -961,7 +961,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
{
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string extraLinkOptionsBuildTypeDef =
- rootLinkerFlags + "_" + configTypeUpper;
+ cmStrCat(rootLinkerFlags, '_', configTypeUpper);
const std::string& extraLinkOptionsBuildType =
this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef);
@@ -978,31 +978,31 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
std::string temp;
std::string extraLinkOptions;
if (target->GetType() == cmStateEnums::EXECUTABLE) {
- extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + " " +
- GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
+ extraLinkOptions = cmStrCat(
+ 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") +
- " " + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
+ extraLinkOptions = cmStrCat(
+ this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"), ' ',
+ GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName));
}
if (target->GetType() == cmStateEnums::MODULE_LIBRARY) {
- extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") +
- " " + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
+ extraLinkOptions = cmStrCat(
+ this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"), ' ',
+ GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName));
}
cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- extraLinkOptions += " ";
+ extraLinkOptions += ' ';
extraLinkOptions += *targetLinkFlags;
}
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
targetLinkFlags = target->GetProperty(linkFlagsConfig);
if (targetLinkFlags) {
- extraLinkOptions += " ";
+ extraLinkOptions += ' ';
extraLinkOptions += *targetLinkFlags;
}
@@ -1285,7 +1285,8 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
<< "\"/>\n";
if (dir) {
- std::string const exe = *dir + "\\" + target->GetFullName(config);
+ std::string const exe =
+ cmStrCat(*dir, '\\', target->GetFullName(config));
fout << "\t\t\t<DebuggerTool\n"
"\t\t\t\tRemoteExecutable=\""
@@ -1369,8 +1370,9 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
// First search a configuration-specific subdirectory and then the
// original directory.
fout << comma
- << this->ConvertToXMLOutputPath(dir + "/$(ConfigurationName)") << ","
- << this->ConvertToXMLOutputPath(dir);
+ << this->ConvertToXMLOutputPath(
+ cmStrCat(dir, "/$(ConfigurationName)"))
+ << ',' << this->ConvertToXMLOutputPath(dir);
comma = ",";
}
}
@@ -1550,11 +1552,11 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
switch (cmOutputConverter::GetFortranFormat(
sf.GetSafeProperty("Fortran_FORMAT"))) {
case cmOutputConverter::FortranFormatFixed:
- fc.CompileFlags = "-fixed " + fc.CompileFlags;
+ fc.CompileFlags = cmStrCat("-fixed ", fc.CompileFlags);
needfc = true;
break;
case cmOutputConverter::FortranFormatFree:
- fc.CompileFlags = "-free " + fc.CompileFlags;
+ fc.CompileFlags = cmStrCat("-free ", fc.CompileFlags);
needfc = true;
break;
default:
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 58d46f1..34b8ae3 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -5,6 +5,7 @@
#include <utility>
#include <cm/memory>
+#include <cmext/string_view>
#include "windows.h"
@@ -204,7 +205,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
std::string suffix;
if (cmd.size() > 4) {
suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
- if (suffix == ".bat" || suffix == ".cmd") {
+ if (suffix == ".bat"_s || suffix == ".cmd"_s) {
script += "call ";
}
}
diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx
index 4fcaedf..91a7b84 100644
--- a/Source/cmMachO.cxx
+++ b/Source/cmMachO.cxx
@@ -69,7 +69,7 @@ bool read(cmsys::ifstream& fin, std::vector<T>& v)
return true;
}
return static_cast<bool>(
- fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size()));
+ fin.read(reinterpret_cast<char*>(v.data()), sizeof(T) * v.size()));
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 6e74d9a..6792cd7 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1051,7 +1051,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
for (std::string const& l :
this->GetLinkedTargetDirectories(language, config)) {
- build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json"));
+ build.ImplicitDeps.emplace_back(
+ cmStrCat(l, '/', language, "Modules.json"));
}
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 429b737..ece657d 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -2117,7 +2117,7 @@ void cmQtAutoMocUicT::JobCompileMocT::MaybeWriteMocResponseFile(
cmd.resize(1);
// Specify response file
- cmd.push_back(cmStrCat('@', responseFile));
+ cmd.emplace_back(cmStrCat('@', responseFile));
}
#else
static_cast<void>(outputFile);
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx
index 6702b7b..ccf24a0 100644
--- a/Source/cmVSSetupHelper.cxx
+++ b/Source/cmVSSetupHelper.cxx
@@ -63,15 +63,16 @@ const WCHAR* ComponentType = L"Component";
bool LoadVSInstanceVCToolsetVersion(VSInstanceInfo& vsInstanceInfo)
{
std::string const vcRoot = vsInstanceInfo.GetInstallLocation();
- std::string vcToolsVersionFile =
- vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt";
+ std::string vcToolsVersionFile = cmStrCat(
+ vcRoot, "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt");
std::string vcToolsVersion;
cmsys::ifstream fin(vcToolsVersionFile.c_str());
if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) {
return false;
}
vcToolsVersion = cmTrimWhitespace(vcToolsVersion);
- std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion;
+ std::string const vcToolsDir =
+ cmStrCat(vcRoot, "/VC/Tools/MSVC/", vcToolsVersion);
if (!cmSystemTools::FileIsDirectory(vcToolsDir)) {
return false;
}
@@ -434,14 +435,14 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
std::string envVSCommonToolsDir;
std::string envVSCommonToolsDirEnvName =
- "VS" + std::to_string(this->Version) + "0COMNTOOLS";
+ cmStrCat("VS", std::to_string(this->Version), "0COMNTOOLS");
if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName.c_str(),
envVSCommonToolsDir)) {
cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir);
}
- std::string const wantVersion = std::to_string(this->Version) + '.';
+ std::string const wantVersion = cmStrCat(std::to_string(this->Version), '.');
bool specifiedLocationNotSpecifiedVersion = false;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 90de51a..f930223 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -15,6 +15,7 @@
#include <cm/string_view>
#include <cm/vector>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "windows.h"
@@ -104,7 +105,7 @@ struct cmVisualStudio10TargetGenerator::Elem
void SetHasElements()
{
if (!HasElements) {
- this->S << ">";
+ this->S << '>';
HasElements = true;
}
}
@@ -116,13 +117,13 @@ struct cmVisualStudio10TargetGenerator::Elem
}
Elem& Attribute(const char* an, std::string av)
{
- this->S << " " << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << "\"";
+ this->S << ' ' << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << '"';
return *this;
}
void Content(std::string val)
{
if (!this->HasContent) {
- this->S << ">";
+ this->S << '>';
this->HasContent = true;
}
this->S << cmVS10EscapeXML(std::move(val));
@@ -135,9 +136,9 @@ struct cmVisualStudio10TargetGenerator::Elem
}
if (HasElements) {
- this->WriteString("</") << this->Tag << ">";
+ this->WriteString("</") << this->Tag << '>';
} else if (HasContent) {
- this->S << "</" << this->Tag << ">";
+ this->S << "</" << this->Tag << '>';
} else {
this->S << " />";
}
@@ -291,8 +292,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->TargetCompileAsWinRT = false;
this->IsMissingFiles = false;
this->DefaultArtifactDir =
- this->LocalGenerator->GetCurrentBinaryDirectory() + "/" +
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
this->Makefile->GetCurrentBinaryDirectory());
this->ClassifyAllConfigSources();
@@ -304,16 +305,16 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition(
const std::string& config) const
{
std::ostringstream oss;
- oss << "'$(Configuration)|$(Platform)'=='";
- oss << config << "|" << this->Platform;
- oss << "'";
+ oss << "'$(Configuration)|$(Platform)'=='" << config << '|' << this->Platform
+ << '\'';
// handle special case for 32 bit C# targets
if (this->ProjectType == VsProjectType::csproj &&
- this->Platform == "Win32") {
- oss << " Or ";
- oss << "'$(Configuration)|$(Platform)'=='";
- oss << config << "|x86";
- oss << "'";
+ this->Platform == "Win32"_s) {
+ oss << " Or "
+ "'$(Configuration)|$(Platform)'=='"
+ << config
+ << "|x86"
+ "'";
}
return oss.str();
}
@@ -377,10 +378,10 @@ void cmVisualStudio10TargetGenerator::Generate()
if (this->ProjectType == VsProjectType::csproj &&
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- std::string message = "The C# target \"" +
- this->GeneratorTarget->GetName() +
- "\" is of type STATIC_LIBRARY. This is discouraged (and may be "
- "disabled in future). Make it a SHARED library instead.";
+ std::string message =
+ cmStrCat("The C# target \"", this->GeneratorTarget->GetName(),
+ "\" is of type STATIC_LIBRARY. This is discouraged (and may be "
+ "disabled in future). Make it a SHARED library instead.");
this->Makefile->IssueMessage(MessageType::DEPRECATION_WARNING, message);
}
@@ -510,7 +511,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
// Setting ResolveNugetPackages to false skips this target and the build
// succeeds.
cm::string_view targetName{ this->GeneratorTarget->GetName() };
- if (targetName == "ALL_BUILD" || targetName == "PACKAGE" ||
+ if (targetName == "ALL_BUILD"_s || targetName == "PACKAGE"_s ||
targetName == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
Elem e1(e0, "PropertyGroup");
e1.Element("ResolveNugetPackages", "false");
@@ -624,8 +625,10 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
.empty()) {
e1.Element(
"CudaToolkitCustomDir",
- this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() +
- this->GlobalGenerator->GetPlatformToolsetCudaNvccSubdirString());
+ cmStrCat(
+ this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(),
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaNvccSubdirString()));
}
}
@@ -729,15 +732,15 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString();
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
- : customDir +
- this->GlobalGenerator
- ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
- R"(extras\visual_studio_integration\MSBuildExtensions\)";
+ : cmStrCat(customDir,
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString(),
+ R"(extras\visual_studio_integration\MSBuildExtensions\)");
Elem(e1, "Import")
.Attribute("Project",
- std::move(cudaPath) + "CUDA " +
- this->GlobalGenerator->GetPlatformToolsetCuda() +
- ".props");
+ cmStrCat(std::move(cudaPath), "CUDA ",
+ this->GlobalGenerator->GetPlatformToolsetCuda(),
+ ".props"));
}
if (this->GlobalGenerator->IsMarmasmEnabled()) {
Elem(e1, "Import")
@@ -783,7 +786,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
ConvertToWindowsSlash(props);
Elem(e1, "Import")
.Attribute("Project", props)
- .Attribute("Condition", "exists('" + props + "')")
+ .Attribute("Condition", cmStrCat("exists('", props, "')"))
.Attribute("Label", "LocalAppDataPlatform");
}
@@ -833,15 +836,15 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString();
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
- : customDir +
- this->GlobalGenerator
- ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
- R"(extras\visual_studio_integration\MSBuildExtensions\)";
+ : cmStrCat(customDir,
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString(),
+ R"(extras\visual_studio_integration\MSBuildExtensions\)");
Elem(e1, "Import")
.Attribute("Project",
- std::move(cudaPath) + "CUDA " +
- this->GlobalGenerator->GetPlatformToolsetCuda() +
- ".targets");
+ cmStrCat(std::move(cudaPath), "CUDA ",
+ this->GlobalGenerator->GetPlatformToolsetCuda(),
+ ".targets"));
}
if (this->GlobalGenerator->IsMarmasmEnabled()) {
Elem(e1, "Import")
@@ -868,7 +871,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
if (this->ProjectType == VsProjectType::csproj) {
for (std::string const& c : this->Configurations) {
Elem e1(e0, "PropertyGroup");
- e1.Attribute("Condition", "'$(Configuration)' == '" + c + "'");
+ e1.Attribute("Condition",
+ cmStrCat("'$(Configuration)' == '", c, '\''));
e1.SetHasElements();
this->WriteEvents(e1, c);
}
@@ -881,7 +885,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
oss << " " << i << ";\n";
}
oss << " "
- << "$(BuildDependsOn)\n";
+ "$(BuildDependsOn)\n";
e1.Element("BuildDependsOn", oss.str());
}
}
@@ -893,17 +897,19 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
{
if (this->ProjectType != VsProjectType::csproj ||
!this->GeneratorTarget->IsDotNetSdkTarget()) {
- std::string message = "The target \"" + this->GeneratorTarget->GetName() +
- "\" is not eligible for .Net SDK style project.";
+ std::string message =
+ cmStrCat("The target \"", this->GeneratorTarget->GetName(),
+ "\" is not eligible for .Net SDK style project.");
this->Makefile->IssueMessage(MessageType::INTERNAL_ERROR, message);
return;
}
if (this->HasCustomCommands()) {
- std::string message = "The target \"" + this->GeneratorTarget->GetName() +
+ std::string message = cmStrCat(
+ "The target \"", this->GeneratorTarget->GetName(),
"\" does not currently support add_custom_command as the Visual Studio "
"generators have not yet learned how to generate custom commands in "
- ".Net SDK-style projects.";
+ ".Net SDK-style projects.");
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, message);
return;
}
@@ -986,11 +992,13 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
for (const std::string& config : this->Configurations) {
Elem e1(e0, "PropertyGroup");
- e1.Attribute("Condition", "'$(Configuration)' == '" + config + "'");
+ e1.Attribute("Condition",
+ cmStrCat("'$(Configuration)' == '", config, '\''));
e1.SetHasElements();
this->WriteEvents(e1, config);
- std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ std::string outDir =
+ cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
ConvertToWindowsSlash(outDir);
e1.Element("OutputPath", outDir);
@@ -1011,7 +1019,7 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
{
e1.Attribute("Label", "Globals");
- e1.Element("ProjectGuid", "{" + this->GUID + "}");
+ e1.Element("ProjectGuid", cmStrCat('{', this->GUID, '}'));
cmValue vsProjectTypes =
this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
@@ -1049,8 +1057,8 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
}
cm::string_view globalKey = cm::string_view(keyIt).substr(prefix.length());
// Skip invalid or separately-handled properties.
- if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
- globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
+ if (globalKey.empty() || globalKey == "PROJECT_TYPES"_s ||
+ globalKey == "ROOTNAMESPACE"_s || globalKey == "KEYWORD"_s) {
continue;
}
cmValue value = this->GeneratorTarget->GetProperty(keyIt);
@@ -1107,7 +1115,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0)
if (cmHasPrefix(i.first, vsDnRef)) {
std::string path = i.second;
if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
+ path =
+ cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path);
}
ConvertToWindowsSlash(path);
this->DotNetHintReferences[""].emplace_back(
@@ -1176,7 +1185,8 @@ void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0)
cmList argsSplit{ *imports };
for (auto& path : argsSplit) {
if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
+ path =
+ cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path);
}
ConvertToWindowsSlash(path);
Elem e1(e0, "Import");
@@ -1191,7 +1201,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_";
static const std::string refpropInfix = "_TAG_";
- const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix;
+ const std::string refPropFullPrefix =
+ cmStrCat(refpropPrefix, ref, refpropInfix);
using CustomTags = std::map<std::string, std::string>;
CustomTags tags;
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
@@ -1243,7 +1254,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
e2.Attribute("Include", obj);
if (this->ProjectType != VsProjectType::csproj) {
- std::string hFileName = obj.substr(0, obj.find_last_of('.')) + ".h";
+ std::string hFileName =
+ cmStrCat(obj.substr(0, obj.find_last_of('.')), ".h");
e2.Element("DependentUpon", hFileName);
for (std::string const& c : this->Configurations) {
@@ -1269,10 +1281,10 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
e2.Element("Link", link);
}
// Determine if this is a generated resource from a .Designer.cs file
- std::string designerResource =
- cmSystemTools::GetFilenamePath(oi->GetFullPath()) + "/" +
- cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()) +
- ".Designer.cs";
+ std::string designerResource = cmStrCat(
+ cmSystemTools::GetFilenamePath(oi->GetFullPath()), '/',
+ cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()),
+ ".Designer.cs");
if (cmsys::SystemTools::FileExists(designerResource)) {
std::string generator = "PublicResXFileCodeGenerator";
if (cmValue g = oi->GetProperty("VS_RESOURCE_GENERATOR")) {
@@ -1337,7 +1349,7 @@ void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences(Elem& e0)
{
if (this->MSTools) {
if (this->GlobalGenerator->TargetsWindowsPhone() &&
- this->GlobalGenerator->GetSystemVersion() == "8.0") {
+ this->GlobalGenerator->GetSystemVersion() == "8.0"_s) {
Elem(e0, "Import")
.Attribute("Project",
"$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
@@ -1358,9 +1370,9 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1)
if (j > 0) {
oss << " Or ";
}
- oss << "'$(Configuration)'=='" << tac.Configs[j] << "'";
+ oss << "'$(Configuration)'=='" << tac.Configs[j] << '\'';
}
- oss << ")";
+ oss << ')';
}
Elem(e1, "Import")
@@ -1378,7 +1390,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0)
}
if (this->GlobalGenerator->TargetsWindowsPhone() &&
- this->GlobalGenerator->GetSystemVersion() == "8.0" &&
+ this->GlobalGenerator->GetSystemVersion() == "8.0"_s &&
references.empty()) {
references.push_back(std::string{ "platform.winmd" });
}
@@ -1400,7 +1412,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0)
e1.Attribute("Label", "ProjectConfigurations");
for (std::string const& c : this->Configurations) {
Elem e2(e1, "ProjectConfiguration");
- e2.Attribute("Include", c + "|" + this->Platform);
+ e2.Attribute("Include", cmStrCat(c, '|', this->Platform));
e2.Element("Configuration", c);
e2.Element("Platform", this->Platform);
}
@@ -1508,9 +1520,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
std::string useOfMfcValue = "false";
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
- if (mfcFlagValue == "1") {
+ if (mfcFlagValue == "1"_s) {
useOfMfcValue = "Static";
- } else if (mfcFlagValue == "2") {
+ } else if (mfcFlagValue == "2"_s) {
useOfMfcValue = "Dynamic";
}
}
@@ -1576,7 +1588,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
e1.Element("DefineDebug", "true");
}
- std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ std::string outDir =
+ cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
ConvertToWindowsSlash(outDir);
e1.Element("OutputPath", outDir);
@@ -1603,7 +1616,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
if (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType()) {
e1.Element("StartAction", "Program");
- e1.Element("StartProgram", outDir + assemblyName + ".exe");
+ e1.Element("StartProgram", cmStrCat(outDir, assemblyName, ".exe"));
}
OptionsHelper oh(o, e1);
@@ -1618,10 +1631,10 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
const char* toolset = gg->GetPlatformToolset();
e1.Element("NdkToolchainVersion", toolset ? toolset : "Default");
if (cmValue minApi = this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
- e1.Element("AndroidMinAPI", "android-" + *minApi);
+ e1.Element("AndroidMinAPI", cmStrCat("android-", *minApi));
}
if (cmValue api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
- e1.Element("AndroidTargetAPI", "android-" + *api);
+ e1.Element("AndroidTargetAPI", cmStrCat("android-", *api));
}
if (cmValue cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
@@ -1646,7 +1659,7 @@ void cmVisualStudio10TargetGenerator::WriteAndroidConfigurationValues(
}
if (cmValue stlType =
this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) {
- if (*stlType != "none") {
+ if (*stlType != "none"_s) {
e1.Element("UseOfStl", *stlType);
}
}
@@ -1724,9 +1737,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
// preventing dependent rebuilds.
this->ForceOld(sourcePath);
} else {
- std::string error =
- cmStrCat("Could not create file: [", sourcePath, "] ");
- cmSystemTools::Error(error + cmSystemTools::GetLastSystemError());
+ cmSystemTools::Error(cmStrCat("Could not create file: [", sourcePath,
+ "] ",
+ cmSystemTools::GetLastSystemError()));
}
}
}
@@ -1811,8 +1824,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
}
script += lg->FinishConstructScript(this->ProjectType);
if (this->ProjectType == VsProjectType::csproj) {
- std::string name = "CustomCommand_" + c + "_" +
- cmSystemTools::ComputeStringMD5(sourcePath);
+ std::string name = cmStrCat("CustomCommand_", c, '_',
+ cmSystemTools::ComputeStringMD5(sourcePath));
this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
outputs.str(), comment, ccg);
} else {
@@ -1883,7 +1896,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
e1.S << "\n Inputs=\"" << cmVS10EscapeAttr(inputs) << "\"";
e1.S << "\n Outputs=\"" << cmVS10EscapeAttr(outputs) << "\"";
if (!comment.empty()) {
- Elem(e1, "Exec").Attribute("Command", "echo " + comment);
+ Elem(e1, "Exec").Attribute("Command", cmStrCat("echo ", comment));
}
Elem(e1, "Exec").Attribute("Command", script);
}
@@ -1957,7 +1970,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
for (auto const& ti : this->Tools) {
if ((this->GeneratorTarget->GetName() ==
CMAKE_CHECK_BUILD_SYSTEM_TARGET) &&
- (ti.first == "None")) {
+ (ti.first == "None"_s)) {
this->WriteBuildSystemSources(e0, ti.first, ti.second);
} else {
this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups);
@@ -1971,7 +1984,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
for (std::string const& oi : this->AddedFiles) {
std::string fileName =
cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(oi));
- if (fileName == "wmappmanifest.xml") {
+ if (fileName == "wmappmanifest.xml"_s) {
Elem e2(e1, "XML");
e2.Attribute("Include", oi);
e2.Element("Filter", "Resource Files");
@@ -1980,7 +1993,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
Elem e2(e1, "AppxManifest");
e2.Attribute("Include", oi);
e2.Element("Filter", "Resource Files");
- } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
+ } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx"_s) {
Elem e2(e1, "None");
e2.Attribute("Include", oi);
e2.Element("Filter", "Resource Files");
@@ -2014,11 +2027,11 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
for (cmSourceGroup const* sg : groupsVec) {
std::string const& name = sg->GetFullName();
if (!name.empty()) {
- std::string guidName = "SG_Filter_" + name;
+ std::string guidName = cmStrCat("SG_Filter_", name);
std::string guid = this->GlobalGenerator->GetGUID(guidName);
Elem e2(e1, "Filter");
e2.Attribute("Include", name);
- e2.Element("UniqueIdentifier", "{" + guid + "}");
+ e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
}
}
@@ -2027,7 +2040,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::string guid = this->GlobalGenerator->GetGUID(guidName);
Elem e2(e1, "Filter");
e2.Attribute("Include", "Resource Files");
- e2.Element("UniqueIdentifier", "{" + guid + "}");
+ e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
e2.Element("Extensions",
"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;"
"gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms");
@@ -2041,7 +2054,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::string guid = this->GlobalGenerator->GetGUID(guidName);
Elem e2(e1, "Filter");
e2.Attribute("Include", filter);
- e2.Element("UniqueIdentifier", "{" + guid + "}");
+ e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
}
}
}
@@ -2228,7 +2241,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
if (this->ProjectType == VsProjectType::csproj && !this->InSourceBuild) {
toolHasSettings = true;
}
- if (ext == "hlsl") {
+ if (ext == "hlsl"_s) {
tool = "FXCompile";
// Figure out the type of shader compiler to use.
if (cmValue st = sf->GetProperty("VS_SHADER_TYPE")) {
@@ -2306,22 +2319,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
toolSettings[config]["ObjectFileOutput"] = *sofn;
}
}
- } else if (ext == "jpg" || ext == "png") {
+ } else if (ext == "jpg"_s || ext == "png"_s) {
tool = "Image";
- } else if (ext == "resw") {
+ } else if (ext == "resw"_s) {
tool = "PRIResource";
- } else if (ext == "xml") {
+ } else if (ext == "xml"_s) {
tool = "XML";
- } else if (ext == "natvis") {
+ } else if (ext == "natvis"_s) {
tool = "Natvis";
- } else if (ext == "settings") {
+ } else if (ext == "settings"_s) {
settingsLastGenOutput =
cmsys::SystemTools::GetFilenameName(sf->GetFullPath());
std::size_t pos = settingsLastGenOutput.find(".settings");
settingsLastGenOutput.replace(pos, 9, ".Designer.cs");
settingsGenerator = "SettingsSingleFileGenerator";
toolHasSettings = true;
- } else if (ext == "vsixmanifest") {
+ } else if (ext == "vsixmanifest"_s) {
subType = "Designer";
}
if (cmValue c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) {
@@ -2342,13 +2355,13 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
if (this->NsightTegra) {
// Nsight Tegra needs specific file types to check up-to-dateness.
std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName());
- if (name == "androidmanifest.xml" || name == "build.xml" ||
- name == "proguard.cfg" || name == "proguard-project.txt" ||
- ext == "properties") {
+ if (name == "androidmanifest.xml"_s || name == "build.xml"_s ||
+ name == "proguard.cfg"_s || name == "proguard-project.txt"_s ||
+ ext == "properties"_s) {
tool = "AndroidBuild";
- } else if (ext == "java") {
+ } else if (ext == "java"_s) {
tool = "JCompile";
- } else if (ext == "asm" || ext == "s") {
+ } else if (ext == "asm"_s || ext == "s"_s) {
tool = "ClCompile";
}
}
@@ -2376,7 +2389,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
if (ParsedToolTargetSettings.find(tool) == ParsedToolTargetSettings.end()) {
cmValue toolTargetProperty = this->GeneratorTarget->Target->GetProperty(
- "VS_SOURCE_SETTINGS_" + std::string(tool));
+ cmStrCat("VS_SOURCE_SETTINGS_", tool));
ConfigToSettings toolTargetSettings;
if (toolTargetProperty) {
ParseSettingsProperty(*toolTargetProperty, toolTargetSettings);
@@ -2408,19 +2421,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis
if (!deployLocation.empty()) {
- e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
+ e2.Element("Link",
+ cmStrCat(deployLocation, "\\%(FileName)%(Extension)"));
}
for (auto& config : this->Configurations) {
- if (cge->Evaluate(this->LocalGenerator, config) == "1") {
- e2.WritePlatformConfigTag("DeploymentContent",
- "'$(Configuration)|$(Platform)'=='" +
- config + "|" + this->Platform + "'",
- "true");
+ if (cge->Evaluate(this->LocalGenerator, config) == "1"_s) {
+ e2.WritePlatformConfigTag(
+ "DeploymentContent",
+ cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|',
+ this->Platform, '\''),
+ "true");
} else {
- e2.WritePlatformConfigTag("ExcludedFromBuild",
- "'$(Configuration)|$(Platform)'=='" +
- config + "|" + this->Platform + "'",
- "true");
+ e2.WritePlatformConfigTag(
+ "ExcludedFromBuild",
+ cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|',
+ this->Platform, '\''),
+ "true");
}
}
}
@@ -2456,7 +2472,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2,
// conversion uses full paths when possible to allow deeper trees.
// However, CUDA 8.0 msbuild rules fail on absolute paths so for CUDA
// we must use relative paths.
- bool forceRelative = sf->GetLanguage() == "CUDA";
+ bool forceRelative = sf->GetLanguage() == "CUDA"_s;
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative);
ConvertToWindowsSlash(sourceFile);
e2.Attribute("Include", sourceFile);
@@ -2554,22 +2570,23 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
case cmGeneratorTarget::SourceKindUnityBatched:
case cmGeneratorTarget::SourceKindObjectSource: {
const std::string& lang = si.Source->GetLanguage();
- if (lang == "C" || lang == "CXX") {
+ if (lang == "C"_s || lang == "CXX"_s) {
tool = "ClCompile";
- } else if (lang == "ASM_MARMASM" &&
+ } else if (lang == "ASM_MARMASM"_s &&
this->GlobalGenerator->IsMarmasmEnabled()) {
tool = "MARMASM";
- } else if (lang == "ASM_MASM" &&
+ } else if (lang == "ASM_MASM"_s &&
this->GlobalGenerator->IsMasmEnabled()) {
tool = "MASM";
- } else if (lang == "ASM_NASM" &&
+ } else if (lang == "ASM_NASM"_s &&
this->GlobalGenerator->IsNasmEnabled()) {
tool = "NASM";
- } else if (lang == "RC") {
+ } else if (lang == "RC"_s) {
tool = "ResourceCompile";
- } else if (lang == "CSharp") {
+ } else if (lang == "CSharp"_s) {
tool = "Compile";
- } else if (lang == "CUDA" && this->GlobalGenerator->IsCudaEnabled()) {
+ } else if (lang == "CUDA"_s &&
+ this->GlobalGenerator->IsCudaEnabled()) {
tool = "CudaCompile";
} else {
tool = "None";
@@ -2592,7 +2609,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
std::back_inserter(exclude_configs));
Elem e2(e1, tool);
- bool isCSharp = (si.Source->GetLanguage() == "CSharp");
+ bool isCSharp = (si.Source->GetLanguage() == "CSharp"_s);
if (isCSharp && !exclude_configs.empty()) {
std::stringstream conditions;
bool firstConditionSet{ false };
@@ -2600,8 +2617,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
if (firstConditionSet) {
conditions << " Or ";
}
- conditions << "('$(Configuration)|$(Platform)'=='" +
- this->Configurations[ci] + "|" + this->Platform + "')";
+ conditions << "('$(Configuration)|$(Platform)'=='"
+ << this->Configurations[ci] << '|' << this->Platform
+ << "')";
firstConditionSet = true;
}
e2.Attribute("Condition", conditions.str());
@@ -2681,9 +2699,9 @@ void cmVisualStudio10TargetGenerator::FinishWritingSource(
writtenSettings.push_back(setting.first);
} else {
e2.WritePlatformConfigTag(setting.first,
- "'$(Configuration)|$(Platform)'=='" +
- configSettings.first + "|" +
- this->Platform + "'",
+ cmStrCat("'$(Configuration)|$(Platform)'=='",
+ configSettings.first, '|',
+ this->Platform, '\''),
setting.second);
}
}
@@ -2731,33 +2749,33 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
// Force language if the file extension does not match.
// Note that MSVC treats the upper-case '.C' extension as C and not C++.
std::string const ext = sf.GetExtension();
- std::string const extLang = ext == "C"
+ std::string const extLang = ext == "C"_s
? "C"
: this->GlobalGenerator->GetLanguageFromExtension(ext.c_str());
std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf);
const char* compileAs = nullptr;
if (lang != extLang) {
- if (lang == "CXX") {
+ if (lang == "CXX"_s) {
// force a C++ file type
compileAs = "CompileAsCpp";
- } else if (lang == "C") {
+ } else if (lang == "C"_s) {
// force to c
compileAs = "CompileAsC";
}
}
- bool noWinRT = this->TargetCompileAsWinRT && lang == "C";
+ bool noWinRT = this->TargetCompileAsWinRT && lang == "C"_s;
// for the first time we need a new line if there is something
// produced here.
if (!objectName.empty()) {
- if (lang == "CUDA") {
- e2.Element("CompileOut", "$(IntDir)/" + objectName);
+ if (lang == "CUDA"_s) {
+ e2.Element("CompileOut", cmStrCat("$(IntDir)/", objectName));
} else {
- e2.Element("ObjectFileName", "$(IntDir)/" + objectName);
+ e2.Element("ObjectFileName", cmStrCat("$(IntDir)/", objectName));
}
}
- if (lang == "ASM_NASM") {
+ if (lang == "ASM_NASM"_s) {
if (cmValue objectDeps = sf.GetProperty("OBJECT_DEPENDS")) {
cmList depends{ *objectDeps };
for (auto& d : depends) {
@@ -2777,7 +2795,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
if (cmValue ccdefs = sf.GetProperty(defPropName)) {
if (!configDefines.empty()) {
- configDefines += ";";
+ configDefines += ';';
}
configDependentDefines |=
cmGeneratorExpression::Find(*ccdefs) != std::string::npos;
@@ -2842,20 +2860,20 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmIDEFlagTable const* flagtable = nullptr;
const std::string& srclang = source->GetLanguage();
- if (srclang == "C" || srclang == "CXX") {
+ if (srclang == "C"_s || srclang == "CXX"_s) {
flagtable = gg->GetClFlagTable();
- } else if (srclang == "ASM_MARMASM" &&
+ } else if (srclang == "ASM_MARMASM"_s &&
this->GlobalGenerator->IsMarmasmEnabled()) {
flagtable = gg->GetMarmasmFlagTable();
- } else if (srclang == "ASM_MASM" &&
+ } else if (srclang == "ASM_MASM"_s &&
this->GlobalGenerator->IsMasmEnabled()) {
flagtable = gg->GetMasmFlagTable();
- } else if (lang == "ASM_NASM" &&
+ } else if (lang == "ASM_NASM"_s &&
this->GlobalGenerator->IsNasmEnabled()) {
flagtable = gg->GetNasmFlagTable();
- } else if (srclang == "RC") {
+ } else if (srclang == "RC"_s) {
flagtable = gg->GetRcFlagTable();
- } else if (srclang == "CSharp") {
+ } else if (srclang == "CSharp"_s) {
flagtable = gg->GetCSharpFlagTable();
}
cmGeneratorExpressionInterpreter genexInterpreter(
@@ -2980,9 +2998,9 @@ void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild(
{
for (size_t ci : exclude_configs) {
e2.WritePlatformConfigTag("ExcludedFromBuild",
- "'$(Configuration)|$(Platform)'=='" +
- this->Configurations[ci] + "|" +
- this->Platform + "'",
+ cmStrCat("'$(Configuration)|$(Platform)'=='",
+ this->Configurations[ci], '|',
+ this->Platform, '\''),
"true");
}
}
@@ -3016,7 +3034,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
outDir = intermediateDir;
targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib");
} else {
- outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
targetNameFull = this->GeneratorTarget->GetFullName(config);
}
ConvertToWindowsSlash(intermediateDir);
@@ -3201,7 +3219,7 @@ std::string cmVisualStudio10TargetGenerator::GetTargetOutputName() const
}
const auto& nameComponents =
this->GeneratorTarget->GetFullNameComponents(config);
- return nameComponents.prefix + nameComponents.base;
+ return cmStrCat(nameComponents.prefix, nameComponents.base);
}
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
@@ -3239,8 +3257,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
const std::string& linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(configName);
if (linkLanguage.empty()) {
- cmSystemTools::Error(
- "CMake can not determine linker language for target: " + this->Name);
+ cmSystemTools::Error(cmStrCat(
+ "CMake can not determine linker language for target: ", this->Name));
return false;
}
@@ -3332,11 +3350,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
defineFlags.find("/clr") != std::string::npos ||
defineFlags.find("-clr") != std::string::npos) {
if (configName == this->Configurations[0]) {
- std::string message = "For the target \"" +
- this->GeneratorTarget->GetName() +
- "\" the /clr compiler flag was added manually. " +
- "Set usage of C++/CLI by setting COMMON_LANGUAGE_RUNTIME "
- "target property.";
+ std::string message =
+ cmStrCat("For the target \"", this->GeneratorTarget->GetName(),
+ "\" the /clr compiler flag was added manually. ",
+ "Set usage of C++/CLI by setting COMMON_LANGUAGE_RUNTIME "
+ "target property.");
this->Makefile->IssueMessage(MessageType::WARNING, message);
}
}
@@ -3344,9 +3362,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
std::string clrString = *clr;
if (!clrString.empty()) {
- clrString = ":" + clrString;
+ clrString = cmStrCat(':', clrString);
}
- flags += " /clr" + clrString;
+ flags += cmStrCat(" /clr", clrString);
}
}
@@ -3419,7 +3437,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
// Add C-specific flags expressible in a ClCompile meant for C++.
- if (langForClCompile == "CXX") {
+ if (langForClCompile == "CXX"_s) {
std::set<std::string> languages;
this->GeneratorTarget->GetLanguages(languages, configName);
if (languages.count("C")) {
@@ -3474,7 +3492,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
std::string managedType = clOptions.HasFlag("CompileAsManaged")
? clOptions.GetFlag("CompileAsManaged")
: "Mixed";
- if (managedType == "Safe" || managedType == "Pure") {
+ if (managedType == "Safe"_s || managedType == "Pure"_s) {
// force empty calling convention if safe clr is used
clOptions.AddFlag("CallingConvention", "");
}
@@ -3498,7 +3516,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
// Remove any target-wide -TC or -TP flag added by the project.
// Such flags are unnecessary and break our model of language selection.
- if (langForClCompile == "C" || langForClCompile == "CXX") {
+ if (langForClCompile == "C"_s || langForClCompile == "CXX"_s) {
clOptions.RemoveFlag("CompileAs");
}
@@ -3593,9 +3611,10 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
Options& rcOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
- std::string rcConfigFlagsVar = "CMAKE_RC_FLAGS_" + CONFIG;
- std::string flags = this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS") +
- " " + this->Makefile->GetSafeDefinition(rcConfigFlagsVar);
+ std::string rcConfigFlagsVar = cmStrCat("CMAKE_RC_FLAGS_", CONFIG);
+ std::string flags =
+ cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), ' ',
+ this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
rcOptions.Parse(flags);
@@ -3736,7 +3755,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// limitation by creating the directory and passing the flag ourselves.
pdb = this->ConvertPath(pdb, true);
ConvertToWindowsSlash(pdb);
- std::string const clFd = R"(-Xcompiler="-Fd\")" + pdb + R"(\"")";
+ std::string const clFd = cmStrCat(R"(-Xcompiler="-Fd\")", pdb, R"(\"")");
cudaOptions.AppendFlagString("AdditionalOptions", clFd);
}
}
@@ -3744,7 +3763,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// CUDA automatically passes the proper '--machine' flag to nvcc
// for the current architecture, but does not reflect this default
// in the user-visible IDE settings. Set it explicitly.
- if (this->Platform == "x64") {
+ if (this->Platform == "x64"_s) {
cudaOptions.AddFlag("TargetMachinePlatform", "64");
}
@@ -3761,7 +3780,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
cudaOptions.RemoveFlag("AdditionalCompilerOptions");
if (!aco.empty()) {
aco = this->LocalGenerator->EscapeForShell(aco, false);
- cudaOptions.AppendFlagString("AdditionalOptions", "-Xcompiler=" + aco);
+ cudaOptions.AppendFlagString("AdditionalOptions",
+ cmStrCat("-Xcompiler=", aco));
}
}
@@ -3787,11 +3807,11 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// Add runtime library selection flag.
std::string const& cudaRuntime =
this->GeneratorTarget->GetRuntimeLinkLibrary("CUDA", configName);
- if (cudaRuntime == "STATIC") {
+ if (cudaRuntime == "STATIC"_s) {
cudaOptions.AddFlag("CudaRuntime", "Static");
- } else if (cudaRuntime == "SHARED") {
+ } else if (cudaRuntime == "SHARED"_s) {
cudaOptions.AddFlag("CudaRuntime", "Shared");
- } else if (cudaRuntime == "NONE") {
+ } else if (cudaRuntime == "NONE"_s) {
cudaOptions.AddFlag("CudaRuntime", "None");
}
@@ -4135,14 +4155,15 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
e2.Element("AdditionalManifestFiles", oss.str());
}
if (dpiAware) {
- if (*dpiAware == "PerMonitor") {
+ if (*dpiAware == "PerMonitor"_s) {
e2.Element("EnableDpiAwareness", "PerMonitorHighDPIAware");
} else if (cmIsOn(*dpiAware)) {
e2.Element("EnableDpiAwareness", "true");
} else if (cmIsOff(*dpiAware)) {
e2.Element("EnableDpiAwareness", "false");
} else {
- cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " + *dpiAware);
+ cmSystemTools::Error(
+ cmStrCat("Bad parameter for VS_DPI_AWARE: ", *dpiAware));
}
}
}
@@ -4230,7 +4251,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
}
{
- std::string manifest_xml = rootDir + "/AndroidManifest.xml";
+ std::string manifest_xml = cmStrCat(rootDir, "/AndroidManifest.xml");
ConvertToWindowsSlash(manifest_xml);
e2.Element("AndroidManifestLocation", manifest_xml);
}
@@ -4238,7 +4259,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
if (cmValue antAdditionalOptions =
this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) {
e2.Element("AdditionalOptions",
- *antAdditionalOptions + " %(AdditionalOptions)");
+ cmStrCat(*antAdditionalOptions, " %(AdditionalOptions)"));
}
}
@@ -4269,8 +4290,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
const std::string& linkLanguage = linkClosure->LinkerLanguage;
if (linkLanguage.empty()) {
- cmSystemTools::Error(
- "CMake can not determine linker language for target: " + this->Name);
+ cmSystemTools::Error(cmStrCat(
+ "CMake can not determine linker language for target: ", this->Name));
return false;
}
@@ -4285,19 +4306,19 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
std::string flags;
std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS");
- flags += " ";
+ flags += ' ';
flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase);
- std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
- flags += " ";
+ std::string linkFlagVar = cmStrCat(linkFlagVarBase, '_', CONFIG);
+ flags += ' ';
flags += this->Makefile->GetRequiredDefinition(linkFlagVar);
cmValue targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- flags += " ";
+ flags += ' ';
flags += *targetLinkFlags;
}
std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
if (cmValue flagsConfig = this->GeneratorTarget->GetProperty(flagsProp)) {
- flags += " ";
+ flags += ' ';
flags += *flagsConfig;
}
@@ -4310,8 +4331,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
this->GeneratorTarget->GetLinkInformation(config);
if (!pcli) {
cmSystemTools::Error(
- "CMake can not compute cmComputeLinkInformation for target: " +
- this->Name);
+ cmStrCat("CMake can not compute cmComputeLinkInformation for target: ",
+ this->Name));
return false;
}
cmComputeLinkInformation& cli = *pcli;
@@ -4336,7 +4357,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
// first just full path
linkDirs.push_back(d);
// next path with configuration type Debug, Release, etc
- linkDirs.push_back(d + "/$(Configuration)");
+ linkDirs.emplace_back(cmStrCat(d, "/$(Configuration)"));
}
linkDirs.push_back("%(AdditionalLibraryDirectories)");
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
@@ -4378,7 +4399,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
if (cmValue stackVal = this->Makefile->GetDefinition(
- "CMAKE_" + linkLanguage + "_STACK_SIZE")) {
+ cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE"))) {
linkOptions.AddFlag("StackReserveSize", *stackVal);
}
@@ -4410,7 +4431,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
if (this->GlobalGenerator->TargetsWindowsPhone() &&
- this->GlobalGenerator->GetSystemVersion() == "8.0") {
+ this->GlobalGenerator->GetSystemVersion() == "8.0"_s) {
// WindowsPhone 8.0 does not have ole32.
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
}
@@ -4475,8 +4496,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
this->GeneratorTarget->GetLinkInformation(config);
if (!pcli) {
cmSystemTools::Error(
- "CMake can not compute cmComputeLinkInformation for target: " +
- this->Name);
+ cmStrCat("CMake can not compute cmComputeLinkInformation for target: ",
+ this->Name));
return false;
}
@@ -4792,7 +4813,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
ConvertToWindowsSlash(path);
Elem e2(e1, "ProjectReference");
e2.Attribute("Include", path);
- e2.Element("Project", "{" + this->GlobalGenerator->GetGUID(name) + "}");
+ e2.Element("Project",
+ cmStrCat('{', this->GlobalGenerator->GetGUID(name), '}'));
e2.Element("Name", name);
this->WriteDotNetReferenceCustomTags(e2, name);
if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) {
@@ -4831,17 +4853,18 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension(
Elem& e1, std::string const& extension, std::string const& version)
{
- const std::string s = "$([Microsoft.Build.Utilities.ToolLocationHelper]"
- "::GetPlatformExtensionSDKLocation(`" +
- extension + ", Version=" + version +
- "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
- "$(ExtensionSDKDirectoryRoot), null))"
- "\\DesignTime\\CommonConfiguration\\Neutral\\" +
- extension + ".props";
+ const std::string s =
+ cmStrCat("$([Microsoft.Build.Utilities.ToolLocationHelper]"
+ "::GetPlatformExtensionSDKLocation(`",
+ extension, ", Version=", version,
+ "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
+ "$(ExtensionSDKDirectoryRoot), null))"
+ "\\DesignTime\\CommonConfiguration\\Neutral\\",
+ extension, ".props");
Elem e2(e1, "Import");
e2.Attribute("Project", s);
- e2.Attribute("Condition", "exists('" + s + "')");
+ e2.Attribute("Condition", cmStrCat("exists('", s, "')"));
}
void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0)
@@ -4892,7 +4915,7 @@ void cmVisualStudio10TargetGenerator::WriteSingleSDKReference(
Elem& e1, std::string const& extension, std::string const& version)
{
Elem(e1, "SDKReference")
- .Attribute("Include", extension + ", Version=" + version);
+ .Attribute("Include", cmStrCat(extension, ", Version=", version));
}
void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
@@ -4913,15 +4936,15 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
if (this->IsMissingFiles &&
!(this->GlobalGenerator->TargetsWindowsPhone() &&
- this->GlobalGenerator->GetSystemVersion() == "8.0")) {
+ this->GlobalGenerator->GetSystemVersion() == "8.0"_s)) {
// Move the manifest to a project directory to avoid clashes
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
Elem e1(e0, "PropertyGroup");
- e1.Element("AppxPackageArtifactsDir", artifactDir + "\\");
+ e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, '\\'));
std::string resourcePriFile =
- this->DefaultArtifactDir + "/resources.pri";
+ cmStrCat(this->DefaultArtifactDir, "/resources.pri");
ConvertToWindowsSlash(resourcePriFile);
e1.Element("ProjectPriFullPath", resourcePriFile);
@@ -4929,10 +4952,12 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
// aren't targeting WP8.0, add a default certificate
if (pfxFile.empty()) {
std::string templateFolder =
- cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
- pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
- cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx",
- pfxFile, false);
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows");
+ pfxFile =
+ cmStrCat(this->DefaultArtifactDir, "/Windows_TemporaryKey.pfx");
+ cmSystemTools::CopyAFile(
+ cmStrCat(templateFolder, "/Windows_TemporaryKey.pfx"), pfxFile,
+ false);
ConvertToWindowsSlash(pfxFile);
this->AddedFiles.push_back(pfxFile);
this->AddedDefaultCertificate = true;
@@ -4973,7 +4998,8 @@ void cmVisualStudio10TargetGenerator::ClassifyAllConfigSource(
// where the user supplied the file name and Visual Studio
// appended the suffix.
std::string resx = acs.Source->ResolveFullPath();
- std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h";
+ std::string hFileName =
+ cmStrCat(resx.substr(0, resx.find_last_of('.')), ".h");
this->ExpectedResxHeaders.insert(hFileName);
} break;
case cmGeneratorTarget::SourceKindXaml: {
@@ -4983,8 +5009,8 @@ void cmVisualStudio10TargetGenerator::ClassifyAllConfigSource(
// where the user supplied the file name and Visual Studio
// appended the suffix.
std::string xaml = acs.Source->ResolveFullPath();
- std::string hFileName = xaml + ".h";
- std::string cppFileName = xaml + ".cpp";
+ std::string hFileName = cmStrCat(xaml, ".h");
+ std::string cppFileName = cmStrCat(xaml, ".cpp");
this->ExpectedXamlHeaders.insert(hFileName);
this->ExpectedXamlSources.insert(cppFileName);
} break;
@@ -5023,7 +5049,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
e1.Element("ApplicationType",
(isWindowsPhone ? "Windows Phone" : "Windows Store"));
e1.Element("DefaultLanguage", "en-US");
- if (rev == "10.0") {
+ if (rev == "10.0"_s) {
e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 14.0 is necessary for building 10.0 apps
e1.Element("MinimumVisualStudioVersion", "14.0");
@@ -5031,7 +5057,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
- } else if (rev == "8.1") {
+ } else if (rev == "8.1"_s) {
e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 12.0 is necessary for building 8.1 apps
e1.Element("MinimumVisualStudioVersion", "12.0");
@@ -5039,7 +5065,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
- } else if (rev == "8.0") {
+ } else if (rev == "8.0"_s) {
e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 11.0 is necessary for building 8.0 apps
e1.Element("MinimumVisualStudioVersion", "11.0");
@@ -5052,7 +5078,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
cmStateEnums::EXECUTABLE) {
e1.Element("XapOutputs", "true");
e1.Element("XapFilename",
- this->Name + "_$(Configuration)_$(Platform).xap");
+ cmStrCat(this->Name, "_$(Configuration)_$(Platform).xap"));
}
}
} else if (isAndroid) {
@@ -5063,9 +5089,9 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
if (isAppContainer) {
e1.Element("AppContainerApplication", "true");
} else if (!isAndroid) {
- if (this->Platform == "ARM64") {
+ if (this->Platform == "ARM64"_s) {
e1.Element("WindowsSDKDesktopARM64Support", "true");
- } else if (this->Platform == "ARM") {
+ } else if (this->Platform == "ARM"_s) {
e1.Element("WindowsSDKDesktopARMSupport", "true");
}
}
@@ -5078,7 +5104,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
"VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
if (targetPlatformMinVersion) {
e1.Element("WindowsTargetPlatformMinVersion", *targetPlatformMinVersion);
- } else if (isWindowsStore && rev == "10.0") {
+ } else if (isWindowsStore && rev == "10.0"_s) {
// If the min version is not set, then use the TargetPlatformVersion
if (!targetPlatformVersion.empty()) {
e1.Element("WindowsTargetPlatformMinVersion", targetPlatformVersion);
@@ -5101,7 +5127,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
cmGeneratorTarget::SourceKindAppManifest);
std::string const& v = this->GlobalGenerator->GetSystemVersion();
if (this->GlobalGenerator->TargetsWindowsPhone()) {
- if (v == "8.0") {
+ if (v == "8.0"_s) {
// Look through the sources for WMAppManifest.xml
bool foundManifest = false;
for (cmGeneratorTarget::AllConfigSource const& source :
@@ -5117,16 +5143,16 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
if (!foundManifest) {
this->IsMissingFiles = true;
}
- } else if (v == "8.1") {
+ } else if (v == "8.1"_s) {
if (manifestSources.empty()) {
this->IsMissingFiles = true;
}
}
} else if (this->GlobalGenerator->TargetsWindowsStore()) {
if (manifestSources.empty()) {
- if (v == "8.0") {
+ if (v == "8.0"_s) {
this->IsMissingFiles = true;
- } else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0")) {
+ } else if (v == "8.1"_s || cmHasLiteralPrefix(v, "10.0")) {
this->IsMissingFiles = true;
}
}
@@ -5138,15 +5164,15 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles(Elem& e1)
{
std::string const& v = this->GlobalGenerator->GetSystemVersion();
if (this->GlobalGenerator->TargetsWindowsPhone()) {
- if (v == "8.0") {
+ if (v == "8.0"_s) {
this->WriteMissingFilesWP80(e1);
- } else if (v == "8.1") {
+ } else if (v == "8.1"_s) {
this->WriteMissingFilesWP81(e1);
}
} else if (this->GlobalGenerator->TargetsWindowsStore()) {
- if (v == "8.0") {
+ if (v == "8.0"_s) {
this->WriteMissingFilesWS80(e1);
- } else if (v == "8.1") {
+ } else if (v == "8.1"_s) {
this->WriteMissingFilesWS81(e1);
} else if (cmHasLiteralPrefix(v, "10.0")) {
this->WriteMissingFilesWS10_0(e1);
@@ -5157,13 +5183,13 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
{
std::string templateFolder =
- cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows");
// For WP80, the manifest needs to be in the same folder as the project
// this can cause an overwrite problem if projects aren't organized in
// folders
- std::string manifestFile =
- this->LocalGenerator->GetCurrentBinaryDirectory() + "/WMAppManifest.xml";
+ std::string manifestFile = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), "/WMAppManifest.xml");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
@@ -5220,22 +5246,22 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
}
this->AddedFiles.push_back(sourceFile);
- std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
- cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
- false);
+ std::string smallLogo = cmStrCat(this->DefaultArtifactDir, "/SmallLogo.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo.png"),
+ smallLogo, false);
ConvertToWindowsSlash(smallLogo);
Elem(e1, "Image").Attribute("Include", smallLogo);
this->AddedFiles.push_back(smallLogo);
- std::string logo = this->DefaultArtifactDir + "/Logo.png";
- cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
+ std::string logo = cmStrCat(this->DefaultArtifactDir, "/Logo.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/Logo.png"), logo, false);
ConvertToWindowsSlash(logo);
Elem(e1, "Image").Attribute("Include", logo);
this->AddedFiles.push_back(logo);
std::string applicationIcon =
- this->DefaultArtifactDir + "/ApplicationIcon.png";
- cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png",
+ cmStrCat(this->DefaultArtifactDir, "/ApplicationIcon.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/ApplicationIcon.png"),
applicationIcon, false);
ConvertToWindowsSlash(applicationIcon);
Elem(e1, "Image").Attribute("Include", applicationIcon);
@@ -5245,7 +5271,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1)
{
std::string manifestFile =
- this->DefaultArtifactDir + "/package.appxManifest";
+ cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
@@ -5307,7 +5333,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1)
{
std::string manifestFile =
- this->DefaultArtifactDir + "/package.appxManifest";
+ cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
@@ -5361,7 +5387,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1)
{
std::string manifestFile =
- this->DefaultArtifactDir + "/package.appxManifest";
+ cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
@@ -5420,7 +5446,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1)
{
std::string manifestFile =
- this->DefaultArtifactDir + "/package.appxManifest";
+ cmStrCat(this->DefaultArtifactDir, "/package.appxManifest");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir);
@@ -5481,7 +5507,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
Elem& e1, const std::string& manifestFile)
{
std::string templateFolder =
- cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows");
std::string sourceFile = this->ConvertPath(manifestFile, false);
ConvertToWindowsSlash(sourceFile);
@@ -5492,36 +5518,38 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
}
this->AddedFiles.push_back(sourceFile);
- std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
- cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
- false);
+ std::string smallLogo = cmStrCat(this->DefaultArtifactDir, "/SmallLogo.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo.png"),
+ smallLogo, false);
ConvertToWindowsSlash(smallLogo);
Elem(e1, "Image").Attribute("Include", smallLogo);
this->AddedFiles.push_back(smallLogo);
- std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png";
- cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44,
- false);
+ std::string smallLogo44 =
+ cmStrCat(this->DefaultArtifactDir, "/SmallLogo44x44.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo44x44.png"),
+ smallLogo44, false);
ConvertToWindowsSlash(smallLogo44);
Elem(e1, "Image").Attribute("Include", smallLogo44);
this->AddedFiles.push_back(smallLogo44);
- std::string logo = this->DefaultArtifactDir + "/Logo.png";
- cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
+ std::string logo = cmStrCat(this->DefaultArtifactDir, "/Logo.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/Logo.png"), logo, false);
ConvertToWindowsSlash(logo);
Elem(e1, "Image").Attribute("Include", logo);
this->AddedFiles.push_back(logo);
- std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png";
- cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo,
- false);
+ std::string storeLogo = cmStrCat(this->DefaultArtifactDir, "/StoreLogo.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/StoreLogo.png"),
+ storeLogo, false);
ConvertToWindowsSlash(storeLogo);
Elem(e1, "Image").Attribute("Include", storeLogo);
this->AddedFiles.push_back(storeLogo);
- std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png";
- cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen,
- false);
+ std::string splashScreen =
+ cmStrCat(this->DefaultArtifactDir, "/SplashScreen.png");
+ cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SplashScreen.png"),
+ splashScreen, false);
ConvertToWindowsSlash(splashScreen);
Elem(e1, "Image").Attribute("Include", splashScreen);
this->AddedFiles.push_back(splashScreen);
@@ -5529,7 +5557,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
if (this->AddedDefaultCertificate) {
// This file has already been added to the build so don't copy it
std::string keyFile =
- this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
+ cmStrCat(this->DefaultArtifactDir, "/Windows_TemporaryKey.pfx");
ConvertToWindowsSlash(keyFile);
Elem(e1, "None").Attribute("Include", keyFile);
}
@@ -5604,8 +5632,9 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(fullFileName, sourceGroups);
if (sourceGroup && !sourceGroup->GetFullName().empty()) {
- sourceGroupedFile = sourceGroup->GetFullName() + "/" +
- cmsys::SystemTools::GetFilenameName(fullFileName);
+ sourceGroupedFile =
+ cmStrCat(sourceGroup->GetFullName(), '/',
+ cmsys::SystemTools::GetFilenameName(fullFileName));
cmsys::SystemTools::ConvertToUnixSlashes(sourceGroupedFile);
}
@@ -5653,8 +5682,9 @@ void cmVisualStudio10TargetGenerator::UpdateCache()
// Store a cache entry that later determines, if a package restore is
// required.
this->GeneratorTarget->Makefile->AddCacheDefinition(
- this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE", "ON",
- "Value Computed by CMake", cmStateEnums::STATIC);
+ cmStrCat(this->GeneratorTarget->GetName(),
+ "_REQUIRES_VS_PACKAGE_RESTORE"),
+ "ON", "Value Computed by CMake", cmStateEnums::STATIC);
} else {
// If there are any dependencies that require package restore, inherit the
// cache variable.
@@ -5667,7 +5697,8 @@ void cmVisualStudio10TargetGenerator::UpdateCache()
for (cmGeneratorTarget const* dt : depends) {
if (dt->HasPackageReferences()) {
this->GeneratorTarget->Makefile->AddCacheDefinition(
- this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE",
+ cmStrCat(this->GeneratorTarget->GetName(),
+ "_REQUIRES_VS_PACKAGE_RESTORE"),
"ON", "Value Computed by CMake", cmStateEnums::STATIC);
}
}
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 7e4503b..6188134 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -7,6 +7,7 @@
#include <vector>
#include <cm/iterator>
+#include <cmext/string_view>
#include "cmAlgorithms.h"
#include "cmLocalVisualStudioGenerator.h"
@@ -117,7 +118,7 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const
auto i = this->FlagMap.find("DebugType");
if (i != this->FlagMap.end()) {
if (i->second.size() == 1) {
- return i->second[0] != "none";
+ return i->second[0] != "none"_s;
}
}
return false;
@@ -137,13 +138,13 @@ bool cmVisualStudioGeneratorOptions::UsingUnicode() const
{
// Look for a _UNICODE definition.
return std::any_of(this->Defines.begin(), this->Defines.end(),
- [](std::string const& di) { return di == "_UNICODE"; });
+ [](std::string const& di) { return di == "_UNICODE"_s; });
}
bool cmVisualStudioGeneratorOptions::UsingSBCS() const
{
// Look for a _SBCS definition.
return std::any_of(this->Defines.begin(), this->Defines.end(),
- [](std::string const& di) { return di == "_SBCS"; });
+ [](std::string const& di) { return di == "_SBCS"_s; });
}
void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
@@ -171,7 +172,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
return;
}
- if (subOptions.size() == 1 && subOptions[0] == "NO") {
+ if (subOptions.size() == 1 && subOptions[0] == "NO"_s) {
AddFlag(ENABLE_UAC, "false");
return;
}
@@ -198,7 +199,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
1, std::max(std::string::size_type(0), keyValue[1].length() - 2));
}
- if (keyValue[0] == "level") {
+ if (keyValue[0] == "level"_s) {
if (uacExecuteLevelMap.find(keyValue[1]) == uacExecuteLevelMap.end()) {
// unknown level value
continue;
@@ -208,8 +209,8 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
continue;
}
- if (keyValue[0] == "uiAccess") {
- if (keyValue[1] != "true" && keyValue[1] != "false") {
+ if (keyValue[0] == "uiAccess"_s) {
+ if (keyValue[1] != "true"_s && keyValue[1] != "false"_s) {
// unknown uiAccess value
continue;
}
@@ -260,11 +261,11 @@ void cmVisualStudioGeneratorOptions::ParseFinish()
auto i = this->FlagMap.find("CudaRuntime");
if (i != this->FlagMap.end() && i->second.size() == 1) {
std::string& cudaRuntime = i->second[0];
- if (cudaRuntime == "static") {
+ if (cudaRuntime == "static"_s) {
cudaRuntime = "Static";
- } else if (cudaRuntime == "shared") {
+ } else if (cudaRuntime == "shared"_s) {
cudaRuntime = "Shared";
- } else if (cudaRuntime == "none") {
+ } else if (cudaRuntime == "none"_s) {
cudaRuntime = "None";
}
}
@@ -279,7 +280,7 @@ void cmVisualStudioGeneratorOptions::PrependInheritedString(
return;
}
std::string& value = i->second[0];
- value = "%(" + key + ") " + value;
+ value = cmStrCat("%(", key, ") ", value);
}
void cmVisualStudioGeneratorOptions::Reparse(std::string const& key)
@@ -298,19 +299,19 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(std::string const& flag)
{
// Look for Intel Fortran flags that do not map well in the flag table.
if (this->CurrentTool == FortranCompiler) {
- if (flag == "/dbglibs" || flag == "-dbglibs") {
+ if (flag == "/dbglibs"_s || flag == "-dbglibs"_s) {
this->FortranRuntimeDebug = true;
return;
}
- if (flag == "/threads" || flag == "-threads") {
+ if (flag == "/threads"_s || flag == "-threads"_s) {
this->FortranRuntimeMT = true;
return;
}
- if (flag == "/libs:dll" || flag == "-libs:dll") {
+ if (flag == "/libs:dll"_s || flag == "-libs:dll"_s) {
this->FortranRuntimeDLL = true;
return;
}
- if (flag == "/libs:static" || flag == "-libs:static") {
+ if (flag == "/libs:static"_s || flag == "-libs:static"_s) {
this->FortranRuntimeDLL = false;
return;
}
@@ -354,13 +355,13 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
return;
}
std::string tag = "PreprocessorDefinitions";
- if (lang == "CUDA") {
+ if (lang == "CUDA"_s) {
tag = "Defines";
}
std::ostringstream oss;
if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) {
- oss << "%(" << tag << ")";
+ oss << "%(" << tag << ')';
}
auto de = cmRemoveDuplicates(this->Defines);
for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
@@ -374,7 +375,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
// Escape this flag for the MSBuild.
if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) {
cmVS10EscapeForMSBuild(define);
- if (lang == "RC") {
+ if (lang == "RC"_s) {
cmSystemTools::ReplaceString(define, "\"", "\\\"");
}
}
@@ -393,9 +394,9 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
}
std::string tag = "AdditionalIncludeDirectories";
- if (lang == "CUDA") {
+ if (lang == "CUDA"_s) {
tag = "Include";
- } else if (lang == "ASM_MASM" || lang == "ASM_NASM") {
+ } else if (lang == "ASM_MASM"_s || lang == "ASM_NASM"_s) {
tag = "IncludePaths";
}
@@ -409,8 +410,8 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
pos++;
}
- if (lang == "ASM_NASM") {
- include += "\\";
+ if (lang == "ASM_NASM"_s) {
+ include += '\\';
}
// Escape this include for the MSBuild.
@@ -420,14 +421,14 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
oss << sep << include;
sep = ";";
- if (lang == "Fortran") {
+ if (lang == "Fortran"_s) {
include += "/$(ConfigurationName)";
oss << sep << include;
}
}
if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) {
- oss << sep << "%(" << tag << ")";
+ oss << sep << "%(" << tag << ')';
}
this->OutputFlag(fout, indent, tag, oss.str());
diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx
index 4b6754e..f685158 100644
--- a/Source/cmVisualStudioSlnData.cxx
+++ b/Source/cmVisualStudioSlnData.cxx
@@ -5,6 +5,7 @@
#include <cstddef>
#include <utility>
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
void cmSlnProjectEntry::AddProjectConfiguration(
@@ -72,7 +73,8 @@ std::string cmSlnData::GetConfigurationTarget(
const std::string& projectName, const std::string& solutionConfiguration,
const std::string& platformName)
{
- std::string solutionTarget = solutionConfiguration + "|" + platformName;
+ std::string solutionTarget =
+ cmStrCat(solutionConfiguration, '|', platformName);
cm::optional<cmSlnProjectEntry> project = GetProjectByName(projectName);
if (!project) {
return platformName;
diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx
index 71c758e..adfd4c5 100644
--- a/Source/cmVisualStudioSlnParser.cxx
+++ b/Source/cmVisualStudioSlnParser.cxx
@@ -8,6 +8,8 @@
#include <utility>
#include <vector>
+#include <cmext/string_view>
+
#include "cmsys/FStream.hxx"
#include "cmStringAlgorithms.h"
@@ -81,7 +83,7 @@ bool cmVisualStudioSlnParser::ParsedLine::IsKeyValuePair() const
std::string cmVisualStudioSlnParser::ParsedLine::GetArgVerbatim() const
{
if (this->Arg.second) {
- return Quote + this->Arg.first + Quote;
+ return cmStrCat(Quote, this->Arg.first, Quote);
}
return this->Arg.first;
}
@@ -101,7 +103,7 @@ std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(
if (idxValue < this->Values.size()) {
const StringData& data = this->Values[idxValue];
if (data.second) {
- return Quote + data.first + Quote;
+ return cmStrCat(Quote, data.first, Quote);
}
return data.first;
}
@@ -169,17 +171,12 @@ LineFormat cmVisualStudioSlnParser::State::NextLineFormat() const
case FileStateTopLevel:
return LineMultiValueTag;
case FileStateProject:
- return LineSingleValueTag;
- case FileStateProjectDependencies:
- return LineKeyValuePair;
case FileStateGlobal:
return LineSingleValueTag;
+ case FileStateProjectDependencies:
case FileStateSolutionConfigurations:
- return LineKeyValuePair;
case FileStateProjectConfigurations:
- return LineKeyValuePair;
case FileStateSolutionFilters:
- return LineKeyValuePair;
case FileStateGlobalSection:
return LineKeyValuePair;
case FileStateIgnore:
@@ -206,7 +203,7 @@ bool cmVisualStudioSlnParser::State::Process(
this->Stack.push(FileStateTopLevel);
break;
case FileStateTopLevel:
- if (line.GetTag() == "Project") {
+ if (line.GetTag() == "Project"_s) {
if (line.GetValueCount() != 3) {
result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
return false;
@@ -221,12 +218,12 @@ bool cmVisualStudioSlnParser::State::Process(
} else {
this->IgnoreUntilTag("EndProject");
}
- } else if (line.GetTag() == "Global") {
+ } else if (line.GetTag() == "Global"_s) {
this->Stack.push(FileStateGlobal);
- } else if (line.GetTag() == "VisualStudioVersion") {
+ } else if (line.GetTag() == "VisualStudioVersion"_s) {
output.SetVisualStudioVersion(line.GetValue(0));
- } else if (line.GetTag() == "MinimumVisualStudioVersion") {
+ } else if (line.GetTag() == "MinimumVisualStudioVersion"_s) {
output.SetMinimumVisualStudioVersion(line.GetValue(0));
} else {
result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
@@ -234,11 +231,11 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateProject:
- if (line.GetTag() == "EndProject") {
+ if (line.GetTag() == "EndProject"_s) {
this->Stack.pop();
- } else if (line.GetTag() == "ProjectSection") {
- if (line.GetArg() == "ProjectDependencies" &&
- line.GetValue(0) == "postProject") {
+ } else if (line.GetTag() == "ProjectSection"_s) {
+ if (line.GetArg() == "ProjectDependencies"_s &&
+ line.GetValue(0) == "postProject"_s) {
if (this->RequestedData.test(DataGroupProjectDependenciesBit)) {
this->Stack.push(FileStateProjectDependencies);
} else {
@@ -253,7 +250,7 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateProjectDependencies:
- if (line.GetTag() == "EndProjectSection") {
+ if (line.GetTag() == "EndProjectSection"_s) {
this->Stack.pop();
} else if (line.IsKeyValuePair()) {
// implement dependency storing here, once needed
@@ -264,25 +261,25 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateGlobal:
- if (line.GetTag() == "EndGlobal") {
+ if (line.GetTag() == "EndGlobal"_s) {
this->Stack.pop();
- } else if (line.GetTag() == "GlobalSection") {
- if (line.GetArg() == "SolutionConfigurationPlatforms" &&
- line.GetValue(0) == "preSolution") {
+ } else if (line.GetTag() == "GlobalSection"_s) {
+ if (line.GetArg() == "SolutionConfigurationPlatforms"_s &&
+ line.GetValue(0) == "preSolution"_s) {
if (this->RequestedData.test(DataGroupSolutionConfigurationsBit)) {
this->Stack.push(FileStateSolutionConfigurations);
} else {
this->IgnoreUntilTag("EndGlobalSection");
}
- } else if (line.GetArg() == "ProjectConfigurationPlatforms" &&
- line.GetValue(0) == "postSolution") {
+ } else if (line.GetArg() == "ProjectConfigurationPlatforms"_s &&
+ line.GetValue(0) == "postSolution"_s) {
if (this->RequestedData.test(DataGroupProjectConfigurationsBit)) {
this->Stack.push(FileStateProjectConfigurations);
} else {
this->IgnoreUntilTag("EndGlobalSection");
}
- } else if (line.GetArg() == "NestedProjects" &&
- line.GetValue(0) == "preSolution") {
+ } else if (line.GetArg() == "NestedProjects"_s &&
+ line.GetValue(0) == "preSolution"_s) {
if (this->RequestedData.test(DataGroupSolutionFiltersBit)) {
this->Stack.push(FileStateSolutionFilters);
} else {
@@ -300,7 +297,7 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateSolutionConfigurations:
- if (line.GetTag() == "EndGlobalSection") {
+ if (line.GetTag() == "EndGlobalSection"_s) {
this->Stack.pop();
} else if (line.IsKeyValuePair()) {
output.AddConfiguration(line.GetValue(0));
@@ -310,7 +307,7 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateProjectConfigurations:
- if (line.GetTag() == "EndGlobalSection") {
+ if (line.GetTag() == "EndGlobalSection"_s) {
this->Stack.pop();
} else if (line.IsKeyValuePair()) {
std::vector<std::string> tagElements =
@@ -331,7 +328,7 @@ bool cmVisualStudioSlnParser::State::Process(
return false;
}
- if (activeBuild == "ActiveCfg") {
+ if (activeBuild == "ActiveCfg"_s) {
projectEntry->AddProjectConfiguration(solutionConfiguration,
line.GetValue(0));
}
@@ -341,7 +338,7 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateSolutionFilters:
- if (line.GetTag() == "EndGlobalSection") {
+ if (line.GetTag() == "EndGlobalSection"_s) {
this->Stack.pop();
} else if (line.IsKeyValuePair()) {
// implement filter storing here, once needed
@@ -352,7 +349,7 @@ bool cmVisualStudioSlnParser::State::Process(
}
break;
case FileStateGlobalSection:
- if (line.GetTag() == "EndGlobalSection") {
+ if (line.GetTag() == "EndGlobalSection"_s) {
this->Stack.pop();
} else if (line.IsKeyValuePair()) {
// implement section storing here, once needed
@@ -544,7 +541,7 @@ bool cmVisualStudioSlnParser::ParseBOM(std::istream& input, std::string& line,
return false;
}
if (!this->LastResult.HadBOM) {
- line = bom + line; // it wasn't a BOM, prepend it to first line
+ line = cmStrCat(bom, line); // it wasn't a BOM, prepend it to first line
}
return true;
}
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index d8d0da9..8aa5384 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -7,14 +7,15 @@
#include <utility>
#include "cmGlobalVisualStudioGenerator.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
{
const std::string registryBase =
cmGlobalVisualStudioGenerator::GetRegistryBase(version);
- const std::string vckey = registryBase + "\\Setup\\VC;ProductDir";
- const std::string vskey = registryBase + "\\Setup\\VS;ProductDir";
+ const std::string vckey = cmStrCat(registryBase, "\\Setup\\VC;ProductDir");
+ const std::string vskey = cmStrCat(registryBase, "\\Setup\\VS;ProductDir");
if (!cmSystemTools::ReadRegistryValue(vckey, this->VcInstallDir,
cmSystemTools::KeyWOW64_32) ||
@@ -24,11 +25,10 @@ int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
}
cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir);
cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir);
- this->VcInstallDir.append("/");
- this->VsInstallDir.append("/");
+ this->VcInstallDir.append("//");
const std::string configFilename =
- this->VcInstallDir + "vcpackages/WCE.VCPlatform.config";
+ cmStrCat(this->VcInstallDir, "vcpackages/WCE.VCPlatform.config");
return this->ParseFile(configFilename.c_str());
}
@@ -39,7 +39,7 @@ std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
return OSMajorVersion;
}
- return OSMajorVersion + "." + OSMinorVersion;
+ return cmStrCat(OSMajorVersion, '.', OSMinorVersion);
}
const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
@@ -61,14 +61,14 @@ void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
this->CharacterData.clear();
- if (name == "PlatformData") {
+ if (name == "PlatformData"_s) {
this->PlatformName.clear();
this->OSMajorVersion.clear();
this->OSMinorVersion.clear();
this->Macros.clear();
}
- if (name == "Macro") {
+ if (name == "Macro"_s) {
std::string macroName;
std::string macroValue;
@@ -83,7 +83,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
if (!macroName.empty()) {
this->Macros[macroName] = macroValue;
}
- } else if (name == "Directories") {
+ } else if (name == "Directories"_s) {
for (const char** attr = attributes; *attr; attr += 2) {
if (strcmp(attr[0], "Include") == 0) {
this->Include = attr[1];
@@ -99,7 +99,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
{
if (!this->RequiredName) {
- if (name == "PlatformName") {
+ if (name == "PlatformName"_s) {
this->AvailablePlatforms.push_back(this->CharacterData);
}
return;
@@ -109,13 +109,13 @@ void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
return;
}
- if (name == "PlatformName") {
+ if (name == "PlatformName"_s) {
this->PlatformName = this->CharacterData;
- } else if (name == "OSMajorVersion") {
+ } else if (name == "OSMajorVersion"_s) {
this->OSMajorVersion = this->CharacterData;
- } else if (name == "OSMinorVersion") {
+ } else if (name == "OSMinorVersion"_s) {
this->OSMinorVersion = this->CharacterData;
- } else if (name == "Platform") {
+ } else if (name == "Platform"_s) {
if (this->PlatformName == this->RequiredName) {
this->FoundRequiredName = true;
}