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).
This commit is contained in:
Brad King 2019-01-10 08:43:29 -05:00
parent 40a732800d
commit 89cc3d432b
4 changed files with 42 additions and 36 deletions

View File

@ -42,18 +42,12 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
cmake* cm, std::string const& platformInGeneratorName) cmake* cm, std::string const& platformInGeneratorName)
: cmGlobalVisualStudioGenerator(cm) : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
{ {
this->IntelProjectVersion = 0; this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false; this->DevEnvCommandInitialized = false;
this->MasmEnabled = false; this->MasmEnabled = false;
this->NasmEnabled = false; this->NasmEnabled = false;
if (platformInGeneratorName.empty()) {
this->DefaultPlatformName = "Win32";
} else {
this->DefaultPlatformName = platformInGeneratorName;
}
this->ExtraFlagTable = cmVS7ExtraFlagTable; this->ExtraFlagTable = cmVS7ExtraFlagTable;
} }
@ -263,14 +257,6 @@ Json::Value cmGlobalVisualStudio7Generator::GetJson() const
} }
#endif #endif
std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const
{
if (!this->GeneratorPlatform.empty()) {
return this->GeneratorPlatform;
}
return this->DefaultPlatformName;
}
bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
cmMakefile* mf) cmMakefile* mf)
{ {
@ -279,18 +265,6 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); 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() void cmGlobalVisualStudio7Generator::Generate()
{ {
// first do the superclass method // first do the superclass method

View File

@ -20,9 +20,6 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
public: public:
~cmGlobalVisualStudio7Generator(); ~cmGlobalVisualStudio7Generator();
///! Get the name for the platform.
std::string const& GetPlatformName() const;
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
@ -32,8 +29,6 @@ public:
bool SetSystemName(std::string const& s, cmMakefile* mf) override; 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 * Utilized by the generator factory to determine if this generator
* supports toolsets. * supports toolsets.
@ -167,8 +162,6 @@ protected:
// Set during OutputSLNFile with the name of the current project. // Set during OutputSLNFile with the name of the current project.
// There is one SLN file per project. // There is one SLN file per project.
std::string CurrentProject; std::string CurrentProject;
std::string GeneratorPlatform;
std::string DefaultPlatformName;
bool MasmEnabled; bool MasmEnabled;
bool NasmEnabled; bool NasmEnabled;

View File

@ -20,12 +20,19 @@
#include "cmState.h" #include "cmState.h"
#include "cmTarget.h" #include "cmTarget.h"
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(
cmake* cm, std::string const& platformInGeneratorName)
: cmGlobalGenerator(cm) : cmGlobalGenerator(cm)
{ {
cm->GetState()->SetIsGeneratorMultiConfig(true); cm->GetState()->SetIsGeneratorMultiConfig(true);
cm->GetState()->SetWindowsShell(true); cm->GetState()->SetWindowsShell(true);
cm->GetState()->SetWindowsVSIDE(true); cm->GetState()->SetWindowsVSIDE(true);
if (platformInGeneratorName.empty()) {
this->DefaultPlatformName = "Win32";
} else {
this->DefaultPlatformName = platformInGeneratorName;
}
} }
cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator() cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
@ -43,6 +50,26 @@ void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
this->Version = 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 const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const
{ {
switch (this->Version) { switch (this->Version) {

View File

@ -49,6 +49,14 @@ public:
/** Is the installed VS an Express edition? */ /** Is the installed VS an Express edition? */
bool IsExpressEdition() const { return this->ExpressEdition; } 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 * Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory. * Studio macros directory.
@ -132,7 +140,8 @@ public:
bool dryRun) override; bool dryRun) override;
protected: protected:
cmGlobalVisualStudioGenerator(cmake* cm); cmGlobalVisualStudioGenerator(cmake* cm,
std::string const& platformInGeneratorName);
void AddExtraIDETargets() override; void AddExtraIDETargets() override;
@ -167,6 +176,9 @@ protected:
VSVersion Version; VSVersion Version;
bool ExpressEdition; bool ExpressEdition;
std::string GeneratorPlatform;
std::string DefaultPlatformName;
private: private:
virtual std::string GetVSMakeProgram() = 0; virtual std::string GetVSMakeProgram() = 0;
void PrintCompilerAdvice(std::ostream&, std::string const&, void PrintCompilerAdvice(std::ostream&, std::string const&,