From 7e3b9af191b1ae596b228d8ac3d709eecf8d82d4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:35:27 -0400 Subject: clang-tidy: fix `readability-container-data-pointer` lints --- Source/cmMachO.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index 4fcaedf..91a7b84 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -69,7 +69,7 @@ bool read(cmsys::ifstream& fin, std::vector& v) return true; } return static_cast( - fin.read(reinterpret_cast(&v[0]), sizeof(T) * v.size())); + fin.read(reinterpret_cast(v.data()), sizeof(T) * v.size())); } } -- cgit v0.12 From 3f1378fbcab72a849908bbc988254f392d04c41a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 12:23:22 -0400 Subject: strings: compare to static `string_view` instances in Windows-only code --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 17 +-- Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx | 4 +- Source/CPack/WiX/cmWIXPatchParser.cxx | 11 +- Source/cmCallVisualStudioMacro.cxx | 4 +- Source/cmGlobalJOMMakefileGenerator.cxx | 3 +- Source/cmGlobalMSYSMakefileGenerator.cxx | 6 +- Source/cmGlobalNMakeMakefileGenerator.cxx | 3 +- Source/cmGlobalVisualStudio10Generator.cxx | 148 +++++++++++----------- Source/cmGlobalVisualStudio11Generator.cxx | 8 +- Source/cmGlobalVisualStudio12Generator.cxx | 10 +- Source/cmGlobalVisualStudio14Generator.cxx | 7 +- Source/cmGlobalVisualStudio7Generator.cxx | 27 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 7 +- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 8 +- Source/cmGlobalWatcomWMakeGenerator.cxx | 5 +- Source/cmLocalVisualStudio10Generator.cxx | 4 +- Source/cmLocalVisualStudioGenerator.cxx | 3 +- Source/cmVisualStudio10TargetGenerator.cxx | 144 ++++++++++----------- Source/cmVisualStudioGeneratorOptions.cxx | 41 +++--- Source/cmVisualStudioSlnParser.cxx | 46 +++---- Source/cmVisualStudioWCEPlatformParser.cxx | 16 +-- 21 files changed, 276 insertions(+), 246 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1ea78fd..2330935 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -7,6 +7,7 @@ #include #include #include +#include #include "cmsys/Directory.hxx" #include "cmsys/Encoding.hxx" @@ -556,7 +557,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 +614,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"); @@ -757,7 +758,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"; @@ -818,7 +819,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( if (type == cmWIXShortcuts::START_MENU) { cmValue cpackWixProgramMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != ".") { + if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != "."_s) { fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix); } @@ -851,10 +852,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,7 +924,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) { std::string fileName = dir.GetFile(static_cast(i)); - if (fileName == "." || fileName == "..") { + if (fileName == "."_s || fileName == ".."_s) { continue; } @@ -1001,7 +1002,7 @@ 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"; diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx index 0a83ca2..13bbf37 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXDirectoriesSourceWriter.h" +#include + 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); diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 8b26c4e..57539d3 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -5,6 +5,7 @@ #include #include +#include #include @@ -39,13 +40,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 +79,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 +99,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 +109,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 { diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index 94b6e18..292b9a3 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -4,6 +4,8 @@ #include +#include + #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -305,7 +307,7 @@ HRESULT GetRunningInstances(std::map& mrot) //! we perhaps looking for any and all solutions? bool FilesSameSolution(const std::string& slnFile, const std::string& slnName) { - if (slnFile == "ALL" || slnName == "ALL") { + if (slnFile == "ALL"_s || slnName == "ALL"_s) { return true; } diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index f1d4d09..44980d6 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -5,6 +5,7 @@ #include #include +#include #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -45,7 +46,7 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os, std::string const& lang, cmValue envVar) const { - if (lang == "CXX" || lang == "C") { + if (lang == "CXX"_s || lang == "C"_s) { /* clang-format off */ os << "To use the JOM generator with Visual C++, cmake must be run from a " diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index e543aea..26b30fd 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalMSYSMakefileGenerator.h" +#include + #include "cmsys/FStream.hxx" #include "cmMakefile.h" @@ -31,7 +33,7 @@ std::string cmGlobalMSYSMakefileGenerator::FindMinGW( while (fin) { fin >> path; fin >> mount; - if (mount == "/mingw") { + if (mount == "/mingw"_s) { mingwBin = cmStrCat(path, "/bin"); } } @@ -45,7 +47,7 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage( this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() && - !(1 == l.size() && l[0] == "NONE")) { + !(1 == l.size() && l[0] == "NONE"_s)) { cmSystemTools::Error( "CMAKE_AR was not found, please set to archive program. " + mf->GetSafeDefinition("CMAKE_AR")); diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index cb53850..424c4bd 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -5,6 +5,7 @@ #include #include +#include #include "cmsys/RegularExpression.hxx" @@ -88,7 +89,7 @@ cmDocumentationEntry cmGlobalNMakeMakefileGenerator::GetDocumentation() void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice( std::ostream& os, std::string const& lang, cmValue envVar) const { - if (lang == "CXX" || lang == "C") { + if (lang == "CXX"_s || lang == "C"_s) { /* clang-format off */ os << "To use the NMake generator with Visual C++, cmake must be run from a " diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index f1d04e5..39ec1cd 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -187,7 +188,7 @@ 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. @@ -370,7 +371,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 +396,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,26 +415,26 @@ 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 " @@ -441,7 +442,8 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); 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; } @@ -519,15 +521,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 +567,7 @@ bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset( std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const { - if (this->SystemVersion == "8.0") { + if (this->SystemVersion == "8.0"_s) { return "CE800"; } return ""; @@ -641,10 +643,10 @@ void cmGlobalVisualStudio10Generator::EnableLanguage( std::vector 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 +832,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; } @@ -899,19 +901,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 +922,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"); } } @@ -1049,7 +1051,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 +1082,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.Add(makeProgramSelected); cm::optional proj = cm::nullopt; - if (tname == "clean") { + if (tname == "clean"_s) { makeCommand.Add(cmStrCat(projectName, ".sln")); makeCommand.Add("/t:Clean"); } else { @@ -1164,7 +1166,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 +1273,7 @@ std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion() std::string cmGlobalVisualStudio10Generator::GetApplicationTypeRevision() const { - if (this->GetSystemName() == "Android") { + if (this->GetSystemName() == "Android"_s) { return this->GetAndroidApplicationTypeRevision(); } @@ -1302,23 +1304,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 +1539,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 +1565,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 +1591,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 +1612,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 +1633,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 +1659,17 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); - if ((useToolset == "v140") || (useToolset == "v141") || - (useToolset == "v142")) { + if ((useToolset == "v140"_s) || (useToolset == "v141"_s) || + (useToolset == "v142"_s)) { return "v14"; } - if (useToolset == "v120") { + if (useToolset == "v120"_s) { return "v12"; } - if (useToolset == "v110") { + if (useToolset == "v110"_s) { return "v11"; } - if (useToolset == "v100") { + if (useToolset == "v100"_s) { return "v10"; } return ""; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index c4e1e11..5491e6e 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -7,6 +7,8 @@ #include #include +#include + #include "cmGlobalGenerator.h" #include "cmGlobalVisualStudioGenerator.h" #include "cmMakefile.h" @@ -25,7 +27,7 @@ void cmGlobalVisualStudio11Generator::EnableLanguage( std::vector const& lang, cmMakefile* mf, bool optional) { for (std::string const& it : lang) { - if (it == "ASM_MARMASM") { + if (it == "ASM_MARMASM"_s) { this->MarmasmEnabled = true; } } @@ -72,7 +74,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 +89,7 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset( bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset( std::string& toolset) const { - if (this->SystemVersion == "8.0") { + if (this->SystemVersion == "8.0"_s) { if (this->IsWindowsStoreToolsetInstalled() && this->IsWindowsDesktopToolsetInstalled()) { toolset = "v110"; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index b7af31b..21776fc 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -6,6 +6,8 @@ #include #include +#include + #include "cmGlobalGenerator.h" #include "cmGlobalGeneratorFactory.h" #include "cmGlobalVisualStudioGenerator.h" @@ -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; } @@ -189,7 +191,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 +206,7 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset( bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset( std::string& toolset) const { - if (this->SystemVersion == "8.1") { + if (this->SystemVersion == "8.1"_s) { if (this->IsWindowsStoreToolsetInstalled() && this->IsWindowsDesktopToolsetInstalled()) { toolset = "v120"; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 4300d5c..d2e9cb2 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -6,6 +6,7 @@ #include #include +#include #include "cmGlobalGenerator.h" #include "cmGlobalGeneratorFactory.h" @@ -198,7 +199,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 +232,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" @@ -361,7 +362,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; } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 203bb09..67e0a29 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -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,7 +252,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand( continue; } bool clean = false; - if (realTarget == "clean") { + if (realTarget == "clean"_s) { clean = true; realTarget = "ALL_BUILD"; } @@ -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); @@ -572,11 +572,12 @@ 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"; @@ -590,7 +591,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( const std::string value = cmTrimWhitespace(itPair.substr(posEqual + 1)); fout << "\t\t" << key << " = " << value << "\n"; - if (key == "SolutionGuid") { + if (key == "SolutionGuid"_s) { addGuid = false; } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 4d7571a..65c8c38 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -12,6 +12,7 @@ #include #include +#include #include @@ -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()); @@ -819,7 +820,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( diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 9fe66d3..44019f6 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -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; } diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index ed44e6b..ca7a1b9 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -4,6 +4,9 @@ #include +#include +#include + #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" @@ -46,7 +49,7 @@ void cmGlobalWatcomWMakeGenerator::EnableLanguage( bool cmGlobalWatcomWMakeGenerator::SetSystemName(std::string const& s, cmMakefile* mf) { - if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86") { + if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86"_s) { mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl"); } diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 8fe6677..2a1521b 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLocalVisualStudio10Generator.h" +#include + #include #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; } } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 58d46f1..34b8ae3 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -5,6 +5,7 @@ #include #include +#include #include "windows.h" @@ -204,7 +205,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( std::string suffix; if (cmd.size() > 4) { suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4)); - if (suffix == ".bat" || suffix == ".cmd") { + if (suffix == ".bat"_s || suffix == ".cmd"_s) { script += "call "; } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4af3ebc..cea0168 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include "windows.h" @@ -308,7 +309,7 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition( oss << "'"; // handle special case for 32 bit C# targets if (this->ProjectType == VsProjectType::csproj && - this->Platform == "Win32") { + this->Platform == "Win32"_s) { oss << " Or "; oss << "'$(Configuration)|$(Platform)'=='"; oss << config << "|x86"; @@ -509,7 +510,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( // Setting ResolveNugetPackages to false skips this target and the build // succeeds. cm::string_view targetName{ this->GeneratorTarget->GetName() }; - if (targetName == "ALL_BUILD" || targetName == "PACKAGE" || + if (targetName == "ALL_BUILD"_s || targetName == "PACKAGE"_s || targetName == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { Elem e1(e0, "PropertyGroup"); e1.Element("ResolveNugetPackages", "false"); @@ -1048,8 +1049,8 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) } cm::string_view globalKey = cm::string_view(keyIt).substr(prefix.length()); // Skip invalid or separately-handled properties. - if (globalKey.empty() || globalKey == "PROJECT_TYPES" || - globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") { + if (globalKey.empty() || globalKey == "PROJECT_TYPES"_s || + globalKey == "ROOTNAMESPACE"_s || globalKey == "KEYWORD"_s) { continue; } cmValue value = this->GeneratorTarget->GetProperty(keyIt); @@ -1336,7 +1337,7 @@ void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences(Elem& e0) { if (this->MSTools) { if (this->GlobalGenerator->TargetsWindowsPhone() && - this->GlobalGenerator->GetSystemVersion() == "8.0") { + this->GlobalGenerator->GetSystemVersion() == "8.0"_s) { Elem(e0, "Import") .Attribute("Project", "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v" @@ -1377,7 +1378,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0) } if (this->GlobalGenerator->TargetsWindowsPhone() && - this->GlobalGenerator->GetSystemVersion() == "8.0" && + this->GlobalGenerator->GetSystemVersion() == "8.0"_s && references.empty()) { references.push_back(std::string{ "platform.winmd" }); } @@ -1507,9 +1508,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( std::string useOfMfcValue = "false"; if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { - if (mfcFlagValue == "1") { + if (mfcFlagValue == "1"_s) { useOfMfcValue = "Static"; - } else if (mfcFlagValue == "2") { + } else if (mfcFlagValue == "2"_s) { useOfMfcValue = "Dynamic"; } } @@ -1645,7 +1646,7 @@ void cmVisualStudio10TargetGenerator::WriteAndroidConfigurationValues( } if (cmValue stlType = this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) { - if (*stlType != "none") { + if (*stlType != "none"_s) { e1.Element("UseOfStl", *stlType); } } @@ -1956,7 +1957,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() for (auto const& ti : this->Tools) { if ((this->GeneratorTarget->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) && - (ti.first == "None")) { + (ti.first == "None"_s)) { this->WriteBuildSystemSources(e0, ti.first, ti.second); } else { this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups); @@ -1970,7 +1971,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() for (std::string const& oi : this->AddedFiles) { std::string fileName = cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(oi)); - if (fileName == "wmappmanifest.xml") { + if (fileName == "wmappmanifest.xml"_s) { Elem e2(e1, "XML"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); @@ -1979,7 +1980,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() Elem e2(e1, "AppxManifest"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); - } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") { + } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx"_s) { Elem e2(e1, "None"); e2.Attribute("Include", oi); e2.Element("Filter", "Resource Files"); @@ -2227,7 +2228,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( if (this->ProjectType == VsProjectType::csproj && !this->InSourceBuild) { toolHasSettings = true; } - if (ext == "hlsl") { + if (ext == "hlsl"_s) { tool = "FXCompile"; // Figure out the type of shader compiler to use. if (cmValue st = sf->GetProperty("VS_SHADER_TYPE")) { @@ -2305,22 +2306,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( toolSettings[config]["ObjectFileOutput"] = *sofn; } } - } else if (ext == "jpg" || ext == "png") { + } else if (ext == "jpg"_s || ext == "png"_s) { tool = "Image"; - } else if (ext == "resw") { + } else if (ext == "resw"_s) { tool = "PRIResource"; - } else if (ext == "xml") { + } else if (ext == "xml"_s) { tool = "XML"; - } else if (ext == "natvis") { + } else if (ext == "natvis"_s) { tool = "Natvis"; - } else if (ext == "settings") { + } else if (ext == "settings"_s) { settingsLastGenOutput = cmsys::SystemTools::GetFilenameName(sf->GetFullPath()); std::size_t pos = settingsLastGenOutput.find(".settings"); settingsLastGenOutput.replace(pos, 9, ".Designer.cs"); settingsGenerator = "SettingsSingleFileGenerator"; toolHasSettings = true; - } else if (ext == "vsixmanifest") { + } else if (ext == "vsixmanifest"_s) { subType = "Designer"; } if (cmValue c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) { @@ -2341,13 +2342,13 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( if (this->NsightTegra) { // Nsight Tegra needs specific file types to check up-to-dateness. std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName()); - if (name == "androidmanifest.xml" || name == "build.xml" || - name == "proguard.cfg" || name == "proguard-project.txt" || - ext == "properties") { + if (name == "androidmanifest.xml"_s || name == "build.xml"_s || + name == "proguard.cfg"_s || name == "proguard-project.txt"_s || + ext == "properties"_s) { tool = "AndroidBuild"; - } else if (ext == "java") { + } else if (ext == "java"_s) { tool = "JCompile"; - } else if (ext == "asm" || ext == "s") { + } else if (ext == "asm"_s || ext == "s"_s) { tool = "ClCompile"; } } @@ -2410,7 +2411,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)"); } for (auto& config : this->Configurations) { - if (cge->Evaluate(this->LocalGenerator, config) == "1") { + if (cge->Evaluate(this->LocalGenerator, config) == "1"_s) { e2.WritePlatformConfigTag("DeploymentContent", "'$(Configuration)|$(Platform)'=='" + config + "|" + this->Platform + "'", @@ -2455,7 +2456,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, // conversion uses full paths when possible to allow deeper trees. // However, CUDA 8.0 msbuild rules fail on absolute paths so for CUDA // we must use relative paths. - bool forceRelative = sf->GetLanguage() == "CUDA"; + bool forceRelative = sf->GetLanguage() == "CUDA"_s; std::string sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative); ConvertToWindowsSlash(sourceFile); e2.Attribute("Include", sourceFile); @@ -2553,22 +2554,23 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) case cmGeneratorTarget::SourceKindUnityBatched: case cmGeneratorTarget::SourceKindObjectSource: { const std::string& lang = si.Source->GetLanguage(); - if (lang == "C" || lang == "CXX") { + if (lang == "C"_s || lang == "CXX"_s) { tool = "ClCompile"; - } else if (lang == "ASM_MARMASM" && + } else if (lang == "ASM_MARMASM"_s && this->GlobalGenerator->IsMarmasmEnabled()) { tool = "MARMASM"; - } else if (lang == "ASM_MASM" && + } else if (lang == "ASM_MASM"_s && this->GlobalGenerator->IsMasmEnabled()) { tool = "MASM"; - } else if (lang == "ASM_NASM" && + } else if (lang == "ASM_NASM"_s && this->GlobalGenerator->IsNasmEnabled()) { tool = "NASM"; - } else if (lang == "RC") { + } else if (lang == "RC"_s) { tool = "ResourceCompile"; - } else if (lang == "CSharp") { + } else if (lang == "CSharp"_s) { tool = "Compile"; - } else if (lang == "CUDA" && this->GlobalGenerator->IsCudaEnabled()) { + } else if (lang == "CUDA"_s && + this->GlobalGenerator->IsCudaEnabled()) { tool = "CudaCompile"; } else { tool = "None"; @@ -2591,7 +2593,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) std::back_inserter(exclude_configs)); Elem e2(e1, tool); - bool isCSharp = (si.Source->GetLanguage() == "CSharp"); + bool isCSharp = (si.Source->GetLanguage() == "CSharp"_s); if (isCSharp && !exclude_configs.empty()) { std::stringstream conditions; bool firstConditionSet{ false }; @@ -2730,33 +2732,33 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( // Force language if the file extension does not match. // Note that MSVC treats the upper-case '.C' extension as C and not C++. std::string const ext = sf.GetExtension(); - std::string const extLang = ext == "C" + std::string const extLang = ext == "C"_s ? "C" : this->GlobalGenerator->GetLanguageFromExtension(ext.c_str()); std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf); const char* compileAs = nullptr; if (lang != extLang) { - if (lang == "CXX") { + if (lang == "CXX"_s) { // force a C++ file type compileAs = "CompileAsCpp"; - } else if (lang == "C") { + } else if (lang == "C"_s) { // force to c compileAs = "CompileAsC"; } } - bool noWinRT = this->TargetCompileAsWinRT && lang == "C"; + bool noWinRT = this->TargetCompileAsWinRT && lang == "C"_s; // for the first time we need a new line if there is something // produced here. if (!objectName.empty()) { - if (lang == "CUDA") { + if (lang == "CUDA"_s) { e2.Element("CompileOut", "$(IntDir)/" + objectName); } else { e2.Element("ObjectFileName", "$(IntDir)/" + objectName); } } - if (lang == "ASM_NASM") { + if (lang == "ASM_NASM"_s) { if (cmValue objectDeps = sf.GetProperty("OBJECT_DEPENDS")) { cmList depends{ *objectDeps }; for (auto& d : depends) { @@ -2841,20 +2843,20 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; cmIDEFlagTable const* flagtable = nullptr; const std::string& srclang = source->GetLanguage(); - if (srclang == "C" || srclang == "CXX") { + if (srclang == "C"_s || srclang == "CXX"_s) { flagtable = gg->GetClFlagTable(); - } else if (srclang == "ASM_MARMASM" && + } else if (srclang == "ASM_MARMASM"_s && this->GlobalGenerator->IsMarmasmEnabled()) { flagtable = gg->GetMarmasmFlagTable(); - } else if (srclang == "ASM_MASM" && + } else if (srclang == "ASM_MASM"_s && this->GlobalGenerator->IsMasmEnabled()) { flagtable = gg->GetMasmFlagTable(); - } else if (lang == "ASM_NASM" && + } else if (lang == "ASM_NASM"_s && this->GlobalGenerator->IsNasmEnabled()) { flagtable = gg->GetNasmFlagTable(); - } else if (srclang == "RC") { + } else if (srclang == "RC"_s) { flagtable = gg->GetRcFlagTable(); - } else if (srclang == "CSharp") { + } else if (srclang == "CSharp"_s) { flagtable = gg->GetCSharpFlagTable(); } cmGeneratorExpressionInterpreter genexInterpreter( @@ -3418,7 +3420,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } // Add C-specific flags expressible in a ClCompile meant for C++. - if (langForClCompile == "CXX") { + if (langForClCompile == "CXX"_s) { std::set languages; this->GeneratorTarget->GetLanguages(languages, configName); if (languages.count("C")) { @@ -3473,7 +3475,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string managedType = clOptions.HasFlag("CompileAsManaged") ? clOptions.GetFlag("CompileAsManaged") : "Mixed"; - if (managedType == "Safe" || managedType == "Pure") { + if (managedType == "Safe"_s || managedType == "Pure"_s) { // force empty calling convention if safe clr is used clOptions.AddFlag("CallingConvention", ""); } @@ -3497,7 +3499,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // Remove any target-wide -TC or -TP flag added by the project. // Such flags are unnecessary and break our model of language selection. - if (langForClCompile == "C" || langForClCompile == "CXX") { + if (langForClCompile == "C"_s || langForClCompile == "CXX"_s) { clOptions.RemoveFlag("CompileAs"); } @@ -3743,7 +3745,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( // CUDA automatically passes the proper '--machine' flag to nvcc // for the current architecture, but does not reflect this default // in the user-visible IDE settings. Set it explicitly. - if (this->Platform == "x64") { + if (this->Platform == "x64"_s) { cudaOptions.AddFlag("TargetMachinePlatform", "64"); } @@ -3786,11 +3788,11 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( // Add runtime library selection flag. std::string const& cudaRuntime = this->GeneratorTarget->GetRuntimeLinkLibrary("CUDA", configName); - if (cudaRuntime == "STATIC") { + if (cudaRuntime == "STATIC"_s) { cudaOptions.AddFlag("CudaRuntime", "Static"); - } else if (cudaRuntime == "SHARED") { + } else if (cudaRuntime == "SHARED"_s) { cudaOptions.AddFlag("CudaRuntime", "Shared"); - } else if (cudaRuntime == "NONE") { + } else if (cudaRuntime == "NONE"_s) { cudaOptions.AddFlag("CudaRuntime", "None"); } @@ -4134,7 +4136,7 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions( e2.Element("AdditionalManifestFiles", oss.str()); } if (dpiAware) { - if (*dpiAware == "PerMonitor") { + if (*dpiAware == "PerMonitor"_s) { e2.Element("EnableDpiAwareness", "PerMonitorHighDPIAware"); } else if (cmIsOn(*dpiAware)) { e2.Element("EnableDpiAwareness", "true"); @@ -4377,7 +4379,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } if (cmValue stackVal = this->Makefile->GetDefinition( - "CMAKE_" + linkLanguage + "_STACK_SIZE")) { + cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE"))) { linkOptions.AddFlag("StackReserveSize", *stackVal); } @@ -4409,7 +4411,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } if (this->GlobalGenerator->TargetsWindowsPhone() && - this->GlobalGenerator->GetSystemVersion() == "8.0") { + this->GlobalGenerator->GetSystemVersion() == "8.0"_s) { // WindowsPhone 8.0 does not have ole32. linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib"); } @@ -4912,7 +4914,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( if (this->IsMissingFiles && !(this->GlobalGenerator->TargetsWindowsPhone() && - this->GlobalGenerator->GetSystemVersion() == "8.0")) { + this->GlobalGenerator->GetSystemVersion() == "8.0"_s)) { // Move the manifest to a project directory to avoid clashes std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); @@ -5022,7 +5024,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) e1.Element("ApplicationType", (isWindowsPhone ? "Windows Phone" : "Windows Store")); e1.Element("DefaultLanguage", "en-US"); - if (rev == "10.0") { + if (rev == "10.0"_s) { e1.Element("ApplicationTypeRevision", rev); // Visual Studio 14.0 is necessary for building 10.0 apps e1.Element("MinimumVisualStudioVersion", "14.0"); @@ -5030,7 +5032,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { isAppContainer = true; } - } else if (rev == "8.1") { + } else if (rev == "8.1"_s) { e1.Element("ApplicationTypeRevision", rev); // Visual Studio 12.0 is necessary for building 8.1 apps e1.Element("MinimumVisualStudioVersion", "12.0"); @@ -5038,7 +5040,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { isAppContainer = true; } - } else if (rev == "8.0") { + } else if (rev == "8.0"_s) { e1.Element("ApplicationTypeRevision", rev); // Visual Studio 11.0 is necessary for building 8.0 apps e1.Element("MinimumVisualStudioVersion", "11.0"); @@ -5062,9 +5064,9 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) if (isAppContainer) { e1.Element("AppContainerApplication", "true"); } else if (!isAndroid) { - if (this->Platform == "ARM64") { + if (this->Platform == "ARM64"_s) { e1.Element("WindowsSDKDesktopARM64Support", "true"); - } else if (this->Platform == "ARM") { + } else if (this->Platform == "ARM"_s) { e1.Element("WindowsSDKDesktopARMSupport", "true"); } } @@ -5077,7 +5079,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"); if (targetPlatformMinVersion) { e1.Element("WindowsTargetPlatformMinVersion", *targetPlatformMinVersion); - } else if (isWindowsStore && rev == "10.0") { + } else if (isWindowsStore && rev == "10.0"_s) { // If the min version is not set, then use the TargetPlatformVersion if (!targetPlatformVersion.empty()) { e1.Element("WindowsTargetPlatformMinVersion", targetPlatformVersion); @@ -5100,7 +5102,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles() cmGeneratorTarget::SourceKindAppManifest); std::string const& v = this->GlobalGenerator->GetSystemVersion(); if (this->GlobalGenerator->TargetsWindowsPhone()) { - if (v == "8.0") { + if (v == "8.0"_s) { // Look through the sources for WMAppManifest.xml bool foundManifest = false; for (cmGeneratorTarget::AllConfigSource const& source : @@ -5116,16 +5118,16 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles() if (!foundManifest) { this->IsMissingFiles = true; } - } else if (v == "8.1") { + } else if (v == "8.1"_s) { if (manifestSources.empty()) { this->IsMissingFiles = true; } } } else if (this->GlobalGenerator->TargetsWindowsStore()) { if (manifestSources.empty()) { - if (v == "8.0") { + if (v == "8.0"_s) { this->IsMissingFiles = true; - } else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0")) { + } else if (v == "8.1"_s || cmHasLiteralPrefix(v, "10.0")) { this->IsMissingFiles = true; } } @@ -5137,15 +5139,15 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles(Elem& e1) { std::string const& v = this->GlobalGenerator->GetSystemVersion(); if (this->GlobalGenerator->TargetsWindowsPhone()) { - if (v == "8.0") { + if (v == "8.0"_s) { this->WriteMissingFilesWP80(e1); - } else if (v == "8.1") { + } else if (v == "8.1"_s) { this->WriteMissingFilesWP81(e1); } } else if (this->GlobalGenerator->TargetsWindowsStore()) { - if (v == "8.0") { + if (v == "8.0"_s) { this->WriteMissingFilesWS80(e1); - } else if (v == "8.1") { + } else if (v == "8.1"_s) { this->WriteMissingFilesWS81(e1); } else if (cmHasLiteralPrefix(v, "10.0")) { this->WriteMissingFilesWS10_0(e1); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 7e4503b..9bbe34b 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -7,6 +7,7 @@ #include #include +#include #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"; } } @@ -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,7 +355,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( return; } std::string tag = "PreprocessorDefinitions"; - if (lang == "CUDA") { + if (lang == "CUDA"_s) { tag = "Defines"; } @@ -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,7 +410,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( pos++; } - if (lang == "ASM_NASM") { + if (lang == "ASM_NASM"_s) { include += "\\"; } @@ -420,7 +421,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( oss << sep << include; sep = ";"; - if (lang == "Fortran") { + if (lang == "Fortran"_s) { include += "/$(ConfigurationName)"; oss << sep << include; } diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 71c758e..76791a6 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -8,6 +8,8 @@ #include #include +#include + #include "cmsys/FStream.hxx" #include "cmStringAlgorithms.h" @@ -206,7 +208,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 +223,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 +236,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 +255,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 +266,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 +302,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 +312,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 tagElements = @@ -331,7 +333,7 @@ bool cmVisualStudioSlnParser::State::Process( return false; } - if (activeBuild == "ActiveCfg") { + if (activeBuild == "ActiveCfg"_s) { projectEntry->AddProjectConfiguration(solutionConfiguration, line.GetValue(0)); } @@ -341,7 +343,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 +354,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 diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index d8d0da9..19c8d35 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -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; } -- cgit v0.12 From a5ba00bdf875cb1290b90abb8c9f55c1b7f88876 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:39:37 -0400 Subject: strings: combine string literals where possible --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 13 ++++++++----- Source/cmGlobalVisualStudio10Generator.cxx | 6 ++++-- Source/cmGlobalVisualStudio11Generator.cxx | 6 ++++-- Source/cmGlobalVisualStudio12Generator.cxx | 6 ++++-- Source/cmGlobalVisualStudio14Generator.cxx | 3 ++- Source/cmGlobalVisualStudio71Generator.cxx | 6 +++--- Source/cmVisualStudio10TargetGenerator.cxx | 11 ++++++----- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 2330935..45f91b2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -104,8 +104,9 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, std::ostringstream command; command << QuotePath(executable); - command << " -nologo"; - command << " -arch " << arch; + command << " -nologo" + " -arch " + << arch; command << " -out " << QuotePath(objectFile); for (std::string const& ext : CandleExtensions) { @@ -132,8 +133,9 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) std::ostringstream command; command << QuotePath(executable); - command << " -nologo"; - command << " -out " << QuotePath(CMakeToWixPath(packageFileNames.at(0))); + command << " -nologo" + " -out " + << QuotePath(CMakeToWixPath(packageFileNames.at(0))); for (std::string const& ext : this->LightExtensions) { command << " -ext " << QuotePath(ext); @@ -1183,7 +1185,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; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 39ec1cd..8befa75 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -438,7 +438,8 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) if (this->PlatformInGeneratorName) { std::ostringstream e; e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR " - << "specifies a platform too: '" << this->GetName() << "'"; + "specifies a platform too: '" + << this->GetName() << "'"; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } @@ -468,7 +469,8 @@ 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() << "'"; + "specifies a platform too: '" + << this->GetName() << "'"; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 5491e6e..84fa378 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -44,7 +44,8 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf) << 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 + "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()); @@ -62,7 +63,8 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf) << 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 + "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()); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 21776fc..3c15bd8 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -159,7 +159,8 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf) << 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 + "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()); @@ -179,7 +180,8 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf) << 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 + "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()); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index d2e9cb2..7cb5a66 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -182,7 +182,8 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf) << 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 + "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()); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index bcb26cc..01f4803 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -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 */ } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cea0168..c7088d5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -310,10 +310,11 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition( // handle special case for 32 bit C# targets if (this->ProjectType == VsProjectType::csproj && this->Platform == "Win32"_s) { - oss << " Or "; - oss << "'$(Configuration)|$(Platform)'=='"; - oss << config << "|x86"; - oss << "'"; + oss << " Or " + "'$(Configuration)|$(Platform)'=='"; + oss << config + << "|x86" + "'"; } return oss.str(); } @@ -881,7 +882,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( oss << " " << i << ";\n"; } oss << " " - << "$(BuildDependsOn)\n"; + "$(BuildDependsOn)\n"; e1.Element("BuildDependsOn", oss.str()); } } -- cgit v0.12 From 2409f62d18b714f3342db99201eadc13420708da Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:57:48 -0400 Subject: strings: simplify streaming sequences --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 11 +++++------ Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 9 ++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 45f91b2..3a116db 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -103,11 +103,10 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, } std::ostringstream command; - command << QuotePath(executable); - command << " -nologo" + command << QuotePath(executable) + << " -nologo" " -arch " - << arch; - command << " -out " << QuotePath(objectFile); + << arch << " -out " << QuotePath(objectFile); for (std::string const& ext : CandleExtensions) { command << " -ext " << QuotePath(ext); @@ -132,8 +131,8 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) } std::ostringstream command; - command << QuotePath(executable); - command << " -nologo" + command << QuotePath(executable) + << " -nologo" " -out " << QuotePath(CMakeToWixPath(packageFileNames.at(0))); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 65c8c38..ad93b6c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -286,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"); } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index c7088d5..ddb08ba 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -304,15 +304,14 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition( const std::string& config) const { std::ostringstream oss; - oss << "'$(Configuration)|$(Platform)'=='"; - oss << config << "|" << this->Platform; - oss << "'"; + oss << "'$(Configuration)|$(Platform)'=='" << config << "|" << this->Platform + << "'"; // handle special case for 32 bit C# targets if (this->ProjectType == VsProjectType::csproj && this->Platform == "Win32"_s) { oss << " Or " - "'$(Configuration)|$(Platform)'=='"; - oss << config + "'$(Configuration)|$(Platform)'=='" + << config << "|x86" "'"; } -- cgit v0.12 From 7137b1783549fb33fcc09eabdd0d77511d36c23b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:33:36 -0400 Subject: cmStrCat: use in Windows-specific sources --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 48 +-- Source/CPack/WiX/cmWIXAccessControlList.cxx | 5 +- Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 12 +- Source/cmGlobalVisualStudio10Generator.cxx | 310 ++++++++++---------- Source/cmGlobalVisualStudio11Generator.cxx | 35 +-- Source/cmGlobalVisualStudio12Generator.cxx | 48 +-- Source/cmGlobalVisualStudio14Generator.cxx | 40 +-- Source/cmGlobalVisualStudio71Generator.cxx | 4 +- Source/cmGlobalVisualStudio7Generator.cxx | 23 +- Source/cmGlobalVisualStudio8Generator.cxx | 8 +- Source/cmGlobalVisualStudio9Generator.cxx | 11 +- Source/cmGlobalVisualStudioGenerator.cxx | 29 +- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 134 ++++----- Source/cmLocalVisualStudio7Generator.cxx | 38 +-- Source/cmVSSetupHelper.cxx | 11 +- Source/cmVisualStudio10TargetGenerator.cxx | 340 ++++++++++++---------- Source/cmVisualStudioGeneratorOptions.cxx | 2 +- Source/cmVisualStudioSlnData.cxx | 4 +- Source/cmVisualStudioSlnParser.cxx | 6 +- Source/cmVisualStudioWCEPlatformParser.cxx | 9 +- 20 files changed, 582 insertions(+), 535 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 3a116db..e9138ee 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -55,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); @@ -113,7 +113,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, } if (!cmHasSuffix(sourceFile, this->CPackTopLevel)) { - command << " " << QuotePath("-I" + this->CPackTopLevel); + command << " " << QuotePath(cmStrCat("-I", this->CPackTopLevel)); } AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command); @@ -198,7 +198,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()) { @@ -295,7 +296,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() usedBaseNames.insert(uniqueBaseName); std::string objectFilename = - this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj"; + cmStrCat(this->CPackTopLevel, "/", uniqueBaseName, ".wixobj"); if (!RunCandleCommand(CMakeToWixPath(sourceFilename), CMakeToWixPath(objectFilename))) { @@ -334,7 +335,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, @@ -358,7 +360,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, @@ -407,7 +410,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, @@ -446,7 +450,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); @@ -468,7 +472,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); @@ -479,7 +484,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() fileDefinitions.BeginElement("Fragment"); std::string featureDefinitionsFilename = - this->CPackTopLevel + "/features.wxs"; + cmStrCat(this->CPackTopLevel, "/features.wxs"); this->WixSources.push_back(featureDefinitionsFilename); @@ -538,7 +543,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, @@ -638,7 +643,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, @@ -796,7 +801,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( std::string componentId = "CM_SHORTCUT"; if (idPrefix.size()) { - componentId += "_" + idPrefix; + componentId += cmStrCat("_", idPrefix); } componentId += idSuffix; @@ -812,7 +817,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); @@ -821,8 +826,8 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( cmValue cpackWixProgramMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != "."_s) { - fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" + - idSuffix); + fileDefinitions.EmitRemoveFolder( + cmStrCat("CM_REMOVE_PROGRAM_MENU_FOLDER", idSuffix)); } } @@ -929,7 +934,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( continue; } - std::string fullPath = topdir + "/" + fileName; + std::string fullPath = cmStrCat(topdir, "/", fileName); std::string relativePath = cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str()); @@ -937,7 +942,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( std::string id = PathToId(relativePath); if (cmSystemTools::FileIsDirectory(fullPath.c_str())) { - std::string subDirectoryId = std::string("CM_D") + id; + std::string subDirectoryId = cmStrCat("CM_D", id); directoryDefinitions.BeginElement("Directory"); directoryDefinitions.AddAttribute("Id", subDirectoryId); @@ -967,7 +972,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; @@ -1036,7 +1041,7 @@ std::string cmCPackWIXGenerator::GenerateGUID() std::string cmCPackWIXGenerator::QuotePath(std::string const& path) { - return std::string("\"") + path + '"'; + return cmStrCat("\"", path, '"'); } std::string cmCPackWIXGenerator::GetRightmostExtension( @@ -1225,6 +1230,7 @@ std::string cmCPackWIXGenerator::RelativePathWithoutComponentPrefix( void cmCPackWIXGenerator::InjectXmlNamespaces(cmWIXSourceWriter& sourceWriter) { for (auto& ns : this->CustomXmlNamespaces) { - sourceWriter.AddAttributeUnlessEmpty("xmlns:" + ns.first, ns.second); + sourceWriter.AddAttributeUnlessEmpty(cmStrCat("xmlns:", ns.first), + ns.second); } } diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 2261a66..5dcd086 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -118,9 +118,8 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry, std::string const& name) { if (!this->IsBooleanAttribute(name)) { - std::ostringstream message; - message << "Unknown boolean attribute '" << name << "'"; - this->ReportError(entry, message.str()); + this->ReportError(entry, + cmStrCat("Unknown boolean attribute '", name, "'")); } this->SourceWriter.AddAttribute(name, "yes"); diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx index a7a0648..3246e98 100644 --- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXFeaturesSourceWriter.h" +#include "cmStringAlgorithms.h" + cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter( cmCPackLog* logger, std::string const& filename, GuidType componentGuidType) : cmWIXSourceWriter(logger, filename, componentGuidType) @@ -17,7 +19,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry( AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY")); std::string registryKey = - std::string("Software\\Kitware\\CMake\\Packages\\") + package; + cmStrCat("Software\\Kitware\\CMake\\Packages\\", package); BeginElement("RegistryValue"); AddAttribute("Root", "HKLM"); @@ -35,7 +37,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( cmCPackComponentGroup const& group, cmWIXPatch& patch) { BeginElement("Feature"); - AddAttribute("Id", "CM_G_" + group.Name); + AddAttribute("Id", cmStrCat("CM_G_", group.Name)); if (group.IsExpandedByDefault) { AddAttribute("Display", "expand"); @@ -44,7 +46,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( AddAttributeUnlessEmpty("Title", group.DisplayName); AddAttributeUnlessEmpty("Description", group.Description); - patch.ApplyFragment("CM_G_" + group.Name, *this); + patch.ApplyFragment(cmStrCat("CM_G_", group.Name), *this); for (cmCPackComponentGroup* subgroup : group.Subgroups) { EmitFeatureForComponentGroup(*subgroup, patch); @@ -61,7 +63,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent( cmCPackComponent const& component, cmWIXPatch& patch) { BeginElement("Feature"); - AddAttribute("Id", "CM_C_" + component.Name); + AddAttribute("Id", cmStrCat("CM_C_", component.Name)); AddAttributeUnlessEmpty("Title", component.DisplayName); AddAttributeUnlessEmpty("Description", component.Description); @@ -78,7 +80,7 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent( AddAttribute("Level", "2"); } - patch.ApplyFragment("CM_C_" + component.Name, *this); + patch.ApplyFragment(cmStrCat("CM_C_", component.Name), *this); EndElement("Feature"); } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8befa75..9a8e64d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -84,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; } @@ -106,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; } @@ -126,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)) { @@ -141,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 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()) { @@ -169,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(); @@ -195,25 +198,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( 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(); @@ -233,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(); @@ -320,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; } } @@ -436,11 +438,10 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) } } 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") == @@ -467,11 +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; } @@ -489,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; } @@ -611,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")) { @@ -851,7 +852,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) 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. { @@ -865,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; } @@ -874,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); @@ -893,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()); } @@ -976,8 +977,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) 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.push_back(cmStrCat("/p:VisualStudioVersion=", this->GetIDEVersion())); std::string out; int ret = 0; cmsys::RegularExpression regex("\n *VCTargetsPath=([^%\r\n]+)[\r\n]"); @@ -1108,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. diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 84fa378..0ec5e8b 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -3,7 +3,6 @@ #include "cmGlobalVisualStudio11Generator.h" #include -#include #include #include @@ -38,17 +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; @@ -57,17 +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; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 3c15bd8..6c72c5d 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -65,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\"." }; } @@ -80,8 +80,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(vs12generatorName + std::string(" ARM")); - names.push_back(vs12generatorName + std::string(" Win64")); + names.push_back(cmStrCat(vs12generatorName, " ARM")); + names.push_back(cmStrCat(vs12generatorName, " Win64")); return names; } @@ -151,19 +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; @@ -172,19 +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; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 7cb5a66..d6a11df 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -67,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\"." }; } @@ -82,8 +82,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(vs14generatorName + std::string(" ARM")); - names.push_back(vs14generatorName + std::string(" Win64")); + names.push_back(cmStrCat(vs14generatorName, " ARM")); + names.push_back(cmStrCat(vs14generatorName, " Win64")); return names; } @@ -173,20 +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; @@ -252,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); @@ -335,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 @@ -402,7 +404,7 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( std::vector sdks; // Grab the paths of the different SDKs that are installed for (std::string const& i : win10Roots) { - std::string path = i + "/Include/*"; + std::string path = cmStrCat(i, "/Include/*"); cmSystemTools::GlobDirs(path, sdks); } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 01f4803..98176b0 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -209,8 +209,8 @@ 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(); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 67e0a29..80a7be8 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -158,7 +158,7 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() std::string vskey; // Search in standard location. - vskey = this->GetRegistryBase() + ";InstallDir"; + vskey = cmStrCat(this->GetRegistryBase(), ";InstallDir"); if (cmSystemTools::ReadRegistryValue(vskey, vscmd, cmSystemTools::KeyWOW64_32)) { cmSystemTools::ConvertToUnixSlashes(vscmd); @@ -259,7 +259,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand( 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"); @@ -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 propKeys = @@ -680,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; @@ -705,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); } } @@ -728,7 +727,7 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( // check if target 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__TO_DEFAULT_BUILD properties for (std::string const& i : configs) { cmValue propertyValue = diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index acb20d1..a2a7cb1 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -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])); } } @@ -409,8 +409,8 @@ 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(); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index e396405..462db2a 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -9,6 +9,7 @@ #include "cmGlobalGenerator.h" #include "cmGlobalGeneratorFactory.h" #include "cmGlobalVisualStudioGenerator.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVisualStudioWCEPlatformParser.h" @@ -63,7 +64,7 @@ public: cmDocumentationEntry GetDocumentation() const override { - return { std::string(vs9generatorName) + " [arch]", + return { cmStrCat(vs9generatorName, " [arch]"), "Deprecated. Generates Visual Studio 2008 project files. " "Optional [arch] can be \"Win64\" or \"IA64\"." }; } @@ -78,14 +79,14 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(vs9generatorName + std::string(" Win64")); - names.push_back(vs9generatorName + std::string(" IA64")); + names.push_back(cmStrCat(vs9generatorName, " Win64")); + names.push_back(cmStrCat(vs9generatorName, " IA64")); cmVisualStudioWCEPlatformParser parser; parser.ParseVersion("9.0"); const std::vector& availablePlatforms = parser.GetAvailablePlatforms(); for (std::string const& i : availablePlatforms) { - names.push_back("Visual Studio 9 2008 " + i); + names.push_back(cmStrCat("Visual Studio 9 2008 ", i)); } return names; } @@ -144,7 +145,7 @@ std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory() cmSystemTools::ConvertToUnixSlashes(base); // 9.0 macros folder: - path = base + "/VSMacros80"; + path = cmStrCat(base, "/VSMacros80"); // *NOT* a typo; right now in Visual Studio 2008 beta the macros // folder is VSMacros80... They may change it to 90 before final // release of 2008 or they may not... we'll have to keep our eyes diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index ad93b6c..be5b79f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -185,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() @@ -275,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. @@ -310,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( @@ -519,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 @@ -547,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(), @@ -639,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(), @@ -685,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(), @@ -906,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; } @@ -920,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 externalObjectSources; @@ -976,7 +977,7 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir, const std::string& projectName, bool dryRun) { - std::string sln = bindir + "/" + projectName + ".sln"; + std::string sln = cmStrCat(bindir, "/", projectName, ".sln"); if (dryRun) { return cmSystemTools::FileExists(sln, true); diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 44019f6..8b408a9 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -211,7 +211,7 @@ static const char* cmVS15GenName(const std::string& name, std::string& genName) if (cmHasLiteralPrefix(p, " 2017")) { p += 5; } - genName = std::string(vs15generatorName) + p; + genName = cmStrCat(vs15generatorName, p); return p; } @@ -250,7 +250,7 @@ public: cmDocumentationEntry GetDocumentation() const override { - return { std::string(vs15generatorName) + " [arch]", + return { cmStrCat(vs15generatorName, " [arch]"), "Generates Visual Studio 2017 project files. " "Optional [arch] can be \"Win64\" or \"ARM\"." }; } @@ -265,8 +265,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(vs15generatorName + std::string(" ARM")); - names.push_back(vs15generatorName + std::string(" Win64")); + names.push_back(cmStrCat(vs15generatorName, " ARM")); + names.push_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; } @@ -526,18 +526,19 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance( cmsys::RegularExpression versionRegex( 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; } } @@ -956,8 +956,8 @@ bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" "Windows Kits\\Installed Roots;KitsRoot81", win81Root, cmSystemTools::KeyWOW64_32)) { - return cmSystemTools::FileExists(win81Root + "/include/um/windows.h", - true); + return cmSystemTools::FileExists( + cmStrCat(win81Root, "/include/um/windows.h"), true); } return false; } @@ -990,29 +990,29 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand() if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17) { if (VSIsArm64Host()) { if (VSHasDotNETFrameworkArm64()) { - msbuild = vs + "/MSBuild/Current/Bin/arm64/MSBuild.exe"; + msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/arm64/MSBuild.exe"); if (cmSystemTools::FileExists(msbuild)) { return msbuild; } } if (VSIsWindows11OrGreater()) { - msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe"; + msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/amd64/MSBuild.exe"); if (cmSystemTools::FileExists(msbuild)) { return msbuild; } } } else { - msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe"; + msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/amd64/MSBuild.exe"); if (cmSystemTools::FileExists(msbuild)) { return msbuild; } } } - msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe"; + msbuild = cmStrCat(vs, "/MSBuild/Current/Bin/MSBuild.exe"); if (cmSystemTools::FileExists(msbuild)) { return msbuild; } - msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe"; + msbuild = cmStrCat(vs, "/MSBuild/15.0/Bin/MSBuild.exe"); if (cmSystemTools::FileExists(msbuild)) { return msbuild; } @@ -1029,7 +1029,7 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindDevEnvCommand() // Ask Visual Studio Installer tool. std::string vs; if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { - devenv = vs + "/Common7/IDE/devenv.com"; + devenv = cmStrCat(vs, "/Common7/IDE/devenv.com"); if (cmSystemTools::FileExists(devenv)) { return devenv; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 24ef5c2..eaa2c2c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -283,7 +283,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() file->ResolveFullPath(); return file; } - cmSystemTools::Error("Error adding rule for " + makefileIn); + cmSystemTools::Error(cmStrCat("Error adding rule for ", makefileIn)); return nullptr; } @@ -673,8 +673,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( : target->GetLinkerLanguage(configName)); if (linkLanguage.empty()) { cmSystemTools::Error( - "CMake can not determine linker language for target: " + - target->GetName()); + cmStrCat("CMake can not determine linker language for target: ", + target->GetName())); return; } langForClCompile = linkLanguage; @@ -961,7 +961,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags( { std::string configTypeUpper = cmSystemTools::UpperCase(configName); std::string extraLinkOptionsBuildTypeDef = - rootLinkerFlags + "_" + configTypeUpper; + cmStrCat(rootLinkerFlags, "_", configTypeUpper); const std::string& extraLinkOptionsBuildType = this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef); @@ -978,19 +978,19 @@ 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"); @@ -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\tConvertToXMLOutputPath(dir + "/$(ConfigurationName)") << "," - << this->ConvertToXMLOutputPath(dir); + << this->ConvertToXMLOutputPath( + cmStrCat(dir, "/$(ConfigurationName)")) + << "," << this->ConvertToXMLOutputPath(dir); comma = ","; } } @@ -1550,11 +1552,11 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( switch (cmOutputConverter::GetFortranFormat( sf.GetSafeProperty("Fortran_FORMAT"))) { case cmOutputConverter::FortranFormatFixed: - fc.CompileFlags = "-fixed " + fc.CompileFlags; + fc.CompileFlags = cmStrCat("-fixed ", fc.CompileFlags); needfc = true; break; case cmOutputConverter::FortranFormatFree: - fc.CompileFlags = "-free " + fc.CompileFlags; + fc.CompileFlags = cmStrCat("-free ", fc.CompileFlags); needfc = true; break; default: diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 6702b7b..ccf24a0 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -63,15 +63,16 @@ const WCHAR* ComponentType = L"Component"; bool LoadVSInstanceVCToolsetVersion(VSInstanceInfo& vsInstanceInfo) { std::string const vcRoot = vsInstanceInfo.GetInstallLocation(); - std::string vcToolsVersionFile = - vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"; + std::string vcToolsVersionFile = cmStrCat( + vcRoot, "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"); std::string vcToolsVersion; cmsys::ifstream fin(vcToolsVersionFile.c_str()); if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) { return false; } vcToolsVersion = cmTrimWhitespace(vcToolsVersion); - std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion; + std::string const vcToolsDir = + cmStrCat(vcRoot, "/VC/Tools/MSVC/", vcToolsVersion); if (!cmSystemTools::FileIsDirectory(vcToolsDir)) { return false; } @@ -434,14 +435,14 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() std::string envVSCommonToolsDir; std::string envVSCommonToolsDirEnvName = - "VS" + std::to_string(this->Version) + "0COMNTOOLS"; + cmStrCat("VS", std::to_string(this->Version), "0COMNTOOLS"); if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName.c_str(), envVSCommonToolsDir)) { cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir); } - std::string const wantVersion = std::to_string(this->Version) + '.'; + std::string const wantVersion = cmStrCat(std::to_string(this->Version), '.'); bool specifiedLocationNotSpecifiedVersion = false; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ddb08ba..b4c55b3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -291,8 +291,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->TargetCompileAsWinRT = false; this->IsMissingFiles = false; this->DefaultArtifactDir = - this->LocalGenerator->GetCurrentBinaryDirectory() + "/" + - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); + cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), "/", + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget)); this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() == this->Makefile->GetCurrentBinaryDirectory()); this->ClassifyAllConfigSources(); @@ -377,10 +377,10 @@ void cmVisualStudio10TargetGenerator::Generate() if (this->ProjectType == VsProjectType::csproj && this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { - std::string message = "The C# target \"" + - this->GeneratorTarget->GetName() + - "\" is of type STATIC_LIBRARY. This is discouraged (and may be " - "disabled in future). Make it a SHARED library instead."; + std::string message = + cmStrCat("The C# target \"", this->GeneratorTarget->GetName(), + "\" is of type STATIC_LIBRARY. This is discouraged (and may be " + "disabled in future). Make it a SHARED library instead."); this->Makefile->IssueMessage(MessageType::DEPRECATION_WARNING, message); } @@ -624,8 +624,10 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( .empty()) { e1.Element( "CudaToolkitCustomDir", - this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() + - this->GlobalGenerator->GetPlatformToolsetCudaNvccSubdirString()); + cmStrCat( + this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(), + this->GlobalGenerator + ->GetPlatformToolsetCudaNvccSubdirString())); } } @@ -729,15 +731,15 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(); std::string cudaPath = customDir.empty() ? "$(VCTargetsPath)\\BuildCustomizations\\" - : customDir + - this->GlobalGenerator - ->GetPlatformToolsetCudaVSIntegrationSubdirString() + - R"(extras\visual_studio_integration\MSBuildExtensions\)"; + : cmStrCat(customDir, + this->GlobalGenerator + ->GetPlatformToolsetCudaVSIntegrationSubdirString(), + R"(extras\visual_studio_integration\MSBuildExtensions\)"); Elem(e1, "Import") .Attribute("Project", - std::move(cudaPath) + "CUDA " + - this->GlobalGenerator->GetPlatformToolsetCuda() + - ".props"); + cmStrCat(std::move(cudaPath), "CUDA ", + this->GlobalGenerator->GetPlatformToolsetCuda(), + ".props")); } if (this->GlobalGenerator->IsMarmasmEnabled()) { Elem(e1, "Import") @@ -783,7 +785,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( ConvertToWindowsSlash(props); Elem(e1, "Import") .Attribute("Project", props) - .Attribute("Condition", "exists('" + props + "')") + .Attribute("Condition", cmStrCat("exists('", props, "')")) .Attribute("Label", "LocalAppDataPlatform"); } @@ -833,15 +835,15 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(); std::string cudaPath = customDir.empty() ? "$(VCTargetsPath)\\BuildCustomizations\\" - : customDir + - this->GlobalGenerator - ->GetPlatformToolsetCudaVSIntegrationSubdirString() + - R"(extras\visual_studio_integration\MSBuildExtensions\)"; + : cmStrCat(customDir, + this->GlobalGenerator + ->GetPlatformToolsetCudaVSIntegrationSubdirString(), + R"(extras\visual_studio_integration\MSBuildExtensions\)"); Elem(e1, "Import") .Attribute("Project", - std::move(cudaPath) + "CUDA " + - this->GlobalGenerator->GetPlatformToolsetCuda() + - ".targets"); + cmStrCat(std::move(cudaPath), "CUDA ", + this->GlobalGenerator->GetPlatformToolsetCuda(), + ".targets")); } if (this->GlobalGenerator->IsMarmasmEnabled()) { Elem(e1, "Import") @@ -868,7 +870,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( if (this->ProjectType == VsProjectType::csproj) { for (std::string const& c : this->Configurations) { Elem e1(e0, "PropertyGroup"); - e1.Attribute("Condition", "'$(Configuration)' == '" + c + "'"); + e1.Attribute("Condition", cmStrCat("'$(Configuration)' == '", c, "'")); e1.SetHasElements(); this->WriteEvents(e1, c); } @@ -893,17 +895,19 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( { if (this->ProjectType != VsProjectType::csproj || !this->GeneratorTarget->IsDotNetSdkTarget()) { - std::string message = "The target \"" + this->GeneratorTarget->GetName() + - "\" is not eligible for .Net SDK style project."; + std::string message = + cmStrCat("The target \"", this->GeneratorTarget->GetName(), + "\" is not eligible for .Net SDK style project."); this->Makefile->IssueMessage(MessageType::INTERNAL_ERROR, message); return; } if (this->HasCustomCommands()) { - std::string message = "The target \"" + this->GeneratorTarget->GetName() + + std::string message = cmStrCat( + "The target \"", this->GeneratorTarget->GetName(), "\" does not currently support add_custom_command as the Visual Studio " "generators have not yet learned how to generate custom commands in " - ".Net SDK-style projects."; + ".Net SDK-style projects."); this->Makefile->IssueMessage(MessageType::FATAL_ERROR, message); return; } @@ -986,11 +990,13 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( for (const std::string& config : this->Configurations) { Elem e1(e0, "PropertyGroup"); - e1.Attribute("Condition", "'$(Configuration)' == '" + config + "'"); + e1.Attribute("Condition", + cmStrCat("'$(Configuration)' == '", config, "'")); e1.SetHasElements(); this->WriteEvents(e1, config); - std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; + std::string outDir = + cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); ConvertToWindowsSlash(outDir); e1.Element("OutputPath", outDir); @@ -1011,7 +1017,7 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) { e1.Attribute("Label", "Globals"); - e1.Element("ProjectGuid", "{" + this->GUID + "}"); + e1.Element("ProjectGuid", cmStrCat("{", this->GUID, "}")); cmValue vsProjectTypes = this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES"); @@ -1107,7 +1113,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) if (cmHasPrefix(i.first, vsDnRef)) { std::string path = i.second; if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; + path = + cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path); } ConvertToWindowsSlash(path); this->DotNetHintReferences[""].emplace_back( @@ -1176,7 +1183,8 @@ void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0) cmList argsSplit{ *imports }; for (auto& path : argsSplit) { if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; + path = + cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path); } ConvertToWindowsSlash(path); Elem e1(e0, "Import"); @@ -1191,7 +1199,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_"; static const std::string refpropInfix = "_TAG_"; - const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix; + const std::string refPropFullPrefix = + cmStrCat(refpropPrefix, ref, refpropInfix); using CustomTags = std::map; CustomTags tags; cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); @@ -1243,7 +1252,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) e2.Attribute("Include", obj); if (this->ProjectType != VsProjectType::csproj) { - std::string hFileName = obj.substr(0, obj.find_last_of('.')) + ".h"; + std::string hFileName = + cmStrCat(obj.substr(0, obj.find_last_of('.')), ".h"); e2.Element("DependentUpon", hFileName); for (std::string const& c : this->Configurations) { @@ -1269,10 +1279,10 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) e2.Element("Link", link); } // Determine if this is a generated resource from a .Designer.cs file - std::string designerResource = - cmSystemTools::GetFilenamePath(oi->GetFullPath()) + "/" + - cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()) + - ".Designer.cs"; + std::string designerResource = cmStrCat( + cmSystemTools::GetFilenamePath(oi->GetFullPath()), "/", + cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()), + ".Designer.cs"); if (cmsys::SystemTools::FileExists(designerResource)) { std::string generator = "PublicResXFileCodeGenerator"; if (cmValue g = oi->GetProperty("VS_RESOURCE_GENERATOR")) { @@ -1400,7 +1410,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0) e1.Attribute("Label", "ProjectConfigurations"); for (std::string const& c : this->Configurations) { Elem e2(e1, "ProjectConfiguration"); - e2.Attribute("Include", c + "|" + this->Platform); + e2.Attribute("Include", cmStrCat(c, "|", this->Platform)); e2.Element("Configuration", c); e2.Element("Platform", this->Platform); } @@ -1576,7 +1586,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( e1.Element("DefineDebug", "true"); } - std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; + std::string outDir = + cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); ConvertToWindowsSlash(outDir); e1.Element("OutputPath", outDir); @@ -1603,7 +1614,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( if (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType()) { e1.Element("StartAction", "Program"); - e1.Element("StartProgram", outDir + assemblyName + ".exe"); + e1.Element("StartProgram", cmStrCat(outDir, assemblyName, ".exe")); } OptionsHelper oh(o, e1); @@ -1618,10 +1629,10 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues( const char* toolset = gg->GetPlatformToolset(); e1.Element("NdkToolchainVersion", toolset ? toolset : "Default"); if (cmValue minApi = this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) { - e1.Element("AndroidMinAPI", "android-" + *minApi); + e1.Element("AndroidMinAPI", cmStrCat("android-", *minApi)); } if (cmValue api = this->GeneratorTarget->GetProperty("ANDROID_API")) { - e1.Element("AndroidTargetAPI", "android-" + *api); + e1.Element("AndroidTargetAPI", cmStrCat("android-", *api)); } if (cmValue cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH")) { @@ -1724,9 +1735,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( // preventing dependent rebuilds. this->ForceOld(sourcePath); } else { - std::string error = - cmStrCat("Could not create file: [", sourcePath, "] "); - cmSystemTools::Error(error + cmSystemTools::GetLastSystemError()); + cmSystemTools::Error(cmStrCat("Could not create file: [", sourcePath, + "] ", + cmSystemTools::GetLastSystemError())); } } } @@ -1811,8 +1822,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } script += lg->FinishConstructScript(this->ProjectType); if (this->ProjectType == VsProjectType::csproj) { - std::string name = "CustomCommand_" + c + "_" + - cmSystemTools::ComputeStringMD5(sourcePath); + std::string name = cmStrCat("CustomCommand_", c, "_", + cmSystemTools::ComputeStringMD5(sourcePath)); this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(), outputs.str(), comment, ccg); } else { @@ -1883,7 +1894,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp( e1.S << "\n Inputs=\"" << cmVS10EscapeAttr(inputs) << "\""; e1.S << "\n Outputs=\"" << cmVS10EscapeAttr(outputs) << "\""; if (!comment.empty()) { - Elem(e1, "Exec").Attribute("Command", "echo " + comment); + Elem(e1, "Exec").Attribute("Command", cmStrCat("echo ", comment)); } Elem(e1, "Exec").Attribute("Command", script); } @@ -2014,11 +2025,11 @@ void cmVisualStudio10TargetGenerator::WriteGroups() for (cmSourceGroup const* sg : groupsVec) { std::string const& name = sg->GetFullName(); if (!name.empty()) { - std::string guidName = "SG_Filter_" + name; + std::string guidName = cmStrCat("SG_Filter_", name); std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", name); - e2.Element("UniqueIdentifier", "{" + guid + "}"); + e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); } } @@ -2027,7 +2038,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", "Resource Files"); - e2.Element("UniqueIdentifier", "{" + guid + "}"); + e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); e2.Element("Extensions", "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;" "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms"); @@ -2041,7 +2052,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", filter); - e2.Element("UniqueIdentifier", "{" + guid + "}"); + e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); } } } @@ -2376,7 +2387,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( if (ParsedToolTargetSettings.find(tool) == ParsedToolTargetSettings.end()) { cmValue toolTargetProperty = this->GeneratorTarget->Target->GetProperty( - "VS_SOURCE_SETTINGS_" + std::string(tool)); + cmStrCat("VS_SOURCE_SETTINGS_", tool)); ConfigToSettings toolTargetSettings; if (toolTargetProperty) { ParseSettingsProperty(*toolTargetProperty, toolTargetSettings); @@ -2408,19 +2419,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( ge.Parse(deployContent); // Deployment location cannot be set on a configuration basis if (!deployLocation.empty()) { - e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)"); + e2.Element("Link", + cmStrCat(deployLocation, "\\%(FileName)%(Extension)")); } for (auto& config : this->Configurations) { if (cge->Evaluate(this->LocalGenerator, config) == "1"_s) { - e2.WritePlatformConfigTag("DeploymentContent", - "'$(Configuration)|$(Platform)'=='" + - config + "|" + this->Platform + "'", - "true"); + e2.WritePlatformConfigTag( + "DeploymentContent", + cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|", + this->Platform, "'"), + "true"); } else { - e2.WritePlatformConfigTag("ExcludedFromBuild", - "'$(Configuration)|$(Platform)'=='" + - config + "|" + this->Platform + "'", - "true"); + e2.WritePlatformConfigTag( + "ExcludedFromBuild", + cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|", + this->Platform, "'"), + "true"); } } } @@ -2601,8 +2615,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) if (firstConditionSet) { conditions << " Or "; } - conditions << "('$(Configuration)|$(Platform)'=='" + - this->Configurations[ci] + "|" + this->Platform + "')"; + conditions << "('$(Configuration)|$(Platform)'=='" + << this->Configurations[ci] << "|" << this->Platform + << "')"; firstConditionSet = true; } e2.Attribute("Condition", conditions.str()); @@ -2682,9 +2697,9 @@ void cmVisualStudio10TargetGenerator::FinishWritingSource( writtenSettings.push_back(setting.first); } else { e2.WritePlatformConfigTag(setting.first, - "'$(Configuration)|$(Platform)'=='" + - configSettings.first + "|" + - this->Platform + "'", + cmStrCat("'$(Configuration)|$(Platform)'=='", + configSettings.first, "|", + this->Platform, "'"), setting.second); } } @@ -2752,9 +2767,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( // produced here. if (!objectName.empty()) { if (lang == "CUDA"_s) { - e2.Element("CompileOut", "$(IntDir)/" + objectName); + e2.Element("CompileOut", cmStrCat("$(IntDir)/", objectName)); } else { - e2.Element("ObjectFileName", "$(IntDir)/" + objectName); + e2.Element("ObjectFileName", cmStrCat("$(IntDir)/", objectName)); } } @@ -2981,9 +2996,9 @@ void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild( { for (size_t ci : exclude_configs) { e2.WritePlatformConfigTag("ExcludedFromBuild", - "'$(Configuration)|$(Platform)'=='" + - this->Configurations[ci] + "|" + - this->Platform + "'", + cmStrCat("'$(Configuration)|$(Platform)'=='", + this->Configurations[ci], "|", + this->Platform, "'"), "true"); } } @@ -3017,7 +3032,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( outDir = intermediateDir; targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib"); } else { - outDir = this->GeneratorTarget->GetDirectory(config) + "/"; + outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); targetNameFull = this->GeneratorTarget->GetFullName(config); } ConvertToWindowsSlash(intermediateDir); @@ -3202,7 +3217,7 @@ std::string cmVisualStudio10TargetGenerator::GetTargetOutputName() const } const auto& nameComponents = this->GeneratorTarget->GetFullNameComponents(config); - return nameComponents.prefix + nameComponents.base; + return cmStrCat(nameComponents.prefix, nameComponents.base); } bool cmVisualStudio10TargetGenerator::ComputeClOptions() @@ -3240,8 +3255,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(configName); if (linkLanguage.empty()) { - cmSystemTools::Error( - "CMake can not determine linker language for target: " + this->Name); + cmSystemTools::Error(cmStrCat( + "CMake can not determine linker language for target: ", this->Name)); return false; } @@ -3333,11 +3348,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( defineFlags.find("/clr") != std::string::npos || defineFlags.find("-clr") != std::string::npos) { if (configName == this->Configurations[0]) { - std::string message = "For the target \"" + - this->GeneratorTarget->GetName() + - "\" the /clr compiler flag was added manually. " + - "Set usage of C++/CLI by setting COMMON_LANGUAGE_RUNTIME " - "target property."; + std::string message = + cmStrCat("For the target \"", this->GeneratorTarget->GetName(), + "\" the /clr compiler flag was added manually. ", + "Set usage of C++/CLI by setting COMMON_LANGUAGE_RUNTIME " + "target property."); this->Makefile->IssueMessage(MessageType::WARNING, message); } } @@ -3345,9 +3360,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) { std::string clrString = *clr; if (!clrString.empty()) { - clrString = ":" + clrString; + clrString = cmStrCat(":", clrString); } - flags += " /clr" + clrString; + flags += cmStrCat(" /clr", clrString); } } @@ -3594,9 +3609,10 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions( Options& rcOptions = *pOptions; std::string CONFIG = cmSystemTools::UpperCase(configName); - std::string rcConfigFlagsVar = "CMAKE_RC_FLAGS_" + CONFIG; - std::string flags = this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS") + - " " + this->Makefile->GetSafeDefinition(rcConfigFlagsVar); + std::string rcConfigFlagsVar = cmStrCat("CMAKE_RC_FLAGS_", CONFIG); + std::string flags = + cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), " ", + this->Makefile->GetSafeDefinition(rcConfigFlagsVar)); rcOptions.Parse(flags); @@ -3737,7 +3753,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( // limitation by creating the directory and passing the flag ourselves. pdb = this->ConvertPath(pdb, true); ConvertToWindowsSlash(pdb); - std::string const clFd = R"(-Xcompiler="-Fd\")" + pdb + R"(\"")"; + std::string const clFd = cmStrCat(R"(-Xcompiler="-Fd\")", pdb, R"(\"")"); cudaOptions.AppendFlagString("AdditionalOptions", clFd); } } @@ -3762,7 +3778,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.RemoveFlag("AdditionalCompilerOptions"); if (!aco.empty()) { aco = this->LocalGenerator->EscapeForShell(aco, false); - cudaOptions.AppendFlagString("AdditionalOptions", "-Xcompiler=" + aco); + cudaOptions.AppendFlagString("AdditionalOptions", + cmStrCat("-Xcompiler=", aco)); } } @@ -4143,7 +4160,8 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions( } else if (cmIsOff(*dpiAware)) { e2.Element("EnableDpiAwareness", "false"); } else { - cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " + *dpiAware); + cmSystemTools::Error( + cmStrCat("Bad parameter for VS_DPI_AWARE: ", *dpiAware)); } } } @@ -4231,7 +4249,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } { - std::string manifest_xml = rootDir + "/AndroidManifest.xml"; + std::string manifest_xml = cmStrCat(rootDir, "/AndroidManifest.xml"); ConvertToWindowsSlash(manifest_xml); e2.Element("AndroidManifestLocation", manifest_xml); } @@ -4239,7 +4257,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( if (cmValue antAdditionalOptions = this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) { e2.Element("AdditionalOptions", - *antAdditionalOptions + " %(AdditionalOptions)"); + cmStrCat(*antAdditionalOptions, " %(AdditionalOptions)")); } } @@ -4270,8 +4288,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( const std::string& linkLanguage = linkClosure->LinkerLanguage; if (linkLanguage.empty()) { - cmSystemTools::Error( - "CMake can not determine linker language for target: " + this->Name); + cmSystemTools::Error(cmStrCat( + "CMake can not determine linker language for target: ", this->Name)); return false; } @@ -4288,7 +4306,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS"); flags += " "; flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase); - std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG; + std::string linkFlagVar = cmStrCat(linkFlagVarBase, "_", CONFIG); flags += " "; flags += this->Makefile->GetRequiredDefinition(linkFlagVar); cmValue targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS"); @@ -4311,8 +4329,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( - "CMake can not compute cmComputeLinkInformation for target: " + - this->Name); + cmStrCat("CMake can not compute cmComputeLinkInformation for target: ", + this->Name)); return false; } cmComputeLinkInformation& cli = *pcli; @@ -4337,7 +4355,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( // first just full path linkDirs.push_back(d); // next path with configuration type Debug, Release, etc - linkDirs.push_back(d + "/$(Configuration)"); + linkDirs.push_back(cmStrCat(d, "/$(Configuration)")); } linkDirs.push_back("%(AdditionalLibraryDirectories)"); linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs); @@ -4476,8 +4494,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( this->GeneratorTarget->GetLinkInformation(config); if (!pcli) { cmSystemTools::Error( - "CMake can not compute cmComputeLinkInformation for target: " + - this->Name); + cmStrCat("CMake can not compute cmComputeLinkInformation for target: ", + this->Name)); return false; } @@ -4793,7 +4811,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) ConvertToWindowsSlash(path); Elem e2(e1, "ProjectReference"); e2.Attribute("Include", path); - e2.Element("Project", "{" + this->GlobalGenerator->GetGUID(name) + "}"); + e2.Element("Project", + cmStrCat("{", this->GlobalGenerator->GetGUID(name), "}")); e2.Element("Name", name); this->WriteDotNetReferenceCustomTags(e2, name); if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) { @@ -4832,17 +4851,18 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1) void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( Elem& e1, std::string const& extension, std::string const& version) { - const std::string s = "$([Microsoft.Build.Utilities.ToolLocationHelper]" - "::GetPlatformExtensionSDKLocation(`" + - extension + ", Version=" + version + - "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " - "$(ExtensionSDKDirectoryRoot), null))" - "\\DesignTime\\CommonConfiguration\\Neutral\\" + - extension + ".props"; + const std::string s = + cmStrCat("$([Microsoft.Build.Utilities.ToolLocationHelper]" + "::GetPlatformExtensionSDKLocation(`", + extension, ", Version=", version, + "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " + "$(ExtensionSDKDirectoryRoot), null))" + "\\DesignTime\\CommonConfiguration\\Neutral\\", + extension, ".props"); Elem e2(e1, "Import"); e2.Attribute("Project", s); - e2.Attribute("Condition", "exists('" + s + "')"); + e2.Attribute("Condition", cmStrCat("exists('", s, "')")); } void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) @@ -4893,7 +4913,7 @@ void cmVisualStudio10TargetGenerator::WriteSingleSDKReference( Elem& e1, std::string const& extension, std::string const& version) { Elem(e1, "SDKReference") - .Attribute("Include", extension + ", Version=" + version); + .Attribute("Include", cmStrCat(extension, ", Version=", version)); } void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( @@ -4920,9 +4940,9 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); Elem e1(e0, "PropertyGroup"); - e1.Element("AppxPackageArtifactsDir", artifactDir + "\\"); + e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, "\\")); std::string resourcePriFile = - this->DefaultArtifactDir + "/resources.pri"; + cmStrCat(this->DefaultArtifactDir, "/resources.pri"); ConvertToWindowsSlash(resourcePriFile); e1.Element("ProjectPriFullPath", resourcePriFile); @@ -4930,10 +4950,12 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( // aren't targeting WP8.0, add a default certificate if (pfxFile.empty()) { std::string templateFolder = - cmSystemTools::GetCMakeRoot() + "/Templates/Windows"; - pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx"; - cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx", - pfxFile, false); + cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows"); + pfxFile = + cmStrCat(this->DefaultArtifactDir, "/Windows_TemporaryKey.pfx"); + cmSystemTools::CopyAFile( + cmStrCat(templateFolder, "/Windows_TemporaryKey.pfx"), pfxFile, + false); ConvertToWindowsSlash(pfxFile); this->AddedFiles.push_back(pfxFile); this->AddedDefaultCertificate = true; @@ -4974,7 +4996,8 @@ void cmVisualStudio10TargetGenerator::ClassifyAllConfigSource( // where the user supplied the file name and Visual Studio // appended the suffix. std::string resx = acs.Source->ResolveFullPath(); - std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h"; + std::string hFileName = + cmStrCat(resx.substr(0, resx.find_last_of('.')), ".h"); this->ExpectedResxHeaders.insert(hFileName); } break; case cmGeneratorTarget::SourceKindXaml: { @@ -4984,8 +5007,8 @@ void cmVisualStudio10TargetGenerator::ClassifyAllConfigSource( // where the user supplied the file name and Visual Studio // appended the suffix. std::string xaml = acs.Source->ResolveFullPath(); - std::string hFileName = xaml + ".h"; - std::string cppFileName = xaml + ".cpp"; + std::string hFileName = cmStrCat(xaml, ".h"); + std::string cppFileName = cmStrCat(xaml, ".cpp"); this->ExpectedXamlHeaders.insert(hFileName); this->ExpectedXamlSources.insert(cppFileName); } break; @@ -5053,7 +5076,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1) cmStateEnums::EXECUTABLE) { e1.Element("XapOutputs", "true"); e1.Element("XapFilename", - this->Name + "_$(Configuration)_$(Platform).xap"); + cmStrCat(this->Name, "_$(Configuration)_$(Platform).xap")); } } } else if (isAndroid) { @@ -5158,13 +5181,13 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles(Elem& e1) void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) { std::string templateFolder = - cmSystemTools::GetCMakeRoot() + "/Templates/Windows"; + cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows"); // For WP80, the manifest needs to be in the same folder as the project // this can cause an overwrite problem if projects aren't organized in // folders - std::string manifestFile = - this->LocalGenerator->GetCurrentBinaryDirectory() + "/WMAppManifest.xml"; + std::string manifestFile = cmStrCat( + this->LocalGenerator->GetCurrentBinaryDirectory(), "/WMAppManifest.xml"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -5221,22 +5244,22 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) } this->AddedFiles.push_back(sourceFile); - std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; - cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, - false); + std::string smallLogo = cmStrCat(this->DefaultArtifactDir, "/SmallLogo.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo.png"), + smallLogo, false); ConvertToWindowsSlash(smallLogo); Elem(e1, "Image").Attribute("Include", smallLogo); this->AddedFiles.push_back(smallLogo); - std::string logo = this->DefaultArtifactDir + "/Logo.png"; - cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); + std::string logo = cmStrCat(this->DefaultArtifactDir, "/Logo.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/Logo.png"), logo, false); ConvertToWindowsSlash(logo); Elem(e1, "Image").Attribute("Include", logo); this->AddedFiles.push_back(logo); std::string applicationIcon = - this->DefaultArtifactDir + "/ApplicationIcon.png"; - cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png", + cmStrCat(this->DefaultArtifactDir, "/ApplicationIcon.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/ApplicationIcon.png"), applicationIcon, false); ConvertToWindowsSlash(applicationIcon); Elem(e1, "Image").Attribute("Include", applicationIcon); @@ -5246,7 +5269,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1) { std::string manifestFile = - this->DefaultArtifactDir + "/package.appxManifest"; + cmStrCat(this->DefaultArtifactDir, "/package.appxManifest"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -5308,7 +5331,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1) void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1) { std::string manifestFile = - this->DefaultArtifactDir + "/package.appxManifest"; + cmStrCat(this->DefaultArtifactDir, "/package.appxManifest"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -5362,7 +5385,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1) void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1) { std::string manifestFile = - this->DefaultArtifactDir + "/package.appxManifest"; + cmStrCat(this->DefaultArtifactDir, "/package.appxManifest"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -5421,7 +5444,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1) void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1) { std::string manifestFile = - this->DefaultArtifactDir + "/package.appxManifest"; + cmStrCat(this->DefaultArtifactDir, "/package.appxManifest"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -5482,7 +5505,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( Elem& e1, const std::string& manifestFile) { std::string templateFolder = - cmSystemTools::GetCMakeRoot() + "/Templates/Windows"; + cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/Windows"); std::string sourceFile = this->ConvertPath(manifestFile, false); ConvertToWindowsSlash(sourceFile); @@ -5493,36 +5516,38 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( } this->AddedFiles.push_back(sourceFile); - std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; - cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo, - false); + std::string smallLogo = cmStrCat(this->DefaultArtifactDir, "/SmallLogo.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo.png"), + smallLogo, false); ConvertToWindowsSlash(smallLogo); Elem(e1, "Image").Attribute("Include", smallLogo); this->AddedFiles.push_back(smallLogo); - std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png"; - cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44, - false); + std::string smallLogo44 = + cmStrCat(this->DefaultArtifactDir, "/SmallLogo44x44.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SmallLogo44x44.png"), + smallLogo44, false); ConvertToWindowsSlash(smallLogo44); Elem(e1, "Image").Attribute("Include", smallLogo44); this->AddedFiles.push_back(smallLogo44); - std::string logo = this->DefaultArtifactDir + "/Logo.png"; - cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false); + std::string logo = cmStrCat(this->DefaultArtifactDir, "/Logo.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/Logo.png"), logo, false); ConvertToWindowsSlash(logo); Elem(e1, "Image").Attribute("Include", logo); this->AddedFiles.push_back(logo); - std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png"; - cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo, - false); + std::string storeLogo = cmStrCat(this->DefaultArtifactDir, "/StoreLogo.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/StoreLogo.png"), + storeLogo, false); ConvertToWindowsSlash(storeLogo); Elem(e1, "Image").Attribute("Include", storeLogo); this->AddedFiles.push_back(storeLogo); - std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png"; - cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen, - false); + std::string splashScreen = + cmStrCat(this->DefaultArtifactDir, "/SplashScreen.png"); + cmSystemTools::CopyAFile(cmStrCat(templateFolder, "/SplashScreen.png"), + splashScreen, false); ConvertToWindowsSlash(splashScreen); Elem(e1, "Image").Attribute("Include", splashScreen); this->AddedFiles.push_back(splashScreen); @@ -5530,7 +5555,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( if (this->AddedDefaultCertificate) { // This file has already been added to the build so don't copy it std::string keyFile = - this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx"; + cmStrCat(this->DefaultArtifactDir, "/Windows_TemporaryKey.pfx"); ConvertToWindowsSlash(keyFile); Elem(e1, "None").Attribute("Include", keyFile); } @@ -5605,8 +5630,9 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink( cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(fullFileName, sourceGroups); if (sourceGroup && !sourceGroup->GetFullName().empty()) { - sourceGroupedFile = sourceGroup->GetFullName() + "/" + - cmsys::SystemTools::GetFilenameName(fullFileName); + sourceGroupedFile = + cmStrCat(sourceGroup->GetFullName(), "/", + cmsys::SystemTools::GetFilenameName(fullFileName)); cmsys::SystemTools::ConvertToUnixSlashes(sourceGroupedFile); } @@ -5654,8 +5680,9 @@ void cmVisualStudio10TargetGenerator::UpdateCache() // Store a cache entry that later determines, if a package restore is // required. this->GeneratorTarget->Makefile->AddCacheDefinition( - this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE", "ON", - "Value Computed by CMake", cmStateEnums::STATIC); + cmStrCat(this->GeneratorTarget->GetName(), + "_REQUIRES_VS_PACKAGE_RESTORE"), + "ON", "Value Computed by CMake", cmStateEnums::STATIC); } else { // If there are any dependencies that require package restore, inherit the // cache variable. @@ -5668,7 +5695,8 @@ void cmVisualStudio10TargetGenerator::UpdateCache() for (cmGeneratorTarget const* dt : depends) { if (dt->HasPackageReferences()) { this->GeneratorTarget->Makefile->AddCacheDefinition( - this->GeneratorTarget->GetName() + "_REQUIRES_VS_PACKAGE_RESTORE", + cmStrCat(this->GeneratorTarget->GetName(), + "_REQUIRES_VS_PACKAGE_RESTORE"), "ON", "Value Computed by CMake", cmStateEnums::STATIC); } } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 9bbe34b..80e37bd 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -280,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) diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx index 4b6754e..d824462 100644 --- a/Source/cmVisualStudioSlnData.cxx +++ b/Source/cmVisualStudioSlnData.cxx @@ -5,6 +5,7 @@ #include #include +#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 project = GetProjectByName(projectName); if (!project) { return platformName; diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 76791a6..9b61566 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -83,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; } @@ -103,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; } @@ -546,7 +546,7 @@ bool cmVisualStudioSlnParser::ParseBOM(std::istream& input, std::string& line, return false; } if (!this->LastResult.HadBOM) { - line = bom + line; // it wasn't a BOM, prepend it to first line + line = cmStrCat(bom, line); // it wasn't a BOM, prepend it to first line } return true; } diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index 19c8d35..aa7aae7 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -7,14 +7,15 @@ #include #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) || @@ -28,7 +29,7 @@ int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version) this->VsInstallDir.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 +40,7 @@ std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const return OSMajorVersion; } - return OSMajorVersion + "." + OSMinorVersion; + return cmStrCat(OSMajorVersion, ".", OSMinorVersion); } const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const -- cgit v0.12 From 809248a0c9f3c2c203399d4cefe10a23cfc53add Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:35:46 -0400 Subject: strings: use character literals where possible --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 30 ++++---- Source/CPack/WiX/cmWIXAccessControlList.cxx | 2 +- Source/CPack/WiX/cmWIXPatch.cxx | 6 +- Source/CPack/WiX/cmWIXPatchParser.cxx | 2 +- Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 6 +- Source/CPack/WiX/cmWIXSourceWriter.cxx | 28 +++---- Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 6 +- Source/CPack/cmCPackCygwinSourceGenerator.cxx | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 10 +-- Source/cmGlobalVisualStudio14Generator.cxx | 6 +- Source/cmGlobalVisualStudio71Generator.cxx | 6 +- Source/cmGlobalVisualStudio7Generator.cxx | 8 +- Source/cmGlobalVisualStudio8Generator.cxx | 26 +++---- Source/cmGlobalVisualStudioGenerator.cxx | 6 +- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 16 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 89 ++++++++++++----------- Source/cmVisualStudioGeneratorOptions.cxx | 6 +- Source/cmVisualStudioSlnData.cxx | 2 +- Source/cmVisualStudioWCEPlatformParser.cxx | 2 +- 20 files changed, 133 insertions(+), 132 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index e9138ee..9530120 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -113,12 +113,12 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, } if (!cmHasSuffix(sourceFile, this->CPackTopLevel)) { - command << " " << QuotePath(cmStrCat("-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()); } @@ -147,7 +147,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command); - command << " " << objectFiles; + command << ' ' << objectFiles; return RunWiXCommand(command.str()); } @@ -296,14 +296,14 @@ bool cmCPackWIXGenerator::PackageFilesImpl() usedBaseNames.insert(uniqueBaseName); std::string objectFilename = - cmStrCat(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); @@ -795,13 +795,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( std::string idSuffix; if (!cpackComponentName.empty()) { - idSuffix += "_"; + idSuffix += '_'; idSuffix += cpackComponentName; } std::string componentId = "CM_SHORTCUT"; if (idPrefix.size()) { - componentId += cmStrCat("_", idPrefix); + componentId += cmStrCat('_', idPrefix); } componentId += idSuffix; @@ -817,7 +817,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( this->Patch->ApplyFragment(componentId, fileDefinitions); std::string registryKey = - cmStrCat("Software\\", cpackVendor, "\\", cpackPackageName); + cmStrCat("Software\\", cpackVendor, '\\', cpackPackageName); shortcuts.EmitShortcuts(type, registryKey, cpackComponentName, fileDefinitions); @@ -934,7 +934,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( continue; } - std::string fullPath = cmStrCat(topdir, "/", fileName); + std::string fullPath = cmStrCat(topdir, '/', fileName); std::string relativePath = cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str()); @@ -1041,7 +1041,7 @@ std::string cmCPackWIXGenerator::GenerateGUID() std::string cmCPackWIXGenerator::QuotePath(std::string const& path) { - return cmStrCat("\"", path, '"'); + return cmStrCat('"', path, '"'); } std::string cmCPackWIXGenerator::GetRightmostExtension( @@ -1095,18 +1095,18 @@ 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; + result << '_' << ambiguityCount; } std::string resultString = result.str(); @@ -1190,7 +1190,7 @@ void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName, cmCPackLogger(cmCPackLog::LOG_ERROR, "Invalid element in CPACK_WIX_CUSTOM_XMLNS ignored: " "\"" - << str << "\"" << std::endl); + << str << '"' << std::endl); } } std::ostringstream oss; @@ -1211,7 +1211,7 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName, cmList list{ variableContent }; for (std::string const& i : list) { - stream << " " << QuotePath(i); + stream << ' ' << QuotePath(i); } } diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 5dcd086..6aba228 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -119,7 +119,7 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry, { if (!this->IsBooleanAttribute(name)) { this->ReportError(entry, - cmStrCat("Unknown boolean attribute '", name, "'")); + cmStrCat("Unknown boolean attribute '", name, '\'')); } this->SourceWriter.AddAttribute(name, "yes"); diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 122ffaf..c3ada17 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -14,7 +14,7 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath) cmWIXPatchParser parser(Fragments, Logger); if (!parser.ParseFile(patchFilePath.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Failed parsing XML patch file: '" << patchFilePath << "'" + "Failed parsing XML patch file: '" << patchFilePath << '\'' << std::endl); return false; } @@ -75,9 +75,9 @@ bool cmWIXPatch::CheckForUnappliedFragments() fragmentList += ", "; } - fragmentList += "'"; + fragmentList += '\''; fragmentList += fragment.first; - fragmentList += "'"; + fragmentList += '\''; } if (!fragmentList.empty()) { diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 57539d3..6a44d63 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -143,7 +143,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while processing XML patch file at " - << line << ":" << column << ": " << msg << std::endl); + << line << ':' << column << ": " << msg << std::endl); Valid = false; } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index d7e534a..f3fe3de 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -135,7 +135,7 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix() void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword) { - File << "\\" << keyword; + File << '\\' << keyword; } void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword) @@ -175,12 +175,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-" << int(c) << ']'; ControlWord("cf0 "); } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 8e9bfdf..e13a3e0 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -34,7 +34,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter() cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1 << " WiX elements were still open when closing '" - << SourceFilename << "'" << std::endl); + << SourceFilename << '\'' << std::endl); return; } @@ -44,12 +44,12 @@ cmWIXSourceWriter::~cmWIXSourceWriter() void cmWIXSourceWriter::BeginElement(std::string const& name) { if (State == BEGIN) { - File << ">"; + File << '>'; } - File << "\n"; + File << '\n'; Indent(Elements.size()); - File << "<" << name; + File << '<' << name; Elements.push_back(name); State = BEGIN; @@ -60,7 +60,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name) if (Elements.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "can not end WiX element with no open elements in '" - << SourceFilename << "'" << std::endl); + << SourceFilename << '\'' << std::endl); return; } @@ -68,14 +68,14 @@ void cmWIXSourceWriter::EndElement(std::string const& name) cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <" << Elements.back() << "> can not be closed by in '" << SourceFilename << "'" << std::endl); + << "> in '" << SourceFilename << '\'' << std::endl); return; } if (State == DEFAULT) { - File << "\n"; + File << '\n'; Indent(Elements.size() - 1); - File << ""; + File << "'; } else { File << "/>"; } @@ -87,13 +87,13 @@ 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; } @@ -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 << ""; + File << ""; 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, diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index fabf4c5..fcb79a2 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -44,9 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles() cmGeneratedFileStream ofs(manifestFile); for (std::string const& file : files) { // remove the temp dir and replace with /usr - ofs << file.substr(tempdir.size()) << "\n"; + ofs << file.substr(tempdir.size()) << '\n'; } - ofs << manifest << "\n"; + ofs << manifest << '\n'; } // add the manifest file to the list of all files files.push_back(manifestFile); @@ -60,7 +60,7 @@ const char* cmCPackCygwinBinaryGenerator::GetOutputExtension() this->OutputExtension = "-"; cmValue patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); if (!patchNumber) { - this->OutputExtension += "1"; + this->OutputExtension += '1'; cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER not specified using 1" << std::endl); diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index a5863ff..f025a6c 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -98,7 +98,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" << " not specified, defaulting to 1\n"); - outerTarFile += "1"; + outerTarFile += '1'; } else { outerTarFile += patch; } @@ -150,7 +150,7 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension() cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" << " not specified, defaulting to 1\n"); - this->OutputExtension += "1"; + this->OutputExtension += '1'; } else { this->OutputExtension += patch; } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 9a8e64d..41cd807 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -198,7 +198,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( std::string versionToolset = this->GeneratorToolsetVersion; cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]"); if (regex.find(versionToolset)) { - versionToolset = cmStrCat("v", versionToolset.erase(2, 1)); + versionToolset = cmStrCat('v', versionToolset.erase(2, 1)); } else { // Version not recognized. Clear it. versionToolset.clear(); @@ -441,7 +441,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) mf->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR ", - "specifies a platform too: '", this->GetName(), "'")); + "specifies a platform too: '", this->GetName(), '\'')); return false; } if (mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM") == @@ -471,7 +471,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf) mf->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR ", - "specifies a platform too: '", this->GetName(), "'")); + "specifies a platform too: '", this->GetName(), '\'')); return false; } @@ -848,7 +848,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) wd = cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeFiles"); } - wd += "/"; + wd += '/'; wd += cmVersion::GetCMakeVersion(); // We record the result persistently in a file. @@ -875,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 = cmStrCat(wd, "/", vcxproj); + std::string const vcxprojAbs = cmStrCat(wd, '/', vcxproj); cmsys::ofstream fout(vcxprojAbs.c_str()); cmXMLWriter xw(fout); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index d6a11df..1350945 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -161,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; @@ -256,7 +256,7 @@ void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion( mf->DisplayStatus(cmStrCat("Selecting Windows SDK version ", this->WindowsTargetPlatformVersion, " to target Windows ", this->SystemVersion, - "."), + '.'), -1); } mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 98176b0..8375b72 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -86,7 +86,7 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations( { fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; for (std::string const& i : configs) { - fout << "\t\t" << i << " = " << i << "\n"; + fout << "\t\t" << i << " = " << i << '\n'; } fout << "\tEndGlobalSection\n"; } @@ -217,11 +217,11 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( } } } - fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|" + fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << '|' << platformName << std::endl; auto ci = configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { - fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|" + fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << '|' << platformName << std::endl; } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 80a7be8..b2657a7 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -486,9 +486,9 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter); } else { VisualStudioFolders[cumulativePath].insert( - cmStrCat(cumulativePath, "/", iter)); + cmStrCat(cumulativePath, '/', iter)); - cumulativePath = cmStrCat(cumulativePath, "/", iter); + cumulativePath = cmStrCat(cumulativePath, '/', iter); } } @@ -581,7 +581,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( 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) { @@ -591,7 +591,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( cmTrimWhitespace(itPair.substr(0, posEqual)); const std::string value = cmTrimWhitespace(itPair.substr(posEqual + 1)); - fout << "\t\t" << key << " = " << value << "\n"; + fout << "\t\t" << key << " = " << value << '\n'; if (key == "SolutionGuid"_s) { addGuid = false; } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index a2a7cb1..2e87502 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -304,7 +304,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() for (const auto& gi : generators) { stampFile = cmStrCat(gi->GetMakefile()->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp"); - fout << stampFile << "\n"; + fout << stampFile << '\n'; stamps.push_back(stampFile); } } @@ -341,7 +341,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() std::string argS = cmStrCat("-S", lg.GetSourceDirectory()); std::string argB = cmStrCat("-B", lg.GetBinaryDirectory()); std::string const sln = - cmStrCat(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 }); @@ -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"; } @@ -417,25 +417,25 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( } } } - fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() - << ".ActiveCfg = " << dstConfig << "|" + fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName() + << ".ActiveCfg = " << dstConfig << '|' << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) - << "\n"; + << '\n'; auto ci = configsPartOfDefaultBuild.find(i); if (!(ci == configsPartOfDefaultBuild.end())) { - fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() - << ".Build.0 = " << dstConfig << "|" + fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName() + << ".Build.0 = " << dstConfig << '|' << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) - << "\n"; + << '\n'; } if (this->NeedsDeploy(target, dstConfig)) { - fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName() - << ".Deploy.0 = " << dstConfig << "|" + fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName() + << ".Deploy.0 = " << dstConfig << '|' << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) - << "\n"; + << '\n'; } } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index be5b79f..5305fec 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -243,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; } @@ -977,7 +977,7 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir, const std::string& projectName, bool dryRun) { - std::string sln = cmStrCat(bindir, "/", projectName, ".sln"); + std::string sln = cmStrCat(bindir, '/', projectName, ".sln"); if (dryRun) { return cmSystemTools::FileExists(sln, true); diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 8b408a9..938e4a3 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -524,7 +524,7 @@ 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)) { mf->IssueMessage( MessageType::FATAL_ERROR, @@ -538,7 +538,7 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance( "\n" "but the version field is not 4 integer components" " starting in ", - majorStr, ".")); + majorStr, '.')); return false; } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eaa2c2c..ef8a7e2 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -961,7 +961,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags( { std::string configTypeUpper = cmSystemTools::UpperCase(configName); std::string extraLinkOptionsBuildTypeDef = - cmStrCat(rootLinkerFlags, "_", configTypeUpper); + cmStrCat(rootLinkerFlags, '_', configTypeUpper); const std::string& extraLinkOptionsBuildType = this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef); @@ -979,30 +979,30 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( std::string extraLinkOptions; if (target->GetType() == cmStateEnums::EXECUTABLE) { extraLinkOptions = cmStrCat( - this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"), " ", + this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"), ' ', GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName)); } if (target->GetType() == cmStateEnums::SHARED_LIBRARY) { extraLinkOptions = cmStrCat( - this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"), " ", + this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"), ' ', GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName)); } if (target->GetType() == cmStateEnums::MODULE_LIBRARY) { extraLinkOptions = cmStrCat( - this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"), " ", + 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; } @@ -1286,7 +1286,7 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool( if (dir) { std::string const exe = - cmStrCat(*dir, "\\", target->GetFullName(config)); + cmStrCat(*dir, '\\', target->GetFullName(config)); fout << "\t\t\tConvertToXMLOutputPath( cmStrCat(dir, "/$(ConfigurationName)")) - << "," << this->ConvertToXMLOutputPath(dir); + << ',' << this->ConvertToXMLOutputPath(dir); comma = ","; } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b4c55b3..6e12402 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -104,7 +104,7 @@ struct cmVisualStudio10TargetGenerator::Elem void SetHasElements() { if (!HasElements) { - this->S << ">"; + this->S << '>'; HasElements = true; } } @@ -116,13 +116,13 @@ struct cmVisualStudio10TargetGenerator::Elem } Elem& Attribute(const char* an, std::string av) { - this->S << " " << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << "\""; + this->S << ' ' << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << '"'; return *this; } void Content(std::string val) { if (!this->HasContent) { - this->S << ">"; + this->S << '>'; this->HasContent = true; } this->S << cmVS10EscapeXML(std::move(val)); @@ -135,9 +135,9 @@ struct cmVisualStudio10TargetGenerator::Elem } if (HasElements) { - this->WriteString("Tag << ">"; + this->WriteString("Tag << '>'; } else if (HasContent) { - this->S << "Tag << ">"; + this->S << "Tag << '>'; } else { this->S << " />"; } @@ -291,7 +291,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->TargetCompileAsWinRT = false; this->IsMissingFiles = false; this->DefaultArtifactDir = - cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), "/", + cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget)); this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() == this->Makefile->GetCurrentBinaryDirectory()); @@ -304,8 +304,8 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition( const std::string& config) const { std::ostringstream oss; - oss << "'$(Configuration)|$(Platform)'=='" << config << "|" << this->Platform - << "'"; + oss << "'$(Configuration)|$(Platform)'=='" << config << '|' << this->Platform + << '\''; // handle special case for 32 bit C# targets if (this->ProjectType == VsProjectType::csproj && this->Platform == "Win32"_s) { @@ -870,7 +870,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( if (this->ProjectType == VsProjectType::csproj) { for (std::string const& c : this->Configurations) { Elem e1(e0, "PropertyGroup"); - e1.Attribute("Condition", cmStrCat("'$(Configuration)' == '", c, "'")); + e1.Attribute("Condition", + cmStrCat("'$(Configuration)' == '", c, '\'')); e1.SetHasElements(); this->WriteEvents(e1, c); } @@ -991,12 +992,12 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( for (const std::string& config : this->Configurations) { Elem e1(e0, "PropertyGroup"); e1.Attribute("Condition", - cmStrCat("'$(Configuration)' == '", config, "'")); + cmStrCat("'$(Configuration)' == '", config, '\'')); e1.SetHasElements(); this->WriteEvents(e1, config); std::string outDir = - cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); + cmStrCat(this->GeneratorTarget->GetDirectory(config), '/'); ConvertToWindowsSlash(outDir); e1.Element("OutputPath", outDir); @@ -1017,7 +1018,7 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) { e1.Attribute("Label", "Globals"); - e1.Element("ProjectGuid", cmStrCat("{", this->GUID, "}")); + e1.Element("ProjectGuid", cmStrCat('{', this->GUID, '}')); cmValue vsProjectTypes = this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES"); @@ -1114,7 +1115,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) std::string path = i.second; if (!cmsys::SystemTools::FileIsFullPath(path)) { path = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path); + cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path); } ConvertToWindowsSlash(path); this->DotNetHintReferences[""].emplace_back( @@ -1184,7 +1185,7 @@ void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0) for (auto& path : argsSplit) { if (!cmsys::SystemTools::FileIsFullPath(path)) { path = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path); + cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path); } ConvertToWindowsSlash(path); Elem e1(e0, "Import"); @@ -1280,7 +1281,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) } // Determine if this is a generated resource from a .Designer.cs file std::string designerResource = cmStrCat( - cmSystemTools::GetFilenamePath(oi->GetFullPath()), "/", + cmSystemTools::GetFilenamePath(oi->GetFullPath()), '/', cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()), ".Designer.cs"); if (cmsys::SystemTools::FileExists(designerResource)) { @@ -1368,9 +1369,9 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1) if (j > 0) { oss << " Or "; } - oss << "'$(Configuration)'=='" << tac.Configs[j] << "'"; + oss << "'$(Configuration)'=='" << tac.Configs[j] << '\''; } - oss << ")"; + oss << ')'; } Elem(e1, "Import") @@ -1410,7 +1411,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0) e1.Attribute("Label", "ProjectConfigurations"); for (std::string const& c : this->Configurations) { Elem e2(e1, "ProjectConfiguration"); - e2.Attribute("Include", cmStrCat(c, "|", this->Platform)); + e2.Attribute("Include", cmStrCat(c, '|', this->Platform)); e2.Element("Configuration", c); e2.Element("Platform", this->Platform); } @@ -1587,7 +1588,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( } std::string outDir = - cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); + cmStrCat(this->GeneratorTarget->GetDirectory(config), '/'); ConvertToWindowsSlash(outDir); e1.Element("OutputPath", outDir); @@ -1822,7 +1823,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } script += lg->FinishConstructScript(this->ProjectType); if (this->ProjectType == VsProjectType::csproj) { - std::string name = cmStrCat("CustomCommand_", c, "_", + std::string name = cmStrCat("CustomCommand_", c, '_', cmSystemTools::ComputeStringMD5(sourcePath)); this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(), outputs.str(), comment, ccg); @@ -2029,7 +2030,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", name); - e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); + e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}')); } } @@ -2038,7 +2039,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", "Resource Files"); - e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); + e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}')); e2.Element("Extensions", "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;" "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms"); @@ -2052,7 +2053,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::string guid = this->GlobalGenerator->GetGUID(guidName); Elem e2(e1, "Filter"); e2.Attribute("Include", filter); - e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}")); + e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}')); } } } @@ -2426,14 +2427,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( if (cge->Evaluate(this->LocalGenerator, config) == "1"_s) { e2.WritePlatformConfigTag( "DeploymentContent", - cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|", - this->Platform, "'"), + cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|', + this->Platform, '\''), "true"); } else { e2.WritePlatformConfigTag( "ExcludedFromBuild", - cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|", - this->Platform, "'"), + cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|', + this->Platform, '\''), "true"); } } @@ -2616,7 +2617,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) conditions << " Or "; } conditions << "('$(Configuration)|$(Platform)'=='" - << this->Configurations[ci] << "|" << this->Platform + << this->Configurations[ci] << '|' << this->Platform << "')"; firstConditionSet = true; } @@ -2698,8 +2699,8 @@ void cmVisualStudio10TargetGenerator::FinishWritingSource( } else { e2.WritePlatformConfigTag(setting.first, cmStrCat("'$(Configuration)|$(Platform)'=='", - configSettings.first, "|", - this->Platform, "'"), + configSettings.first, '|', + this->Platform, '\''), setting.second); } } @@ -2793,7 +2794,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper); if (cmValue ccdefs = sf.GetProperty(defPropName)) { if (!configDefines.empty()) { - configDefines += ";"; + configDefines += ';'; } configDependentDefines |= cmGeneratorExpression::Find(*ccdefs) != std::string::npos; @@ -2997,8 +2998,8 @@ void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild( for (size_t ci : exclude_configs) { e2.WritePlatformConfigTag("ExcludedFromBuild", cmStrCat("'$(Configuration)|$(Platform)'=='", - this->Configurations[ci], "|", - this->Platform, "'"), + this->Configurations[ci], '|', + this->Platform, '\''), "true"); } } @@ -3032,7 +3033,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( outDir = intermediateDir; targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib"); } else { - outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), "/"); + outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), '/'); targetNameFull = this->GeneratorTarget->GetFullName(config); } ConvertToWindowsSlash(intermediateDir); @@ -3360,7 +3361,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) { std::string clrString = *clr; if (!clrString.empty()) { - clrString = cmStrCat(":", clrString); + clrString = cmStrCat(':', clrString); } flags += cmStrCat(" /clr", clrString); } @@ -3611,7 +3612,7 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions( std::string CONFIG = cmSystemTools::UpperCase(configName); std::string rcConfigFlagsVar = cmStrCat("CMAKE_RC_FLAGS_", CONFIG); std::string flags = - cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), " ", + cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), ' ', this->Makefile->GetSafeDefinition(rcConfigFlagsVar)); rcOptions.Parse(flags); @@ -4304,19 +4305,19 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } std::string flags; std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS"); - flags += " "; + flags += ' '; flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase); - std::string linkFlagVar = cmStrCat(linkFlagVarBase, "_", CONFIG); - flags += " "; + std::string linkFlagVar = cmStrCat(linkFlagVarBase, '_', CONFIG); + flags += ' '; flags += this->Makefile->GetRequiredDefinition(linkFlagVar); cmValue targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { - flags += " "; + flags += ' '; flags += *targetLinkFlags; } std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG); if (cmValue flagsConfig = this->GeneratorTarget->GetProperty(flagsProp)) { - flags += " "; + flags += ' '; flags += *flagsConfig; } @@ -4812,7 +4813,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) Elem e2(e1, "ProjectReference"); e2.Attribute("Include", path); e2.Element("Project", - cmStrCat("{", this->GlobalGenerator->GetGUID(name), "}")); + cmStrCat('{', this->GlobalGenerator->GetGUID(name), '}')); e2.Element("Name", name); this->WriteDotNetReferenceCustomTags(e2, name); if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) { @@ -4940,7 +4941,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); Elem e1(e0, "PropertyGroup"); - e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, "\\")); + e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, '\\')); std::string resourcePriFile = cmStrCat(this->DefaultArtifactDir, "/resources.pri"); ConvertToWindowsSlash(resourcePriFile); @@ -5631,7 +5632,7 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink( this->Makefile->FindSourceGroup(fullFileName, sourceGroups); if (sourceGroup && !sourceGroup->GetFullName().empty()) { sourceGroupedFile = - cmStrCat(sourceGroup->GetFullName(), "/", + cmStrCat(sourceGroup->GetFullName(), '/', cmsys::SystemTools::GetFilenameName(fullFileName)); cmsys::SystemTools::ConvertToUnixSlashes(sourceGroupedFile); } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 80e37bd..6188134 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -361,7 +361,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( 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)) { @@ -411,7 +411,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( } if (lang == "ASM_NASM"_s) { - include += "\\"; + include += '\\'; } // Escape this include for the MSBuild. @@ -428,7 +428,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( } if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) { - oss << sep << "%(" << tag << ")"; + oss << sep << "%(" << tag << ')'; } this->OutputFlag(fout, indent, tag, oss.str()); diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx index d824462..f685158 100644 --- a/Source/cmVisualStudioSlnData.cxx +++ b/Source/cmVisualStudioSlnData.cxx @@ -74,7 +74,7 @@ std::string cmSlnData::GetConfigurationTarget( const std::string& platformName) { std::string solutionTarget = - cmStrCat(solutionConfiguration, "|", platformName); + cmStrCat(solutionConfiguration, '|', platformName); cm::optional project = GetProjectByName(projectName); if (!project) { return platformName; diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index aa7aae7..f13457f 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -40,7 +40,7 @@ std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const return OSMajorVersion; } - return cmStrCat(OSMajorVersion, ".", OSMinorVersion); + return cmStrCat(OSMajorVersion, '.', OSMinorVersion); } const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const -- cgit v0.12 From d4144b9c0a1a8a8f3a24ff33fc2582bb319d73ac Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:43:10 -0400 Subject: strings: use `emplace_back` with `cmStrCat` arguments --- Source/CPack/cmCPackInnoSetupGenerator.cxx | 8 ++++---- Source/cmExportBuildFileGenerator.cxx | 4 ++-- Source/cmExportInstallFileGenerator.cxx | 4 ++-- Source/cmGlobalGhsMultiGenerator.cxx | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 6 +++--- Source/cmGlobalVisualStudio12Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio14Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio9Generator.cxx | 8 ++++---- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 4 ++-- Source/cmNinjaTargetGenerator.cxx | 3 ++- Source/cmQtAutoMocUic.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 12 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx index ada9a5b..b8bf070 100644 --- a/Source/CPack/cmCPackInnoSetupGenerator.cxx +++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx @@ -106,7 +106,7 @@ int cmCPackInnoSetupGenerator::PackageFiles() const cmList extraScripts(GetOption("CPACK_INNOSETUP_EXTRA_SCRIPTS")); for (const std::string& i : extraScripts) { - includeDirectives.push_back(cmStrCat( + includeDirectives.emplace_back(cmStrCat( "#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel)))); } } @@ -142,7 +142,7 @@ int cmCPackInnoSetupGenerator::PackageFiles() const cmList codeFiles(GetOption("CPACK_INNOSETUP_CODE_FILES")); for (const std::string& i : codeFiles) { - codeIncludes.push_back(cmStrCat( + codeIncludes.emplace_back(cmStrCat( "#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel)))); } } @@ -781,7 +781,7 @@ bool cmCPackInnoSetupGenerator::ConfigureISScript() // Create internal variables std::vector 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 keys; for (const char* i : availableKeys) { if (params.count(i)) { - keys.push_back(cmStrCat(i, ": ", params.at(i))); + keys.emplace_back(cmStrCat(i, ": ", params.at(i))); } } diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 8d3960c..fd35786 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -419,7 +419,7 @@ std::string cmExportBuildFileGenerator::GetFileSetDirectories( resultVector.push_back( cmStrCat("\"$<$:", 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("\"$<$:", escapedFile, ">\"")); } else { - resultVector.push_back(cmStrCat('"', escapedFile, '"')); + resultVector.emplace_back(cmStrCat('"', escapedFile, '"')); } } } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 264c947..6cf3a09 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -616,7 +616,7 @@ std::string cmExportInstallFileGenerator::GetFileSetDirectories( resultVector.push_back( cmStrCat("\"$<$:", 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("\"$<$:", escapedFile, ">\"")); } else { - resultVector.push_back(cmStrCat('"', escapedFile, '"')); + resultVector.emplace_back(cmStrCat('"', escapedFile, '"')); } } } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 2453bfc..4ba53ec 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -670,7 +670,7 @@ bool cmGlobalGhsMultiGenerator::AddCheckTarget() } // Add the cache file. - listFiles.push_back(cmStrCat( + listFiles.emplace_back(cmStrCat( this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeCache.txt")); // Print not implemented warning. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 41cd807..7a852f8 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -975,9 +975,9 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) std::vector 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(cmStrCat("/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]"); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 6c72c5d..1f1a2c3 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -80,8 +80,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(cmStrCat(vs12generatorName, " ARM")); - names.push_back(cmStrCat(vs12generatorName, " Win64")); + names.emplace_back(cmStrCat(vs12generatorName, " ARM")); + names.emplace_back(cmStrCat(vs12generatorName, " Win64")); return names; } diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 1350945..9f1926d 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -82,8 +82,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(cmStrCat(vs14generatorName, " ARM")); - names.push_back(cmStrCat(vs14generatorName, " Win64")); + names.emplace_back(cmStrCat(vs14generatorName, " ARM")); + names.emplace_back(cmStrCat(vs14generatorName, " Win64")); return names; } diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 462db2a..de2153d 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -72,21 +72,21 @@ public: std::vector GetGeneratorNames() const override { std::vector names; - names.push_back(vs9generatorName); + names.emplace_back(vs9generatorName); return names; } std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(cmStrCat(vs9generatorName, " Win64")); - names.push_back(cmStrCat(vs9generatorName, " IA64")); + names.emplace_back(cmStrCat(vs9generatorName, " Win64")); + names.emplace_back(cmStrCat(vs9generatorName, " IA64")); cmVisualStudioWCEPlatformParser parser; parser.ParseVersion("9.0"); const std::vector& availablePlatforms = parser.GetAvailablePlatforms(); for (std::string const& i : availablePlatforms) { - names.push_back(cmStrCat("Visual Studio 9 2008 ", i)); + names.emplace_back(cmStrCat("Visual Studio 9 2008 ", i)); } return names; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 938e4a3..52e6d42 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -265,8 +265,8 @@ public: std::vector GetGeneratorNamesWithPlatform() const override { std::vector names; - names.push_back(cmStrCat(vs15generatorName, " ARM")); - names.push_back(cmStrCat(vs15generatorName, " Win64")); + names.emplace_back(cmStrCat(vs15generatorName, " ARM")); + names.emplace_back(cmStrCat(vs15generatorName, " Win64")); return names; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d712d71..4837ee6 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1052,7 +1052,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( for (std::string const& l : this->GetLinkedTargetDirectories(language, config)) { - build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json")); + build.ImplicitDeps.emplace_back( + cmStrCat(l, '/', language, "Modules.json")); } this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index a101a81..62b5172 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2116,7 +2116,7 @@ void cmQtAutoMocUicT::JobCompileMocT::MaybeWriteMocResponseFile( cmd.resize(1); // Specify response file - cmd.push_back(cmStrCat('@', responseFile)); + cmd.emplace_back(cmStrCat('@', responseFile)); } #else static_cast(outputFile); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6e12402..5ba9332 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4356,7 +4356,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( // first just full path linkDirs.push_back(d); // next path with configuration type Debug, Release, etc - linkDirs.push_back(cmStrCat(d, "/$(Configuration)")); + linkDirs.emplace_back(cmStrCat(d, "/$(Configuration)")); } linkDirs.push_back("%(AdditionalLibraryDirectories)"); linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs); -- cgit v0.12 From 48b38d2d864988081725cc0d306a18ae1e79ac96 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:58:16 -0400 Subject: cmLocalVisualStudio10Generator: remove unnecessary `.c_str()` --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 7 +++---- Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx | 2 +- Source/cmLocalVisualStudio10Generator.cxx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 9530120..c5b7abd 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -936,12 +936,11 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions( 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())) { + if (cmSystemTools::FileIsDirectory(fullPath)) { std::string subDirectoryId = cmStrCat("CM_D", id); directoryDefinitions.BeginElement("Directory"); @@ -1070,7 +1069,7 @@ std::string cmCPackWIXGenerator::PathToId(std::string const& path) std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) { std::vector components; - cmSystemTools::SplitPath(path.c_str(), components, false); + cmSystemTools::SplitPath(path, components, false); size_t replacementCount = 0; diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx index 13bbf37..a655d86 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -55,7 +55,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory( std::vector installRoot; - cmSystemTools::SplitPath(installRootString.c_str(), installRoot); + cmSystemTools::SplitPath(installRootString, installRoot); if (!installRoot.empty() && installRoot.back().empty()) { installRoot.pop_back(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 2a1521b..165f0fd 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -95,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 -- cgit v0.12 From 46f71720fe4064cc6a309c9dd9bd05060bda0667 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:58:46 -0400 Subject: cmVisualStudioSlnParser: simplify switch statement --- Source/cmVisualStudioSlnParser.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 9b61566..adfd4c5 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -171,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: -- cgit v0.12 From 1159cdc2354ab1f2eb8bcd76782fd464c715fcaa Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 14:59:17 -0400 Subject: cmVisualStudioWCEPlatformParser: combine character pushbacks --- Source/cmVisualStudioWCEPlatformParser.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index f13457f..8aa5384 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -25,8 +25,7 @@ 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 = cmStrCat(this->VcInstallDir, "vcpackages/WCE.VCPlatform.config"); -- cgit v0.12 From e8983bd20d7bfecba1d5961a68e61bc13efe5e37 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:04:55 -0400 Subject: clang-tidy: fix `readability-braces-around-statements` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 18 ++++++++++++------ Source/CPack/WiX/cmWIXAccessControlList.cxx | 3 ++- Source/CPack/WiX/cmWIXPatch.cxx | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index c5b7abd..0dd7760 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -314,8 +314,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl() void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() { cmValue cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); - if (!cpackWixExtraSources) + if (!cpackWixExtraSources) { return; + } cmExpandList(cpackWixExtraSources, this->WixSources); } @@ -323,8 +324,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 }; @@ -1059,8 +1061,9 @@ 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()) + if (i != PathToIdMap.end()) { return i->second; + } std::string id = CreateNewIdForPath(path); return id; @@ -1077,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); @@ -1163,8 +1167,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()); @@ -1204,8 +1209,9 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName, std::ostream& stream) { cmValue variableContent = GetOption(variableName); - if (!variableContent) + if (!variableContent) { return; + } cmList list{ variableContent }; diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 6aba228..cdb86c3 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -107,8 +107,9 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name) size_t i = 0; while (validAttributes[i]) { - if (name == validAttributes[i++]) + if (name == validAttributes[i++]) { return true; + } } return false; diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index c3ada17..70033a3 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -26,8 +26,9 @@ void cmWIXPatch::ApplyFragment(std::string const& id, cmWIXSourceWriter& writer) { cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); - if (i == Fragments.end()) + if (i == Fragments.end()) { return; + } const cmWIXPatchElement& fragment = i->second; for (auto const& attr : fragment.attributes) { -- cgit v0.12 From 93a366697f5310738935b2f25dbf978f39031764 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:05:21 -0400 Subject: clang-tidy: fix `modernize-use-nullptr` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 7 ++++--- Source/CPack/WiX/cmWIXAccessControlList.cxx | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 0dd7760..1f55b80 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -63,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; @@ -665,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); } } diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index cdb86c3..0ebe2f4 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -102,7 +102,7 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name) "Write", "WriteAttributes", "WriteExtendedAttributes", - 0 + nullptr }; size_t i = 0; -- cgit v0.12 From 4489e9a85ce96ec6d15856b298f3d0255c8d615b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:21:01 -0400 Subject: clang-tidy: fix `modernize-use-auto` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 2 +- Source/CPack/WiX/cmWIXPatch.cxx | 2 +- Source/CPack/WiX/cmWIXShortcut.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1f55b80..b12b817 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1061,7 +1061,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension( std::string cmCPackWIXGenerator::PathToId(std::string const& path) { - id_map_t::const_iterator i = PathToIdMap.find(path); + auto i = PathToIdMap.find(path); if (i != PathToIdMap.end()) { return i->second; } diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 70033a3..c65449c 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -25,7 +25,7 @@ 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); + auto i = Fragments.find(id); if (i == Fragments.end()) { return; } diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx index c3eb219..1cfb6c1 100644 --- a/Source/CPack/WiX/cmWIXShortcut.cxx +++ b/Source/CPack/WiX/cmWIXShortcut.cxx @@ -20,7 +20,7 @@ bool cmWIXShortcuts::EmitShortcuts( std::string const& cpackComponentName, cmWIXFilesSourceWriter& fileDefinitions) const { - shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type); + auto i = this->Shortcuts.find(type); if (i == this->Shortcuts.end()) { return false; -- cgit v0.12 From ffa49c23aaab2d1361321b9de32ef4da9e34c3bc Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:22:05 -0400 Subject: clang-tidy: fix `readability-else-after-return` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 16 ++++++++-------- Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index b12b817..31ddb0e 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -997,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 @@ -1012,9 +1012,8 @@ std::string cmCPackWIXGenerator::GetArchitecture() const if (void_p_size == "8"_s) { return "x64"; - } else { - return "x86"; } + return "x86"; } std::string cmCPackWIXGenerator::GenerateGUID() @@ -1109,7 +1108,8 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) << path << '\'' << std::endl); return std::string(); - } else if (ambiguityCount > 1) { + } + if (ambiguityCount > 1) { result << '_' << ambiguityCount; } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index f3fe3de..cef2da9 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -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; -- cgit v0.12 From 7eaab9a957fd8c86641d8400c37c40f27e70c215 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:22:28 -0400 Subject: clang-tidy: fix `modernize-raw-string-literal` lints --- Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 2 +- Source/CPack/WiX/cmWIXSourceWriter.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx index 3246e98..78c2208 100644 --- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -19,7 +19,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry( AddAttribute("Guid", CreateGuidFromComponentId("CM_PACKAGE_REGISTRY")); std::string registryKey = - cmStrCat("Software\\Kitware\\CMake\\Packages\\", package); + cmStrCat(R"(Software\Kitware\CMake\Packages\)", package); BeginElement("RegistryValue"); AddAttribute("Root", "HKLM"); diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index e13a3e0..54fa011 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -144,7 +144,7 @@ std::string cmWIXSourceWriter::CreateGuidFromComponentId( void cmWIXSourceWriter::WriteXMLDeclaration() { - File << "" << std::endl; + File << R"()" << std::endl; } void cmWIXSourceWriter::Indent(size_t count) -- cgit v0.12 From 32fe862b8cf35de9221f7ccc8145fcbf80c7041d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:22:41 -0400 Subject: clang-tidy: fix `readability-container-size-empty` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 31ddb0e..2853ab9 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -803,7 +803,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( } std::string componentId = "CM_SHORTCUT"; - if (idPrefix.size()) { + if (!idPrefix.empty()) { componentId += cmStrCat('_', idPrefix); } -- cgit v0.12 From 1df29567ac28b3738bf30e4aa40e95c4b155bef0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:22:58 -0400 Subject: clang-tidy: fix `modernize-use-equals-default` lints --- Source/CPack/WiX/cmWIXPatchParser.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 6a44d63..136eaac 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -21,9 +21,7 @@ cmWIXPatchNode::Type cmWIXPatchElement::type() return cmWIXPatchNode::ELEMENT; } -cmWIXPatchNode::~cmWIXPatchNode() -{ -} +cmWIXPatchNode::~cmWIXPatchNode() = default; cmWIXPatchElement::cmWIXPatchElement() = default; cmWIXPatchElement::~cmWIXPatchElement() = default; -- cgit v0.12 From 3d03629f20977bd137765e1d03ebbd53a349553c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:23:15 -0400 Subject: cmWIXRichTextFormatWriter: remove identity cast --- Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index cef2da9..8a63239 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -182,6 +182,6 @@ void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c) void cmWIXRichTextFormatWriter::EmitInvalidCodepoint(int c) { ControlWord("cf1 "); - File << "[INVALID-BYTE-" << int(c) << ']'; + File << "[INVALID-BYTE-" << c << ']'; ControlWord("cf0 "); } -- cgit v0.12 From a19ec77200ccd2157d936bec6472329464937b67 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:23:30 -0400 Subject: clang-tidy: fix `readability-static-accessed-through-instance` lints --- Source/CPack/WiX/cmWIXSourceWriter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 54fa011..82dc019 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -97,7 +97,7 @@ void cmWIXSourceWriter::AddTextNode(std::string const& text) return; } - File << this->EscapeAttributeValue(text); + File << cmWIXSourceWriter::EscapeAttributeValue(text); State = DEFAULT; } -- cgit v0.12 From d58253d155b43b8af1d0b64412145625907e3d9e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 18:23:46 -0400 Subject: clang-tidy: fix `performance-faster-string-find` lints --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 2853ab9..5077596 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1050,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); } -- cgit v0.12