Merge topic 'windows-tidy-cmstrcat'

d58253d155 clang-tidy: fix `performance-faster-string-find` lints
a19ec77200 clang-tidy: fix `readability-static-accessed-through-instance` lints
3d03629f20 cmWIXRichTextFormatWriter: remove identity cast
1df29567ac clang-tidy: fix `modernize-use-equals-default` lints
32fe862b8c clang-tidy: fix `readability-container-size-empty` lints
7eaab9a957 clang-tidy: fix `modernize-raw-string-literal` lints
ffa49c23aa clang-tidy: fix `readability-else-after-return` lints
4489e9a85c clang-tidy: fix `modernize-use-auto` lints
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8668
This commit is contained in:
Brad King
2023-08-01 13:31:21 +00:00
committed by Kitware Robot
42 changed files with 1018 additions and 929 deletions

View File

@@ -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);
}
}

View File

@@ -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");

View File

@@ -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();

View File

@@ -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");
}

View File

@@ -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()) {

View File

@@ -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;
}

View File

@@ -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 ");
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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)));
}
}

View File

@@ -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;
}

View File

@@ -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, '"'));
}
}
}

View File

@@ -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, '"'));
}
}
}

View File

@@ -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.

View File

@@ -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 "

View File

@@ -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"));

View File

@@ -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 "

View File

@@ -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 "";

View File

@@ -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";

View File

@@ -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";

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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 =

View File

@@ -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';
}
}
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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");
}

View File

@@ -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

View File

@@ -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:

View File

@@ -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 ";
}
}

View File

@@ -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()));
}
}

View File

@@ -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),

View File

@@ -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);

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -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());

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}