From fe17685722f7c4af3664409f1728f7c3e9e4e9da Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:10:53 -0500 Subject: cmGlobalVisualStudio10Generator: Adopt flag table name methods Migrate them from `cmVisualStudio10ToolsetOptions`. --- Source/CMakeLists.txt | 2 - Source/cmGlobalVisualStudio10Generator.cxx | 188 +++++++++++++++++++++++++---- Source/cmGlobalVisualStudio10Generator.h | 17 ++- Source/cmVisualStudio10ToolsetOptions.cxx | 143 ---------------------- Source/cmVisualStudio10ToolsetOptions.h | 31 ----- 5 files changed, 177 insertions(+), 204 deletions(-) delete mode 100644 Source/cmVisualStudio10ToolsetOptions.cxx delete mode 100644 Source/cmVisualStudio10ToolsetOptions.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6adc9cf..d782890 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -785,8 +785,6 @@ if (WIN32) cmVisualStudioGeneratorOptions.cxx cmVisualStudio10TargetGenerator.h cmVisualStudio10TargetGenerator.cxx - cmVisualStudio10ToolsetOptions.h - cmVisualStudio10ToolsetOptions.cxx cmLocalVisualStudio10Generator.cxx cmLocalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.h diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7794df3..8ad6f5d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1400,65 +1400,65 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetClFlagTableName( + std::string optionsName = this->GetClFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( - this->GetPlatformName(), this->DefaultCLFlagTableName); + std::string defaultName = this->GetToolsetName(this->GetPlatformName(), + this->DefaultCLFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetCSharpFlagTableName( + std::string optionsName = this->GetCSharpFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultCSharpFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetRcFlagTableName( + std::string optionsName = this->GetRcFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( - this->GetPlatformName(), this->DefaultRCFlagTableName); + std::string defaultName = this->GetToolsetName(this->GetPlatformName(), + this->DefaultRCFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetLibFlagTableName( + std::string optionsName = this->GetLibFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultLibFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetLinkFlagTableName( + std::string optionsName = this->GetLinkFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultLinkFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultCudaFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "Cuda"); } @@ -1466,29 +1466,165 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultCudaHostFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = this->ToolsetOptions.GetMasmFlagTableName( + std::string optionsName = this->GetMasmFlagTableName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultMasmFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string toolsetName = this->ToolsetOptions.GetToolsetName( + std::string toolsetName = this->GetToolsetName( this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->ToolsetOptions.GetToolsetName( + std::string defaultName = this->GetToolsetName( this->GetPlatformName(), this->DefaultNasmFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "NASM"); } + +std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if (toolset == "v142") { + return "v142"; + } else if (toolset == "v141") { + return "v141"; + } else if (useToolset == "v140") { + return "v140"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if (useToolset == "v142") { + return "v142"; + } else if (useToolset == "v141") { + return "v141"; + } else if (useToolset == "v140") { + return "v140"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { + return "v14"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { + return "v14"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if (useToolset == "v142") { + return "v142"; + } else if (useToolset == "v141") { + return "v141"; + } else if (useToolset == "v140") { + return "v140"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( + std::string const& name, std::string const& toolset) const +{ + std::string const useToolset = this->GetToolsetName(name, toolset); + + if ((useToolset == "v140") || (useToolset == "v141") || + (useToolset == "v142")) { + return "v14"; + } else if (useToolset == "v120") { + return "v12"; + } else if (useToolset == "v110") { + return "v11"; + } else if (useToolset == "v100") { + return "v10"; + } else { + return ""; + } +} + +std::string cmGlobalVisualStudio10Generator::GetToolsetName( + std::string const& name, std::string const& toolset) const +{ + static_cast(name); + std::size_t length = toolset.length(); + + if (cmHasLiteralSuffix(toolset, "_xp")) { + length -= 3; + } + + return toolset.substr(0, length); +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 65ea33f..64a7b95 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -6,7 +6,6 @@ #include #include "cmGlobalVisualStudio8Generator.h" -#include "cmVisualStudio10ToolsetOptions.h" /** \class cmGlobalVisualStudio10Generator * \brief Write a Unix makefiles. @@ -224,7 +223,6 @@ private: std::string MSBuildCommand; bool MSBuildCommandInitialized; - cmVisualStudio10ToolsetOptions ToolsetOptions; std::set AndroidExecutableWarnings; virtual std::string FindMSBuildCommand(); std::string FindDevEnvCommand() override; @@ -234,6 +232,21 @@ private: bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); + std::string GetClFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetCSharpFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetRcFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetLibFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetLinkFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetMasmFlagTableName(std::string const& name, + std::string const& toolset) const; + std::string GetToolsetName(std::string const& name, + std::string const& toolset) const; + std::string CustomVCTargetsPath; std::string VCTargetsPath; bool FindVCTargetsPath(cmMakefile* mf); diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx deleted file mode 100644 index 7fc33e6..0000000 --- a/Source/cmVisualStudio10ToolsetOptions.cxx +++ /dev/null @@ -1,143 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmVisualStudio10ToolsetOptions.h" - -#include "cmAlgorithms.h" -#include "cmIDEFlagTable.h" -#include "cmVisualStudioGeneratorOptions.h" - -std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if (toolset == "v142") { - return "v142"; - } else if (toolset == "v141") { - return "v141"; - } else if (useToolset == "v140") { - return "v140"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if (useToolset == "v142") { - return "v142"; - } else if (useToolset == "v141") { - return "v141"; - } else if (useToolset == "v140") { - return "v140"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if ((useToolset == "v140") || (useToolset == "v141") || - (useToolset == "v142")) { - return "v14"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if ((useToolset == "v140") || (useToolset == "v141") || - (useToolset == "v142")) { - return "v14"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if (useToolset == "v142") { - return "v142"; - } else if (useToolset == "v141") { - return "v141"; - } else if (useToolset == "v140") { - return "v140"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName( - std::string const& name, std::string const& toolset) const -{ - std::string const useToolset = this->GetToolsetName(name, toolset); - - if ((useToolset == "v140") || (useToolset == "v141") || - (useToolset == "v142")) { - return "v14"; - } else if (useToolset == "v120") { - return "v12"; - } else if (useToolset == "v110") { - return "v11"; - } else if (useToolset == "v100") { - return "v10"; - } else { - return ""; - } -} - -std::string cmVisualStudio10ToolsetOptions::GetToolsetName( - std::string const& name, std::string const& toolset) const -{ - static_cast(name); - std::size_t length = toolset.length(); - - if (cmHasLiteralSuffix(toolset, "_xp")) { - length -= 3; - } - - return toolset.substr(0, length); -} diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h deleted file mode 100644 index 85cc2b6..0000000 --- a/Source/cmVisualStudio10ToolsetOptions.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#pragma once - -#include "cmConfigure.h" // IWYU pragma: keep - -#include - -/** \class cmVisualStudio10ToolsetOptions - * \brief Retrieves toolset options for MSBuild. - * - * cmVisualStudio10ToolsetOptions manages toolsets within MSBuild - */ -class cmVisualStudio10ToolsetOptions -{ -public: - std::string GetClFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetCSharpFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetRcFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetLibFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetLinkFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetMasmFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetToolsetName(std::string const& name, - std::string const& toolset) const; -}; -- cgit v0.12 From e562e8987ca0d569e19034ec97141a009999536b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:36:53 -0500 Subject: cmGlobalVisualStudio10Generator: Remove unused flag table method argument --- Source/cmGlobalVisualStudio10Generator.cxx | 121 ++++++++++++++--------------- Source/cmGlobalVisualStudio10Generator.h | 21 ++--- 2 files changed, 66 insertions(+), 76 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 8ad6f5d..e3eadf6 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1400,103 +1400,101 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = this->GetClFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName(this->GetPlatformName(), - this->DefaultCLFlagTableName); + std::string optionsName = + this->GetClFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = this->GetToolsetName(this->DefaultCLFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = this->GetCSharpFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultCSharpFlagTableName); + std::string optionsName = + this->GetCSharpFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultCSharpFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = this->GetRcFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName(this->GetPlatformName(), - this->DefaultRCFlagTableName); + std::string optionsName = + this->GetRcFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = this->GetToolsetName(this->DefaultRCFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = this->GetLibFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultLibFlagTableName); + std::string optionsName = + this->GetLibFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultLibFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = this->GetLinkFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultLinkFlagTableName); + std::string optionsName = + this->GetLinkFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultLinkFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultCudaFlagTableName); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultCudaFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultCudaHostFlagTableName); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultCudaHostFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = this->GetMasmFlagTableName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultMasmFlagTableName); + std::string optionsName = + this->GetMasmFlagTableName(this->GetPlatformToolsetString()); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultMasmFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string toolsetName = this->GetToolsetName( - this->GetPlatformName(), this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName( - this->GetPlatformName(), this->DefaultNasmFlagTableName); + std::string toolsetName = + this->GetToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->GetToolsetName(this->DefaultNasmFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if (toolset == "v142") { return "v142"; @@ -1516,9 +1514,9 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1538,9 +1536,9 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1557,9 +1555,9 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1576,9 +1574,9 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1598,9 +1596,9 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(name, toolset); + std::string const useToolset = this->GetToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1617,9 +1615,8 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( } std::string cmGlobalVisualStudio10Generator::GetToolsetName( - std::string const& name, std::string const& toolset) const + std::string const& toolset) const { - static_cast(name); std::size_t length = toolset.length(); if (cmHasLiteralSuffix(toolset, "_xp")) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 64a7b95..5057572 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -232,20 +232,13 @@ private: bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); - std::string GetClFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetCSharpFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetRcFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetLibFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetLinkFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetMasmFlagTableName(std::string const& name, - std::string const& toolset) const; - std::string GetToolsetName(std::string const& name, - std::string const& toolset) const; + std::string GetClFlagTableName(std::string const& toolset) const; + std::string GetCSharpFlagTableName(std::string const& toolset) const; + std::string GetRcFlagTableName(std::string const& toolset) const; + std::string GetLibFlagTableName(std::string const& toolset) const; + std::string GetLinkFlagTableName(std::string const& toolset) const; + std::string GetMasmFlagTableName(std::string const& toolset) const; + std::string GetToolsetName(std::string const& toolset) const; std::string CustomVCTargetsPath; std::string VCTargetsPath; -- cgit v0.12 From a1c0758ea0c26eb1f5003cca431f3326e1e2495b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:42:52 -0500 Subject: cmGlobalVisualStudio10Generator: Clarify method name --- Source/cmGlobalVisualStudio10Generator.cxx | 52 ++++++++++++++++-------------- Source/cmGlobalVisualStudio10Generator.h | 2 +- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index e3eadf6..a8207b5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1403,8 +1403,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const std::string optionsName = this->GetClFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName(this->DefaultCLFlagTableName); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->CanonicalToolsetName(this->DefaultCLFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CL"); } @@ -1414,9 +1415,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() std::string optionsName = this->GetCSharpFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultCSharpFlagTableName); + this->CanonicalToolsetName(this->DefaultCSharpFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp"); } @@ -1425,8 +1426,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const std::string optionsName = this->GetRcFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); - std::string defaultName = this->GetToolsetName(this->DefaultRCFlagTableName); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); + std::string defaultName = + this->CanonicalToolsetName(this->DefaultRCFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "RC"); } @@ -1435,9 +1437,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const std::string optionsName = this->GetLibFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultLibFlagTableName); + this->CanonicalToolsetName(this->DefaultLibFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB"); } @@ -1446,18 +1448,18 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const std::string optionsName = this->GetLinkFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultLinkFlagTableName); + this->CanonicalToolsetName(this->DefaultLinkFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultCudaFlagTableName); + this->CanonicalToolsetName(this->DefaultCudaFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "Cuda"); } @@ -1465,9 +1467,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultCudaHostFlagTableName); + this->CanonicalToolsetName(this->DefaultCudaHostFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "CudaHost"); } @@ -1476,25 +1478,25 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const std::string optionsName = this->GetMasmFlagTableName(this->GetPlatformToolsetString()); std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultMasmFlagTableName); + this->CanonicalToolsetName(this->DefaultMasmFlagTableName); return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { std::string toolsetName = - this->GetToolsetName(this->GetPlatformToolsetString()); + this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = - this->GetToolsetName(this->DefaultNasmFlagTableName); + this->CanonicalToolsetName(this->DefaultNasmFlagTableName); return LoadFlagTable("", toolsetName, defaultName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if (toolset == "v142") { return "v142"; @@ -1516,7 +1518,7 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1538,7 +1540,7 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1557,7 +1559,7 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1576,7 +1578,7 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1598,7 +1600,7 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1614,7 +1616,7 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetToolsetName( +std::string cmGlobalVisualStudio10Generator::CanonicalToolsetName( std::string const& toolset) const { std::size_t length = toolset.length(); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5057572..6736e17 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -238,7 +238,7 @@ private: std::string GetLibFlagTableName(std::string const& toolset) const; std::string GetLinkFlagTableName(std::string const& toolset) const; std::string GetMasmFlagTableName(std::string const& toolset) const; - std::string GetToolsetName(std::string const& toolset) const; + std::string CanonicalToolsetName(std::string const& toolset) const; std::string CustomVCTargetsPath; std::string VCTargetsPath; -- cgit v0.12 From 1b774e18fbf98b1e5b3b046e621e36f2e7d145f5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:50:43 -0500 Subject: cmGlobalVisualStudio10Generator: Remove redundant arguments --- Source/cmGlobalVisualStudio10Generator.cxx | 42 +++++++++++++----------------- Source/cmGlobalVisualStudio10Generator.h | 12 ++++----- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a8207b5..a155d7d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1400,8 +1400,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = - this->GetClFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetClFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1412,8 +1411,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = - this->GetCSharpFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetCSharpFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1423,8 +1421,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = - this->GetRcFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetRcFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1434,8 +1431,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = - this->GetLibFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetLibFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1445,8 +1441,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = - this->GetLinkFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetLinkFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1475,8 +1470,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = - this->GetMasmFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetMasmFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1493,9 +1487,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const return LoadFlagTable("", toolsetName, defaultName, "NASM"); } -std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (toolset == "v142") { @@ -1515,9 +1509,9 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { @@ -1537,9 +1531,9 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || @@ -1556,9 +1550,9 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || @@ -1575,9 +1569,9 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { @@ -1597,9 +1591,9 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 6736e17..d683c37 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -232,12 +232,12 @@ private: bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); - std::string GetClFlagTableName(std::string const& toolset) const; - std::string GetCSharpFlagTableName(std::string const& toolset) const; - std::string GetRcFlagTableName(std::string const& toolset) const; - std::string GetLibFlagTableName(std::string const& toolset) const; - std::string GetLinkFlagTableName(std::string const& toolset) const; - std::string GetMasmFlagTableName(std::string const& toolset) const; + std::string GetClFlagTableName() const; + std::string GetCSharpFlagTableName() const; + std::string GetRcFlagTableName() const; + std::string GetLibFlagTableName() const; + std::string GetLinkFlagTableName() const; + std::string GetMasmFlagTableName() const; std::string CanonicalToolsetName(std::string const& toolset) const; std::string CustomVCTargetsPath; -- cgit v0.12 From 99f6f1b3b9df00f0221a0603fca12c4388f3c596 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:50:43 -0500 Subject: cmGlobalVisualStudio10Generator: Remove redundant arguments --- Source/cmGlobalVisualStudio10Generator.cxx | 42 +++++++++--------------------- Source/cmGlobalVisualStudio10Generator.h | 1 - 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a155d7d..6b7a972 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1366,8 +1366,8 @@ static std::string cmGetFlagTableName(std::string const& toolsetName, } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( - std::string const& optionsName, std::string const& toolsetName, - std::string const& defaultName, std::string const& table) const + std::string const& optionsName, std::string const& defaultName, + std::string const& table) const { cmIDEFlagTable const* ret = nullptr; @@ -1376,6 +1376,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( filename = cmGetFlagTableName(optionsName, table); ret = cmLoadFlagTableJson(filename); } else { + std::string const& toolsetName = + this->CanonicalToolsetName(this->GetPlatformToolsetString()); filename = cmGetFlagTableName(toolsetName, table); if (cmSystemTools::FileExists(filename)) { ret = cmLoadFlagTableJson(filename); @@ -1401,90 +1403,72 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { std::string optionsName = this->GetClFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCLFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "CL"); + return LoadFlagTable(optionsName, defaultName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { std::string optionsName = this->GetCSharpFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCSharpFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp"); + return LoadFlagTable(optionsName, defaultName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { std::string optionsName = this->GetRcFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultRCFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "RC"); + return LoadFlagTable(optionsName, defaultName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { std::string optionsName = this->GetLibFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultLibFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB"); + return LoadFlagTable(optionsName, defaultName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { std::string optionsName = this->GetLinkFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultLinkFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "Link"); + return LoadFlagTable(optionsName, defaultName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCudaFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "Cuda"); + return LoadFlagTable("", defaultName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCudaHostFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "CudaHost"); + return LoadFlagTable("", defaultName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { std::string optionsName = this->GetMasmFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultMasmFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM"); + return LoadFlagTable(optionsName, defaultName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultNasmFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "NASM"); + return LoadFlagTable("", defaultName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index d683c37..5160f29 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -170,7 +170,6 @@ protected: std::string const& GetMSBuildCommand(); cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName, - std::string const& toolsetName, std::string const& defaultName, std::string const& table) const; -- cgit v0.12 From d5522f096da4a04669e49bebfb63887ca1b0fdde Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:25:01 -0500 Subject: cmGlobalVisualStudio10Generator: Drop default toolset name canonicalization The default toolset names are always canonical. --- Source/cmGlobalVisualStudio10Generator.cxx | 37 ++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6b7a972..101ddc0 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1403,72 +1403,55 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { std::string optionsName = this->GetClFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCLFlagTableName); - return LoadFlagTable(optionsName, defaultName, "CL"); + return LoadFlagTable(optionsName, this->DefaultCLFlagTableName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { std::string optionsName = this->GetCSharpFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCSharpFlagTableName); - return LoadFlagTable(optionsName, defaultName, "CSharp"); + return LoadFlagTable(optionsName, this->DefaultCSharpFlagTableName, + "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { std::string optionsName = this->GetRcFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultRCFlagTableName); - return LoadFlagTable(optionsName, defaultName, "RC"); + return LoadFlagTable(optionsName, this->DefaultRCFlagTableName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { std::string optionsName = this->GetLibFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultLibFlagTableName); - return LoadFlagTable(optionsName, defaultName, "LIB"); + return LoadFlagTable(optionsName, this->DefaultLibFlagTableName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { std::string optionsName = this->GetLinkFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultLinkFlagTableName); - return LoadFlagTable(optionsName, defaultName, "Link"); + return LoadFlagTable(optionsName, this->DefaultLinkFlagTableName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCudaFlagTableName); - return LoadFlagTable("", defaultName, "Cuda"); + return LoadFlagTable("", this->DefaultCudaFlagTableName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCudaHostFlagTableName); - return LoadFlagTable("", defaultName, "CudaHost"); + return LoadFlagTable("", this->DefaultCudaHostFlagTableName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { std::string optionsName = this->GetMasmFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultMasmFlagTableName); - return LoadFlagTable(optionsName, defaultName, "MASM"); + return LoadFlagTable(optionsName, this->DefaultMasmFlagTableName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultNasmFlagTableName); - return LoadFlagTable("", defaultName, "NASM"); + return LoadFlagTable("", this->DefaultNasmFlagTableName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const -- cgit v0.12 From cbba9f26a891d477851fac1cf1515d69c25d41a9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:29:08 -0500 Subject: cmGlobalVisualStudio10Generator: Drop unnecessary temporaries --- Source/cmGlobalVisualStudio10Generator.cxx | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 101ddc0..0c7f1c4 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1402,56 +1402,56 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = this->GetClFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultCLFlagTableName, "CL"); + return LoadFlagTable(this->GetClFlagTableName(), + this->DefaultCLFlagTableName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = this->GetCSharpFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultCSharpFlagTableName, - "CSharp"); + return LoadFlagTable(this->GetCSharpFlagTableName(), + this->DefaultCSharpFlagTableName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = this->GetRcFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultRCFlagTableName, "RC"); + return LoadFlagTable(this->GetRcFlagTableName(), + this->DefaultRCFlagTableName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = this->GetLibFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultLibFlagTableName, "LIB"); + return LoadFlagTable(this->GetLibFlagTableName(), + this->DefaultLibFlagTableName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = this->GetLinkFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultLinkFlagTableName, "Link"); + return LoadFlagTable(this->GetLinkFlagTableName(), + this->DefaultLinkFlagTableName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - return LoadFlagTable("", this->DefaultCudaFlagTableName, "Cuda"); + return LoadFlagTable(std::string(), this->DefaultCudaFlagTableName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - return LoadFlagTable("", this->DefaultCudaHostFlagTableName, "CudaHost"); + return LoadFlagTable(std::string(), this->DefaultCudaHostFlagTableName, + "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = this->GetMasmFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultMasmFlagTableName, "MASM"); + return LoadFlagTable(this->GetMasmFlagTableName(), + this->DefaultMasmFlagTableName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - return LoadFlagTable("", this->DefaultNasmFlagTableName, "NASM"); + return LoadFlagTable(std::string(), this->DefaultNasmFlagTableName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const -- cgit v0.12 From 414b5e0119a99de401e1d7aea61428ec2c9311d5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:34:34 -0500 Subject: cmGlobalVisualStudio10Generator: Clarify LoadFlagTable argument name --- Source/cmGlobalVisualStudio10Generator.cxx | 10 +++++----- Source/cmGlobalVisualStudio10Generator.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0c7f1c4..40e30d5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1366,19 +1366,19 @@ static std::string cmGetFlagTableName(std::string const& toolsetName, } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( - std::string const& optionsName, std::string const& defaultName, + std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const { cmIDEFlagTable const* ret = nullptr; std::string filename; - if (!optionsName.empty()) { - filename = cmGetFlagTableName(optionsName, table); + if (!toolSpecificName.empty()) { + filename = cmGetFlagTableName(toolSpecificName, table); ret = cmLoadFlagTableJson(filename); } else { - std::string const& toolsetName = + std::string const& genericName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); - filename = cmGetFlagTableName(toolsetName, table); + filename = cmGetFlagTableName(genericName, table); if (cmSystemTools::FileExists(filename)) { ret = cmLoadFlagTableJson(filename); } else { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5160f29..e8f5ab5 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -169,7 +169,7 @@ protected: std::string const& GetMSBuildCommand(); - cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName, + cmIDEFlagTable const* LoadFlagTable(std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const; -- cgit v0.12 From 1b33150f7eff42df9d3f926b078de44681755a1d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 16:23:52 -0500 Subject: cmGlobalVisualStudio10Generator: Generalize flag table lookup interface --- Source/cmGlobalVisualStudio10Generator.cxx | 59 +++++++++++++++++++----------- Source/cmGlobalVisualStudio10Generator.h | 6 +++ 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 40e30d5..8d68bf6 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1358,46 +1358,61 @@ static cmIDEFlagTable const* cmLoadFlagTableJson( return ret; } -static std::string cmGetFlagTableName(std::string const& toolsetName, - std::string const& table) +cm::optional cmGlobalVisualStudio10Generator::FindFlagTable( + cm::string_view toolsetName, cm::string_view table) const { - return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" + - toolsetName + "_" + table + ".json"; + std::string fullPath = + cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/MSBuild/FlagTables/", + toolsetName, '_', table, ".json"); + if (cmSystemTools::FileExists(fullPath)) { + return fullPath; + } + return {}; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const { - cmIDEFlagTable const* ret = nullptr; + cmMakefile* mf = this->GetCurrentMakefile(); std::string filename; if (!toolSpecificName.empty()) { - filename = cmGetFlagTableName(toolSpecificName, table); - ret = cmLoadFlagTableJson(filename); + if (cm::optional found = + this->FindFlagTable(toolSpecificName, table)) { + filename = std::move(*found); + } else { + mf->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("JSON flag table for ", table, + " not found for toolset ", toolSpecificName)); + return nullptr; + } } else { std::string const& genericName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); - filename = cmGetFlagTableName(genericName, table); - if (cmSystemTools::FileExists(filename)) { - ret = cmLoadFlagTableJson(filename); + cm::optional found = this->FindFlagTable(genericName, table); + if (!found) { + found = this->FindFlagTable(defaultName, table); + } + if (found) { + filename = std::move(*found); } else { - filename = cmGetFlagTableName(defaultName, table); - ret = cmLoadFlagTableJson(filename); + mf->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("JSON flag table for ", table, + " not found for toolset ", genericName, " ", + defaultName)); + return nullptr; } } - if (!ret) { - cmMakefile* mf = this->GetCurrentMakefile(); - - std::ostringstream e; - /* clang-format off */ - e << "JSON flag table \"" << filename << - "\" could not be loaded.\n"; - /* clang-format on */ - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename)) { + return ret; } - return ret; + + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("JSON flag table could not be loaded:\n ", filename)); + return nullptr; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index e8f5ab5..df79ad7 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -5,6 +5,9 @@ #include #include +#include +#include + #include "cmGlobalVisualStudio8Generator.h" /** \class cmGlobalVisualStudio10Generator @@ -239,6 +242,9 @@ private: std::string GetMasmFlagTableName() const; std::string CanonicalToolsetName(std::string const& toolset) const; + cm::optional FindFlagTable(cm::string_view toolsetName, + cm::string_view table) const; + std::string CustomVCTargetsPath; std::string VCTargetsPath; bool FindVCTargetsPath(cmMakefile* mf); -- cgit v0.12