Ver código fonte

strings: compare to static `string_view` instances in Windows-only code

Ben Boeckel 2 anos atrás
pai
commit
3f1378fbca

+ 9 - 8
Source/CPack/WiX/cmCPackWIXGenerator.cxx

@@ -7,6 +7,7 @@
 #include <cm/memory>
 #include <cm/string_view>
 #include <cmext/algorithm>
+#include <cmext/string_view>
 
 #include "cmsys/Directory.hxx"
 #include "cmsys/Encoding.hxx"
@@ -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<unsigned long>(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";

+ 3 - 1
Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx

@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmWIXDirectoriesSourceWriter.h"
 
+#include <cmext/string_view>
+
 cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
   cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
   : cmWIXSourceWriter(logger, filename, componentGuidType)
@@ -14,7 +16,7 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
   BeginElement("Directory");
   AddAttribute("Id", "ProgramMenuFolder");
 
-  if (startMenuFolder != ".") {
+  if (startMenuFolder != "."_s) {
     BeginElement("Directory");
     AddAttribute("Id", "PROGRAM_MENU_FOLDER");
     AddAttribute("Name", startMenuFolder);

+ 6 - 5
Source/CPack/WiX/cmWIXPatchParser.cxx

@@ -5,6 +5,7 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/string_view>
 
 #include <cm3p/expat.h>
 
@@ -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 {

+ 3 - 1
Source/cmCallVisualStudioMacro.cxx

@@ -4,6 +4,8 @@
 
 #include <sstream>
 
+#include <cmext/string_view>
+
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -305,7 +307,7 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
 //! we perhaps looking for any and all solutions?
 bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
 {
-  if (slnFile == "ALL" || slnName == "ALL") {
+  if (slnFile == "ALL"_s || slnName == "ALL"_s) {
     return true;
   }
 

+ 2 - 1
Source/cmGlobalJOMMakefileGenerator.cxx

@@ -5,6 +5,7 @@
 #include <ostream>
 
 #include <cmext/algorithm>
+#include <cmext/string_view>
 
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
@@ -45,7 +46,7 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
                                                        std::string const& lang,
                                                        cmValue envVar) const
 {
-  if (lang == "CXX" || lang == "C") {
+  if (lang == "CXX"_s || lang == "C"_s) {
     /* clang-format off */
     os <<
       "To use the JOM generator with Visual C++, cmake must be run from a "

+ 4 - 2
Source/cmGlobalMSYSMakefileGenerator.cxx

@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalMSYSMakefileGenerator.h"
 
+#include <cmext/string_view>
+
 #include "cmsys/FStream.hxx"
 
 #include "cmMakefile.h"
@@ -31,7 +33,7 @@ std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
   while (fin) {
     fin >> path;
     fin >> mount;
-    if (mount == "/mingw") {
+    if (mount == "/mingw"_s) {
       mingwBin = cmStrCat(path, "/bin");
     }
   }
@@ -45,7 +47,7 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 
   if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
-      !(1 == l.size() && l[0] == "NONE")) {
+      !(1 == l.size() && l[0] == "NONE"_s)) {
     cmSystemTools::Error(
       "CMAKE_AR was not found, please set to archive program. " +
       mf->GetSafeDefinition("CMAKE_AR"));

+ 2 - 1
Source/cmGlobalNMakeMakefileGenerator.cxx

@@ -5,6 +5,7 @@
 #include <ostream>
 
 #include <cmext/algorithm>
+#include <cmext/string_view>
 
 #include "cmsys/RegularExpression.hxx"
 
@@ -88,7 +89,7 @@ cmDocumentationEntry cmGlobalNMakeMakefileGenerator::GetDocumentation()
 void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(
   std::ostream& os, std::string const& lang, cmValue envVar) const
 {
-  if (lang == "CXX" || lang == "C") {
+  if (lang == "CXX"_s || lang == "C"_s) {
     /* clang-format off */
     os <<
       "To use the NMake generator with Visual C++, cmake must be run from a "

+ 75 - 73
Source/cmGlobalVisualStudio10Generator.cxx

@@ -9,6 +9,7 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/string_view>
 
 #include <cm3p/json/reader.h>
 #include <cm3p/json/value.h>
@@ -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<std::string> const& lang, cmMakefile* mf, bool optional)
 {
   for (std::string const& it : lang) {
-    if (it == "ASM_NASM") {
+    if (it == "ASM_NASM"_s) {
       this->NasmEnabled = true;
     }
-    if (it == "CUDA") {
+    if (it == "CUDA"_s) {
       this->CudaEnabled = true;
     }
   }
@@ -830,8 +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<cmSlnProjectEntry> 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 "";

+ 5 - 3
Source/cmGlobalVisualStudio11Generator.cxx

@@ -7,6 +7,8 @@
 #include <utility>
 #include <vector>
 
+#include <cmext/string_view>
+
 #include "cmGlobalGenerator.h"
 #include "cmGlobalVisualStudioGenerator.h"
 #include "cmMakefile.h"
@@ -25,7 +27,7 @@ void cmGlobalVisualStudio11Generator::EnableLanguage(
   std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
 {
   for (std::string const& it : lang) {
-    if (it == "ASM_MARMASM") {
+    if (it == "ASM_MARMASM"_s) {
       this->MarmasmEnabled = true;
     }
   }
@@ -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";

+ 6 - 4
Source/cmGlobalVisualStudio12Generator.cxx

@@ -6,6 +6,8 @@
 #include <sstream>
 #include <vector>
 
+#include <cmext/string_view>
+
 #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";

+ 4 - 3
Source/cmGlobalVisualStudio14Generator.cxx

@@ -6,6 +6,7 @@
 #include <sstream>
 
 #include <cm/vector>
+#include <cmext/string_view>
 
 #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;
     }
   }

+ 14 - 13
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;
             }
           }

+ 4 - 3
Source/cmGlobalVisualStudioGenerator.cxx

@@ -12,6 +12,7 @@
 
 #include <cm/iterator>
 #include <cm/memory>
+#include <cmext/string_view>
 
 #include <windows.h>
 
@@ -78,9 +79,9 @@ bool cmGlobalVisualStudioGenerator::SetGeneratorPlatform(std::string const& p,
   if (!this->InitializePlatform(mf)) {
     return false;
   }
-  if (this->GetPlatformName() == "x64") {
+  if (this->GetPlatformName() == "x64"_s) {
     mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
-  } else if (this->GetPlatformName() == "Itanium") {
+  } else if (this->GetPlatformName() == "Itanium"_s) {
     mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
   }
   mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
@@ -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(

+ 4 - 4
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;
     }
 

+ 4 - 1
Source/cmGlobalWatcomWMakeGenerator.cxx

@@ -4,6 +4,9 @@
 
 #include <ostream>
 
+#include <cm/string_view>
+#include <cmext/string_view>
+
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmState.h"
@@ -46,7 +49,7 @@ void cmGlobalWatcomWMakeGenerator::EnableLanguage(
 bool cmGlobalWatcomWMakeGenerator::SetSystemName(std::string const& s,
                                                  cmMakefile* mf)
 {
-  if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86") {
+  if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86"_s) {
     mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl");
     mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl");
   }

+ 3 - 1
Source/cmLocalVisualStudio10Generator.cxx

@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmLocalVisualStudio10Generator.h"
 
+#include <cmext/string_view>
+
 #include <cm3p/expat.h>
 
 #include "cmGlobalGenerator.h"
@@ -37,7 +39,7 @@ public:
     if (!this->GUID.empty()) {
       return;
     }
-    if ("ProjectGUID" == name || "ProjectGuid" == name) {
+    if (name == "ProjectGUID"_s || name == "ProjectGuid"_s) {
       this->DoGUID = true;
     }
   }

+ 2 - 1
Source/cmLocalVisualStudioGenerator.cxx

@@ -5,6 +5,7 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/string_view>
 
 #include "windows.h"
 
@@ -204,7 +205,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
     std::string suffix;
     if (cmd.size() > 4) {
       suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
-      if (suffix == ".bat" || suffix == ".cmd") {
+      if (suffix == ".bat"_s || suffix == ".cmd"_s) {
         script += "call ";
       }
     }

+ 73 - 71
Source/cmVisualStudio10TargetGenerator.cxx

@@ -15,6 +15,7 @@
 #include <cm/string_view>
 #include <cm/vector>
 #include <cmext/algorithm>
+#include <cmext/string_view>
 
 #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<std::string> 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);

+ 21 - 20
Source/cmVisualStudioGeneratorOptions.cxx

@@ -7,6 +7,7 @@
 #include <vector>
 
 #include <cm/iterator>
+#include <cmext/string_view>
 
 #include "cmAlgorithms.h"
 #include "cmLocalVisualStudioGenerator.h"
@@ -117,7 +118,7 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const
   auto i = this->FlagMap.find("DebugType");
   if (i != this->FlagMap.end()) {
     if (i->second.size() == 1) {
-      return i->second[0] != "none";
+      return i->second[0] != "none"_s;
     }
   }
   return false;
@@ -137,13 +138,13 @@ bool cmVisualStudioGeneratorOptions::UsingUnicode() const
 {
   // Look for a _UNICODE definition.
   return std::any_of(this->Defines.begin(), this->Defines.end(),
-                     [](std::string const& di) { return di == "_UNICODE"; });
+                     [](std::string const& di) { return di == "_UNICODE"_s; });
 }
 bool cmVisualStudioGeneratorOptions::UsingSBCS() const
 {
   // Look for a _SBCS definition.
   return std::any_of(this->Defines.begin(), this->Defines.end(),
-                     [](std::string const& di) { return di == "_SBCS"; });
+                     [](std::string const& di) { return di == "_SBCS"_s; });
 }
 
 void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
@@ -171,7 +172,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
     return;
   }
 
-  if (subOptions.size() == 1 && subOptions[0] == "NO") {
+  if (subOptions.size() == 1 && subOptions[0] == "NO"_s) {
     AddFlag(ENABLE_UAC, "false");
     return;
   }
@@ -198,7 +199,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
         1, std::max(std::string::size_type(0), keyValue[1].length() - 2));
     }
 
-    if (keyValue[0] == "level") {
+    if (keyValue[0] == "level"_s) {
       if (uacExecuteLevelMap.find(keyValue[1]) == uacExecuteLevelMap.end()) {
         // unknown level value
         continue;
@@ -208,8 +209,8 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
       continue;
     }
 
-    if (keyValue[0] == "uiAccess") {
-      if (keyValue[1] != "true" && keyValue[1] != "false") {
+    if (keyValue[0] == "uiAccess"_s) {
+      if (keyValue[1] != "true"_s && keyValue[1] != "false"_s) {
         // unknown uiAccess value
         continue;
       }
@@ -260,11 +261,11 @@ void cmVisualStudioGeneratorOptions::ParseFinish()
     auto i = this->FlagMap.find("CudaRuntime");
     if (i != this->FlagMap.end() && i->second.size() == 1) {
       std::string& cudaRuntime = i->second[0];
-      if (cudaRuntime == "static") {
+      if (cudaRuntime == "static"_s) {
         cudaRuntime = "Static";
-      } else if (cudaRuntime == "shared") {
+      } else if (cudaRuntime == "shared"_s) {
         cudaRuntime = "Shared";
-      } else if (cudaRuntime == "none") {
+      } else if (cudaRuntime == "none"_s) {
         cudaRuntime = "None";
       }
     }
@@ -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;
     }

+ 24 - 22
Source/cmVisualStudioSlnParser.cxx

@@ -8,6 +8,8 @@
 #include <utility>
 #include <vector>
 
+#include <cmext/string_view>
+
 #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<std::string> 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

+ 8 - 8
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;
     }