From d1b87d72f964ae57966c5f02ee9e32236bd59338 Mon Sep 17 00:00:00 2001 From: Gilles Khouzam Date: Fri, 2 Oct 2015 11:34:55 -0700 Subject: [PATCH] VS: Select Windows 10 Store SDK and toolset for VS 2015 --- Source/cmGlobalVisualStudio14Generator.cxx | 63 ++++++++++++++++++++++ Source/cmGlobalVisualStudio14Generator.h | 7 +++ 2 files changed, 70 insertions(+) diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 661dddd88..41825fb15 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -120,6 +120,34 @@ bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf) return true; } +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf) +{ + std::ostringstream e; + if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) + { + if(this->DefaultPlatformToolset.empty()) + { + e << this->GetName() << " supports Windows Store '8.0', '8.1' and " + "'10.0', but not '" << this->SystemVersion << + "'. Check CMAKE_SYSTEM_VERSION."; + } + else + { + e << "A Windows Store component with CMake requires both the Windows " + << "Desktop SDK as well as the Windows Store '" << this->SystemVersion + << "' SDK. Please make sure that you have both installed"; + } + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) + { + return this->SelectWindows10SDK(mf); + } + return true; +} + //---------------------------------------------------------------------------- bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf) { @@ -138,6 +166,28 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf) return true; } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset( + std::string& toolset) const +{ + if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) + { + if (this->IsWindowsStoreToolsetInstalled() && + this->IsWindowsDesktopToolsetInstalled()) + { + toolset = "v140"; + return true; + } + else + { + return false; + } + } + return + this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(toolset); +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout) { @@ -166,6 +216,19 @@ cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const vc14, cmSystemTools::KeyWOW64_32); } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const +{ + const char universal10Key[] = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;SrcPath"; + + std::string win10SDK; + return cmSystemTools::ReadRegistryValue(universal10Key, + win10SDK, cmSystemTools::KeyWOW64_32); +} + //---------------------------------------------------------------------------- std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() { diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index fcade852c..76c15d99c 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -31,6 +31,13 @@ public: virtual const char* GetToolsVersion() { return "14.0"; } protected: virtual bool InitializeWindows(cmMakefile* mf); + virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool SelectWindowsStoreToolset(std::string& toolset) const; + + // These aren't virtual because we need to check if the selected version + // of the toolset is installed + bool IsWindowsStoreToolsetInstalled() const; + virtual const char* GetIDEVersion() { return "14.0"; } virtual bool SelectWindows10SDK(cmMakefile* mf);