VS: Select WindowsPhone and WindowsStore default toolsets

Teach the VS >= 10 generators to recognize these system names and select
the appropriate default toolset for the system version.  Report an error
when the version is not known to be supported by VS.

Inspired-by: Gilles Khouzam <gillesk@microsoft.com>
This commit is contained in:
Brad King 2014-07-28 16:15:43 -04:00
parent 3abd150ce9
commit d7938bff37
6 changed files with 139 additions and 1 deletions

View File

@ -148,19 +148,45 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile*) bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
{ {
if(this->SystemName == "WindowsPhone") if(this->SystemName == "WindowsPhone")
{ {
this->SystemIsWindowsPhone = true; this->SystemIsWindowsPhone = true;
if(!this->InitializeWindowsPhone(mf))
{
return false;
}
} }
else if(this->SystemName == "WindowsStore") else if(this->SystemName == "WindowsStore")
{ {
this->SystemIsWindowsStore = true; this->SystemIsWindowsStore = true;
if(!this->InitializeWindowsStore(mf))
{
return false;
}
} }
return true; return true;
} }
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
{
cmOStringStream e;
e << this->GetName() << " does not support Windows Phone.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
{
cmOStringStream e;
e << this->GetName() << " does not support Windows Store.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator void cmGlobalVisualStudio10Generator
::AddVSPlatformToolsetDefinition(cmMakefile* mf) const ::AddVSPlatformToolsetDefinition(cmMakefile* mf) const

View File

@ -107,6 +107,10 @@ public:
protected: protected:
virtual void Generate(); virtual void Generate();
virtual bool InitializeSystem(cmMakefile* mf); virtual bool InitializeSystem(cmMakefile* mf);
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const { return ""; }
virtual std::string SelectWindowsStoreToolset() const { return ""; }
virtual const char* GetIDEVersion() { return "10.0"; } virtual const char* GetIDEVersion() { return "10.0"; }

View File

@ -128,6 +128,56 @@ cmGlobalVisualStudio11Generator::MatchesGeneratorName(
return false; return false;
} }
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsPhoneToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Phone '8.0', but not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsStoreToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Store '8.0', but not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset() const
{
if(this->SystemVersion == "8.0")
{
return "v110_wp80";
}
return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset();
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset() const
{
if(this->SystemVersion == "8.0")
{
return "v110";
}
return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -34,6 +34,10 @@ public:
/** TODO: VS 11 user macro support. */ /** TODO: VS 11 user macro support. */
virtual std::string GetUserMacrosDirectory() { return ""; } virtual std::string GetUserMacrosDirectory() { return ""; }
protected: protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const;
virtual std::string SelectWindowsStoreToolset() const;
virtual const char* GetIDEVersion() { return "11.0"; } virtual const char* GetIDEVersion() { return "11.0"; }
bool UseFolderProperty(); bool UseFolderProperty();
static std::set<std::string> GetInstalledWindowsCESDKs(); static std::set<std::string> GetInstalledWindowsCESDKs();

View File

@ -108,6 +108,56 @@ cmGlobalVisualStudio12Generator::MatchesGeneratorName(
return false; return false;
} }
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsPhoneToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Phone '8.0' and '8.1', "
"but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
{
this->DefaultPlatformToolset = this->SelectWindowsStoreToolset();
if(this->DefaultPlatformToolset.empty())
{
cmOStringStream e;
e << this->GetName() << " supports Windows Store '8.0' and '8.1', "
"but not '" << this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset() const
{
if(this->SystemVersion == "8.1")
{
return "v120_wp81";
}
return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset();
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset() const
{
if(this->SystemVersion == "8.1")
{
return "v120";
}
return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -39,6 +39,10 @@ public:
//version number //version number
virtual const char* GetToolsVersion() { return "12.0"; } virtual const char* GetToolsVersion() { return "12.0"; }
protected: protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
virtual std::string SelectWindowsPhoneToolset() const;
virtual std::string SelectWindowsStoreToolset() const;
virtual const char* GetIDEVersion() { return "12.0"; } virtual const char* GetIDEVersion() { return "12.0"; }
private: private:
class Factory; class Factory;