From d7938bff37bfa05f34b9ad5a46ae3aff54955eea Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Jul 2014 16:15:43 -0400 Subject: [PATCH] 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 --- Source/cmGlobalVisualStudio10Generator.cxx | 28 +++++++++++- Source/cmGlobalVisualStudio10Generator.h | 4 ++ Source/cmGlobalVisualStudio11Generator.cxx | 50 ++++++++++++++++++++++ Source/cmGlobalVisualStudio11Generator.h | 4 ++ Source/cmGlobalVisualStudio12Generator.cxx | 50 ++++++++++++++++++++++ Source/cmGlobalVisualStudio12Generator.h | 4 ++ 6 files changed, 139 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 5189569dc..c708a0824 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -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 diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index e3156bfa0..6245b285f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -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"; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index e5a159ba1..33cfaa187 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -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) { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 3d89a9408..0b497db4d 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -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 GetInstalledWindowsCESDKs(); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 4235cbc7c..29ecfe00b 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -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) { diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 8ac2d1d20..ec85f1011 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -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;