Commit 5a283b79 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'vs-refactor'

b91f6f39 VS: Track explicitly when platform is specified in generator name
89cc3d43 VS: Move platform name members to top-level global generator
40a73280 VS: Clarify global generator constructor interface
5ca7e505 Help: Document VS generator default platform selection
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2786
parents 73aca057 b91f6f39
Pipeline #127469 passed with stage
in 0 seconds
......@@ -15,6 +15,8 @@ projects (Database, Website, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -15,6 +15,8 @@ projects (JavaScript, Database, Website, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -15,6 +15,8 @@ projects (JavaScript, Powershell, Python, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -12,6 +12,8 @@ projects (JavaScript, Powershell, Python, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -28,6 +28,8 @@ by default.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -6,6 +6,8 @@ Generates Visual Studio 9 2008 project files.
Platform Selection
^^^^^^^^^^^^^^^^^^
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
......
......@@ -90,8 +90,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
}
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio8Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
{
std::string vc10Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
......@@ -406,7 +407,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
return false;
}
} else if (this->SystemName == "Android") {
if (this->DefaultPlatformName != "Win32") {
if (this->PlatformInGeneratorName) {
std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
......@@ -437,7 +438,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
{
if (this->DefaultPlatformName != "Win32") {
if (this->PlatformInGeneratorName) {
std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
......
......@@ -14,8 +14,6 @@
class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
{
public:
cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
bool MatchesGeneratorName(const std::string& name) const override;
......@@ -125,6 +123,9 @@ public:
cmIDEFlagTable const* GetNasmFlagTable() const;
protected:
cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
void Generate() override;
virtual bool InitializeSystem(cmMakefile* mf);
virtual bool InitializeWindows(cmMakefile* mf);
......@@ -168,6 +169,8 @@ protected:
private:
class Factory;
friend class Factory;
struct LongestSourcePath
{
LongestSourcePath()
......
......@@ -92,8 +92,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
}
cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio10Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio10Generator(cm, name, platformInGeneratorName)
{
std::string vc11Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
......
......@@ -20,13 +20,14 @@ class cmake;
class cmGlobalVisualStudio11Generator : public cmGlobalVisualStudio10Generator
{
public:
cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
bool MatchesGeneratorName(const std::string& name) const override;
protected:
cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool InitializeWindowsPhone(cmMakefile* mf) override;
bool InitializeWindowsStore(cmMakefile* mf) override;
bool SelectWindowsPhoneToolset(std::string& toolset) const override;
......
......@@ -75,8 +75,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
}
cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio11Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio11Generator(cm, name, platformInGeneratorName)
{
std::string vc12Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
......
......@@ -18,13 +18,14 @@ class cmake;
class cmGlobalVisualStudio12Generator : public cmGlobalVisualStudio11Generator
{
public:
cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
bool MatchesGeneratorName(const std::string& name) const override;
protected:
cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool ProcessGeneratorToolsetField(std::string const& key,
std::string const& value) override;
......@@ -44,5 +45,6 @@ protected:
private:
class Factory;
friend class Factory;
};
#endif
......@@ -75,8 +75,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
}
cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio12Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio12Generator(cm, name, platformInGeneratorName)
{
std::string vc14Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
......
......@@ -18,13 +18,14 @@ class cmake;
class cmGlobalVisualStudio14Generator : public cmGlobalVisualStudio12Generator
{
public:
cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
bool MatchesGeneratorName(const std::string& name) const override;
protected:
cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool InitializeWindows(cmMakefile* mf) override;
bool InitializeWindowsStore(cmMakefile* mf) override;
bool SelectWindowsStoreToolset(std::string& toolset) const override;
......@@ -47,5 +48,6 @@ protected:
private:
class Factory;
friend class Factory;
};
#endif
......@@ -76,8 +76,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio15Generator::NewFactory()
}
cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio14Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio14Generator(cm, name, platformInGeneratorName)
{
this->ExpressEdition = false;
this->DefaultPlatformToolset = "v141";
......
......@@ -18,8 +18,6 @@ class cmake;
class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator
{
public:
cmGlobalVisualStudio15Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
bool MatchesGeneratorName(const std::string& name) const override;
......@@ -32,6 +30,9 @@ public:
std::string GetAuxiliaryToolset() const override;
protected:
cmGlobalVisualStudio15Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool InitializeWindows(cmMakefile* mf) override;
bool SelectWindowsStoreToolset(std::string& toolset) const override;
......@@ -53,6 +54,7 @@ protected:
private:
class Factory;
friend class Factory;
mutable cmVSSetupAPIHelper vsSetupAPIHelper;
};
#endif
......@@ -41,19 +41,13 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
};
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
cmake* cm, const std::string& platformName)
: cmGlobalVisualStudioGenerator(cm)
cmake* cm, std::string const& platformInGeneratorName)
: cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
{
this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
this->MasmEnabled = false;
this->NasmEnabled = false;
if (platformName.empty()) {
this->DefaultPlatformName = "Win32";
} else {
this->DefaultPlatformName = platformName;
}
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
......
......@@ -18,13 +18,8 @@ struct cmIDEFlagTable;
class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
{
public:
cmGlobalVisualStudio7Generator(cmake* cm,
const std::string& platformName = "");
~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;
......@@ -34,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.
......@@ -110,6 +103,9 @@ public:
cmIDEFlagTable const* ExtraFlagTable;
protected:
cmGlobalVisualStudio7Generator(cmake* cm,
std::string const& platformInGeneratorName);
void Generate() override;
std::string const& GetDevEnvCommand();
......@@ -166,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;
......
......@@ -12,8 +12,9 @@
#include "cmake.h"
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio71Generator(cm, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio71Generator(cm, platformInGeneratorName)
{
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->Name = name;
......@@ -60,7 +61,7 @@ void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
cmMakefile* mf)
{
if (this->DefaultPlatformName == "Win32") {
if (!this->PlatformInGeneratorName) {
this->GeneratorPlatform = p;
return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf);
} else {
......
......@@ -13,9 +13,6 @@
class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
{
public:
cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
const std::string& platformName);
///! Get the name for the generator.
std::string GetName() const override { return this->Name; }
......@@ -45,6 +42,9 @@ public:
}
protected:
cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
void AddExtraIDETargets() override;
std::string FindDevEnvCommand() override;
......
......@@ -83,8 +83,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
}
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
cmake* cm, const std::string& name, const std::string& platformName)
: cmGlobalVisualStudio8Generator(cm, name, platformName)
cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
: cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
{
this->Version = VS9;
std::string vc9Express;
......
......@@ -13,8 +13,6 @@
class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator
{
public:
cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
/**
......@@ -30,6 +28,10 @@ public:
*/
std::string GetUserMacrosRegKeyBase() override;
protected:
cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
private:
class Factory;
friend class Factory;
......
......@@ -20,12 +20,20 @@
#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;
this->PlatformInGeneratorName = true;
}
}
cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
......@@ -43,6 +51,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) {
......
......@@ -41,7 +41,6 @@ public:
VS15 = 150
};
cmGlobalVisualStudioGenerator(cmake* cm);
virtual ~cmGlobalVisualStudioGenerator();
VSVersion GetVersion() const;
......@@ -50,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.
......@@ -133,6 +140,9 @@ public:
bool dryRun) override;
protected:
cmGlobalVisualStudioGenerator(cmake* cm,
std::string const& platformInGeneratorName);
void AddExtraIDETargets() override;
// Does this VS version link targets to each other if there are
......@@ -166,6 +176,10 @@ protected:
VSVersion Version;
bool ExpressEdition;
std::string GeneratorPlatform;
std::string DefaultPlatformName;
bool PlatformInGeneratorName = false;
private:
virtual std::string GetVSMakeProgram() = 0;
void PrintCompilerAdvice(std::ostream&, std::string const&,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment