diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-27 16:23:22 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-27 23:10:39 (GMT) |
commit | 3f1378fbcab72a849908bbc988254f392d04c41a (patch) | |
tree | 0dcf9d2e38272b101fa4bfb12133a22c9fb2def7 /Source/cmVisualStudioGeneratorOptions.cxx | |
parent | 7e3b9af191b1ae596b228d8ac3d709eecf8d82d4 (diff) | |
download | CMake-3f1378fbcab72a849908bbc988254f392d04c41a.zip CMake-3f1378fbcab72a849908bbc988254f392d04c41a.tar.gz CMake-3f1378fbcab72a849908bbc988254f392d04c41a.tar.bz2 |
strings: compare to static `string_view` instances in Windows-only code
Diffstat (limited to 'Source/cmVisualStudioGeneratorOptions.cxx')
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 41 |
1 files changed, 21 insertions, 20 deletions
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 <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; } |