Skip to content

Commit

Permalink
Merge topic 'vs-refactor'
Browse files Browse the repository at this point in the history
b91f6f3 VS: Track explicitly when platform is specified in generator name
89cc3d4 VS: Move platform name members to top-level global generator
40a7328 VS: Clarify global generator constructor interface
5ca7e50 Help: Document VS generator default platform selection

Acked-by: Kitware Robot <[email protected]>
Merge-request: !2786
  • Loading branch information
bradking authored and kwrobot committed Jan 11, 2019
2 parents 73aca05 + b91f6f3 commit 5a283b7
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 71 deletions.
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 10 2010.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 11 2012.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 12 2013.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 14 2015.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 15 2017.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Help/generator/Visual Studio 9 2008.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions Source/cmGlobalVisualStudio10Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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() << "'";
Expand Down Expand Up @@ -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() << "'";
Expand Down
7 changes: 5 additions & 2 deletions Source/cmGlobalVisualStudio10Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -125,6 +123,9 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
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);
Expand Down Expand Up @@ -168,6 +169,8 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator

private:
class Factory;
friend class Factory;

struct LongestSourcePath
{
LongestSourcePath()
Expand Down
5 changes: 3 additions & 2 deletions Source/cmGlobalVisualStudio11Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions Source/cmGlobalVisualStudio11Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions Source/cmGlobalVisualStudio12Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions Source/cmGlobalVisualStudio12Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -44,5 +45,6 @@ class cmGlobalVisualStudio12Generator : public cmGlobalVisualStudio11Generator

private:
class Factory;
friend class Factory;
};
#endif
5 changes: 3 additions & 2 deletions Source/cmGlobalVisualStudio14Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions Source/cmGlobalVisualStudio14Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,5 +48,6 @@ class cmGlobalVisualStudio14Generator : public cmGlobalVisualStudio12Generator

private:
class Factory;
friend class Factory;
};
#endif
5 changes: 3 additions & 2 deletions Source/cmGlobalVisualStudio15Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions Source/cmGlobalVisualStudio15Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +30,9 @@ class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator
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;

Expand All @@ -53,6 +54,7 @@ class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator

private:
class Factory;
friend class Factory;
mutable cmVSSetupAPIHelper vsSetupAPIHelper;
};
#endif
30 changes: 2 additions & 28 deletions Source/cmGlobalVisualStudio7Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
12 changes: 3 additions & 9 deletions Source/cmGlobalVisualStudio7Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -34,8 +29,6 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator

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.
Expand Down Expand Up @@ -110,6 +103,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
cmIDEFlagTable const* ExtraFlagTable;

protected:
cmGlobalVisualStudio7Generator(cmake* cm,
std::string const& platformInGeneratorName);

void Generate() override;

std::string const& GetDevEnvCommand();
Expand Down Expand Up @@ -166,8 +162,6 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
// 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;

Expand Down
7 changes: 4 additions & 3 deletions Source/cmGlobalVisualStudio8Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions Source/cmGlobalVisualStudio8Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -45,6 +42,9 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
}

protected:
cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);

void AddExtraIDETargets() override;

std::string FindDevEnvCommand() override;
Expand Down
Loading

0 comments on commit 5a283b7

Please sign in to comment.