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")
{
this->SystemIsWindowsPhone = true;
if(!this->InitializeWindowsPhone(mf))
{
return false;
}
}
else if(this->SystemName == "WindowsStore")
{
this->SystemIsWindowsStore = true;
if(!this->InitializeWindowsStore(mf))
{
return false;
}
}
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
::AddVSPlatformToolsetDefinition(cmMakefile* mf) const

View File

@ -107,6 +107,10 @@ public:
protected:
virtual void Generate();
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"; }

View File

@ -128,6 +128,56 @@ cmGlobalVisualStudio11Generator::MatchesGeneratorName(
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)
{

View File

@ -34,6 +34,10 @@ public:
/** TODO: VS 11 user macro support. */
virtual std::string GetUserMacrosDirectory() { return ""; }
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"; }
bool UseFolderProperty();
static std::set<std::string> GetInstalledWindowsCESDKs();

View File

@ -108,6 +108,56 @@ cmGlobalVisualStudio12Generator::MatchesGeneratorName(
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)
{

View File

@ -39,6 +39,10 @@ public:
//version number
virtual const char* GetToolsVersion() { return "12.0"; }
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"; }
private:
class Factory;