From 89cc3d432bc576d00cb12880b37ec8b348599897 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jan 2019 08:43:29 -0500 Subject: VS: Move platform name members to top-level global generator We no longer support any VS versions that pre-date support for multiple platforms (target architectures). --- Source/cmGlobalVisualStudio7Generator.cxx | 28 +--------------------------- Source/cmGlobalVisualStudio7Generator.h | 7 ------- Source/cmGlobalVisualStudioGenerator.cxx | 29 ++++++++++++++++++++++++++++- Source/cmGlobalVisualStudioGenerator.h | 14 +++++++++++++- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 84f8df1..5855177 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -42,18 +42,12 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = { cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( cmake* cm, std::string const& platformInGeneratorName) - : cmGlobalVisualStudioGenerator(cm) + : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName) { this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; this->MasmEnabled = false; this->NasmEnabled = false; - - if (platformInGeneratorName.empty()) { - this->DefaultPlatformName = "Win32"; - } else { - this->DefaultPlatformName = platformInGeneratorName; - } this->ExtraFlagTable = cmVS7ExtraFlagTable; } @@ -263,14 +257,6 @@ Json::Value cmGlobalVisualStudio7Generator::GetJson() const } #endif -std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const -{ - if (!this->GeneratorPlatform.empty()) { - return this->GeneratorPlatform; - } - return this->DefaultPlatformName; -} - bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, cmMakefile* mf) { @@ -279,18 +265,6 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); } -bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p, - cmMakefile* mf) -{ - if (this->GetPlatformName() == "x64") { - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - } else if (this->GetPlatformName() == "Itanium") { - mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); - } - mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); - return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf); -} - void cmGlobalVisualStudio7Generator::Generate() { // first do the superclass method diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 4240bd4..d2a2a38 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -20,9 +20,6 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator public: ~cmGlobalVisualStudio7Generator(); - ///! Get the name for the platform. - std::string const& GetPlatformName() const; - ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; @@ -32,8 +29,6 @@ public: bool SetSystemName(std::string const& s, cmMakefile* mf) override; - bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override; - /** * Utilized by the generator factory to determine if this generator * supports toolsets. @@ -167,8 +162,6 @@ protected: // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; - std::string GeneratorPlatform; - std::string DefaultPlatformName; bool MasmEnabled; bool NasmEnabled; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index adf0a81..4828c8a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -20,12 +20,19 @@ #include "cmState.h" #include "cmTarget.h" -cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) +cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator( + cmake* cm, std::string const& platformInGeneratorName) : cmGlobalGenerator(cm) { cm->GetState()->SetIsGeneratorMultiConfig(true); cm->GetState()->SetWindowsShell(true); cm->GetState()->SetWindowsVSIDE(true); + + if (platformInGeneratorName.empty()) { + this->DefaultPlatformName = "Win32"; + } else { + this->DefaultPlatformName = platformInGeneratorName; + } } cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator() @@ -43,6 +50,26 @@ void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v) this->Version = v; } +bool cmGlobalVisualStudioGenerator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if (this->GetPlatformName() == "x64") { + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + } else if (this->GetPlatformName() == "Itanium") { + mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); + } + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); + return this->cmGlobalGenerator::SetGeneratorPlatform(p, mf); +} + +std::string const& cmGlobalVisualStudioGenerator::GetPlatformName() const +{ + if (!this->GeneratorPlatform.empty()) { + return this->GeneratorPlatform; + } + return this->DefaultPlatformName; +} + const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const { switch (this->Version) { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index d827616..3909a26 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -49,6 +49,14 @@ public: /** Is the installed VS an Express edition? */ bool IsExpressEdition() const { return this->ExpressEdition; } + bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override; + + /** + * Get the name of the target platform (architecture) for which we generate. + * The names are as defined by VS, e.g. "Win32", "x64", "Itanium", "ARM". + */ + std::string const& GetPlatformName() const; + /** * Configure CMake's Visual Studio macros file into the user's Visual * Studio macros directory. @@ -132,7 +140,8 @@ public: bool dryRun) override; protected: - cmGlobalVisualStudioGenerator(cmake* cm); + cmGlobalVisualStudioGenerator(cmake* cm, + std::string const& platformInGeneratorName); void AddExtraIDETargets() override; @@ -167,6 +176,9 @@ protected: VSVersion Version; bool ExpressEdition; + std::string GeneratorPlatform; + std::string DefaultPlatformName; + private: virtual std::string GetVSMakeProgram() = 0; void PrintCompilerAdvice(std::ostream&, std::string const&, -- cgit v0.12