From 25c4b7b88120f518d6df82ca55679095a55536e1 Mon Sep 17 00:00:00 2001
From: Gilles Khouzam <gillesk@microsoft.com>
Date: Fri, 2 Oct 2015 11:34:55 -0700
Subject: [PATCH] This change adds support for Windows 10 Universal (Store)
 Applications.

A Windows 10 Universal Application can be targeted by setting:
CMAKE_SYSTEM_NAME=WindowsStore and CMAKE_SYSTEM_VERSION=10.0
There are no WindowsPhone apps, universal apps target both phone and store.
Specifying the CMAKE_SYSTEM_VERSION to be 10.0 will use the latest Windows
10 SDK installed. If you want to specify a specific SDK, you can make
CMAKE_SYSTEM_VERSION to be more specific (10.0.10240.0 for RTM for example).


New Properties Added:
VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION: Target Property.
Specifies the minimum version of the OS that the project can target.

VS_DESKTOP_EXTENSIONS_VERSION, VS_MOBILE_EXTENSIONS_VERSIONS,
VS_IOT_EXTENSIONS_VERSION: Target property. When specifying these properties
a reference to the version of the SDK specified will be added to the
target allowing to target the extended functionality in a universal project.
To match the version of the SDK being used, use
CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION

VS_IOT_STARTUP_TASK: Target property. Specifies that the target should be
built as an IOT continuous background task.
---
 Help/manual/cmake-properties.7.rst                 |   5 +
 Help/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION.rst    |  10 +
 Help/prop_tgt/VS_IOT_EXTENSIONS_VERSION.rst        |  11 +
 Help/prop_tgt/VS_IOT_STARTUP_TASK.rst              |   6 +
 Help/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION.rst     |  11 +
 .../VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION.rst     |  10 +
 Modules/Platform/Windows-MSVC.cmake                |   5 +-
 Source/cmGlobalVisualStudio14Generator.cxx         |  84 +++++++-
 Source/cmGlobalVisualStudio14Generator.h           |   7 +
 Source/cmVisualStudio10TargetGenerator.cxx         | 228 ++++++++++++++++++++-
 Source/cmVisualStudio10TargetGenerator.h           |   7 +
 Templates/Windows/SmallLogo44x44.png               | Bin 0 -> 554 bytes
 Tests/CMakeLists.txt                               |   9 +-
 Tests/VSWinStorePhone/CMakeLists.txt               |  17 +-
 .../Direct3DApp1/Assets/SmallLogo44x44.png         | Bin 0 -> 554 bytes
 .../cmake/Package_vc14.store.appxmanifest.in       |  36 ++++
 16 files changed, 427 insertions(+), 19 deletions(-)
 create mode 100644 Help/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION.rst
 create mode 100644 Help/prop_tgt/VS_IOT_EXTENSIONS_VERSION.rst
 create mode 100644 Help/prop_tgt/VS_IOT_STARTUP_TASK.rst
 create mode 100644 Help/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION.rst
 create mode 100644 Help/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION.rst
 create mode 100644 Templates/Windows/SmallLogo44x44.png
 create mode 100644 Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
 create mode 100644 Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index ac893c2..931363c 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -254,17 +254,22 @@ Properties on Targets
    /prop_tgt/TYPE
    /prop_tgt/VERSION
    /prop_tgt/VISIBILITY_INLINES_HIDDEN
+   /prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
    /prop_tgt/VS_DOTNET_REFERENCES
    /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
    /prop_tgt/VS_GLOBAL_KEYWORD
    /prop_tgt/VS_GLOBAL_PROJECT_TYPES
    /prop_tgt/VS_GLOBAL_ROOTNAMESPACE
    /prop_tgt/VS_GLOBAL_variable
+   /prop_tgt/VS_IOT_EXTENSIONS_VERSION
+   /prop_tgt/VS_IOT_STARTUP_TASK
    /prop_tgt/VS_KEYWORD
+   /prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
    /prop_tgt/VS_SCC_AUXPATH
    /prop_tgt/VS_SCC_LOCALPATH
    /prop_tgt/VS_SCC_PROJECTNAME
    /prop_tgt/VS_SCC_PROVIDER
+   /prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
    /prop_tgt/VS_WINRT_COMPONENT
    /prop_tgt/VS_WINRT_EXTENSIONS
    /prop_tgt/VS_WINRT_REFERENCES
diff --git a/Help/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION.rst b/Help/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION.rst
new file mode 100644
index 0000000..64154f4
--- /dev/null
+++ b/Help/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION.rst
@@ -0,0 +1,10 @@
+VS_DESKTOP_EXTENSIONS_VERSION
+-----------------------------
+
+Visual Studio Windows 10 Desktop Extensions Version
+
+Specifies the version of the Desktop Extensions that should be included in the
+target. For example 1.0.10240.0. If the value is not specified, the Desktop
+Extensions will not be included. To use the same version of the extensions as
+the Windows 10 SDK that is being used, you can use the
+`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable.
diff --git a/Help/prop_tgt/VS_IOT_EXTENSIONS_VERSION.rst b/Help/prop_tgt/VS_IOT_EXTENSIONS_VERSION.rst
new file mode 100644
index 0000000..9be4588
--- /dev/null
+++ b/Help/prop_tgt/VS_IOT_EXTENSIONS_VERSION.rst
@@ -0,0 +1,11 @@
+VS_IOT_EXTENSIONS_VERSION
+-------------------------
+
+Visual Studio Windows 10 IoT Extensions Version
+
+Specifies the version of the IoT Extensions that should be included in the
+target. For example 1.0.10240.0. If the value is not specified, the IoT
+Extensions will not be included. To use the same version of the extensions as
+the Windows 10 SDK that is being used, you can use the
+`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable.
+
diff --git a/Help/prop_tgt/VS_IOT_STARTUP_TASK.rst b/Help/prop_tgt/VS_IOT_STARTUP_TASK.rst
new file mode 100644
index 0000000..add50cb
--- /dev/null
+++ b/Help/prop_tgt/VS_IOT_STARTUP_TASK.rst
@@ -0,0 +1,6 @@
+VS_IOT_STARTUP_TASK
+-------------------
+
+Visual Studio Windows 10 IoT Continuous Background Task
+
+Specifies that the target should be compiled as a Continuous Background Task library.
diff --git a/Help/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION.rst b/Help/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION.rst
new file mode 100644
index 0000000..65f1370
--- /dev/null
+++ b/Help/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION.rst
@@ -0,0 +1,11 @@
+VS_MOBILE_EXTENSIONS_VERSION
+----------------------------
+
+Visual Studio Windows 10 Mobile Extensions Version
+
+Specifies the version of the Mobile Extensions that should be included in the
+target. For example 1.0.10240.0. If the value is not specified, the Mobile
+Extensions will not be included. To use the same version of the extensions as
+the Windows 10 SDK that is being used, you can use the
+`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable.
+
diff --git a/Help/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION.rst b/Help/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION.rst
new file mode 100644
index 0000000..ffe3770
--- /dev/null
+++ b/Help/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION.rst
@@ -0,0 +1,10 @@
+VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
+--------------------------------------
+
+Visual Studio Windows Target Platform Minimum Version
+
+For Windows 10. Specifies the minimum version of the OS that is being
+targeted. For example 1.0.10240.0. If the value is not specified, the
+value of `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` will be used on
+WindowsStore projects otherwise the target platform minimum version will not
+be specified for the project.
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 8594596..e745209 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -179,7 +179,10 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE)
   set(_PLATFORM_DEFINES "/DWIN32")
   set(_FLAGS_C " /DUNICODE /D_UNICODE")
   set(_FLAGS_CXX " /DUNICODE /D_UNICODE /GR /EHsc")
-  if(WINDOWS_PHONE)
+  if(WINDOWS_STORE AND MSVC_VERSION GREATER 1899)
+    # if WINDOWS_STORE, greater than MSVC 1899, then this is a Universal Application Platform project
+    set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsApp.lib")
+  elseif(WINDOWS_PHONE)
     set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib")
   elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
     set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 74679d8..ccc68c0 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -121,6 +121,34 @@ bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
 }
 
 //----------------------------------------------------------------------------
+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)
 {
   // Find the default version of the Windows 10 SDK.
@@ -139,6 +167,28 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
 }
 
 //----------------------------------------------------------------------------
+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)
 {
   // Visual Studio 14 writes .sln format 12.00
@@ -167,6 +217,19 @@ cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const
 }
 
 //----------------------------------------------------------------------------
+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()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -202,14 +265,23 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
     // has a version less or equal to our version of the operating system
     std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
 
-    for (std::vector<std::string>::iterator i = sdks.begin();
-         i != sdks.end(); ++i)
+    // If we specify simply Windows 10.0 for a store app. Use the latest
+    // Windows 10 SDK.
+    if (this->SystemName == "WindowsStore" && this->SystemVersion == "10.0")
+      {
+      return sdks.at(0);
+      }
+    else
       {
-      // Find the SDK less or equal to our specified version
-      if (!cmSystemTools::VersionCompareGreater(*i, this->SystemVersion))
+      for (std::vector<std::string>::iterator i = sdks.begin();
+           i != sdks.end(); ++i)
         {
-        // This is the most recent SDK that we can run safely
-        return *i;
+        // Find the SDK less or equal to our specified version
+        if (!cmSystemTools::VersionCompareGreater(*i, this->SystemVersion))
+          {
+          // This is the most recent SDK that we can run safely
+          return *i;
+          }
         }
       }
     }
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index fcade85..76c15d9 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);
 
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 6093f6c..06e871c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -463,6 +463,7 @@ void cmVisualStudio10TargetGenerator::Generate()
   this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
                     " Condition=\"exists('" VS10_USER_PROPS "')\""
                     " Label=\"LocalAppDataPlatform\" />\n", 2);
+  this->WritePlatformExtensions();
   this->WriteString("</ImportGroup>\n", 1);
   this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
   this->WriteWinRTPackageCertificateKeyFile();
@@ -475,6 +476,7 @@ void cmVisualStudio10TargetGenerator::Generate()
   this->WriteXamlFilesGroup();
   this->WriteWinRTReferences();
   this->WriteProjectReferences();
+  this->WriteSDKReferences();
   this->WriteString(
     "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
     " />\n", 1);
@@ -1307,6 +1309,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
     {
     tool = "XML";
     }
+
   if(this->NsightTegra)
     {
     // Nsight Tegra needs specific file types to check up-to-dateness.
@@ -2590,7 +2593,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
 
     // A Windows Runtime component uses internal .NET metadata,
     // so does not have an import library.
-    if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT"))
+    if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") &&
+       this->Target->GetType() != cmTarget::EXECUTABLE)
       {
       linkOptions.AddFlag("GenerateWindowsMetadata", "true");
       }
@@ -2661,7 +2665,7 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
     {
     this->WriteString("<ProjectReference>\n", 2);
     this->WriteString(
-      "  <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
+      "<LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 3);
     this->WriteString("</ProjectReference>\n", 2);
     }
 }
@@ -2896,6 +2900,101 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
   this->WriteString("</ItemGroup>\n", 1);
 }
 
+void cmVisualStudio10TargetGenerator::WritePlatformExtensions()
+{
+  // This only applies to Windows 10 apps
+  if (this->GlobalGenerator->TargetsWindowsStore() &&
+      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0"))
+    {
+    const char* desktopExtensionsVersion =
+      this->Target->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
+    if (desktopExtensionsVersion)
+      {
+      this->WriteSinglePlatformExtension("WindowsDesktop",
+                                         desktopExtensionsVersion);
+      }
+    const char* mobileExtensionsVersion =
+      this->Target->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
+    if (mobileExtensionsVersion)
+      {
+      this->WriteSinglePlatformExtension("WindowsMobile",
+                                         mobileExtensionsVersion);
+      }
+    }
+}
+
+void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension(
+  std::string const& extension,
+  std::string const& version
+  )
+{
+      this->WriteString("<Import Project=", 2);
+      (*this->BuildFileStream)
+        << "\"$([Microsoft.Build.Utilities.ToolLocationHelper]"
+        << "::GetPlatformExtensionSDKLocation(`"
+        << extension <<", Version=" << version
+        << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
+        << "$(ExtensionSDKDirectoryRoot), null))"
+        << "\\DesignTime\\CommonConfiguration\\Neutral\\"
+        << extension << ".props\" "
+        << "Condition=\"exists('$("
+        << "[Microsoft.Build.Utilities.ToolLocationHelper]"
+        << "::GetPlatformExtensionSDKLocation(`"
+        << extension << ", Version=" << version
+        << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
+        << "$(ExtensionSDKDirectoryRoot), null))"
+        << "\\DesignTime\\CommonConfiguration\\Neutral\\"
+        << extension << ".props')\" />\n";
+}
+
+void cmVisualStudio10TargetGenerator::WriteSDKReferences()
+{
+  // This only applies to Windows 10 apps
+  if (this->GlobalGenerator->TargetsWindowsStore() &&
+      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0"))
+    {
+    const char* desktopExtensionsVersion =
+      this->Target->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
+    const char* mobileExtensionsVersion =
+      this->Target->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
+    const char* iotExtensionsVersion =
+      this->Target->GetProperty("VS_IOT_EXTENSIONS_VERSION");
+
+    if(desktopExtensionsVersion || mobileExtensionsVersion ||
+       iotExtensionsVersion)
+      {
+      this->WriteString("<ItemGroup>\n", 1);
+      if(desktopExtensionsVersion)
+        {
+        this->WriteSingleSDKReference("WindowsDesktop",
+                                      desktopExtensionsVersion);
+        }
+      if(mobileExtensionsVersion)
+        {
+        this->WriteSingleSDKReference("WindowsMobile",
+                                      mobileExtensionsVersion);
+        }
+      if(iotExtensionsVersion)
+        {
+        this->WriteSingleSDKReference("WindowsIoT",
+                                      iotExtensionsVersion);
+        }
+      this->WriteString("</ItemGroup>\n", 1);
+      }
+    }
+}
+
+void cmVisualStudio10TargetGenerator::WriteSingleSDKReference(
+  std::string const& extension,
+  std::string const& version
+  )
+{
+  this->WriteString("<SDKReference Include=\"", 2);
+  (*this->BuildFileStream) << extension
+    << ", Version=" << version << "\" />\n";
+}
+
+
 void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
 {
   if((this->GlobalGenerator->TargetsWindowsStore() ||
@@ -3018,13 +3117,27 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
     (*this->BuildFileStream) << (isWindowsPhone ?
                                  "Windows Phone" : "Windows Store")
                              << "</ApplicationType>\n";
-    this->WriteString("<ApplicationTypeRevision>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(v)
-                             << "</ApplicationTypeRevision>\n";
     this->WriteString("<DefaultLanguage>en-US"
                       "</DefaultLanguage>\n", 2);
-    if(v == "8.1")
+    if (cmHasLiteralPrefix(v, "10.0"))
+      {
+      this->WriteString("<ApplicationTypeRevision>", 2);
+      (*this->BuildFileStream) << cmVS10EscapeXML("10.0")
+                               << "</ApplicationTypeRevision>\n";
+      // Visual Studio 14.0 is necessary for building 10.0 apps
+      this->WriteString("<MinimumVisualStudioVersion>14.0"
+        "</MinimumVisualStudioVersion>\n", 2);
+
+      if(this->Target->GetType() < cmTarget::UTILITY)
+        {
+        isAppContainer = true;
+        }
+      }
+    else if(v == "8.1")
       {
+      this->WriteString("<ApplicationTypeRevision>", 2);
+      (*this->BuildFileStream) << cmVS10EscapeXML(v)
+                               << "</ApplicationTypeRevision>\n";
       // Visual Studio 12.0 is necessary for building 8.1 apps
       this->WriteString("<MinimumVisualStudioVersion>12.0"
                         "</MinimumVisualStudioVersion>\n", 2);
@@ -3036,6 +3149,9 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
       }
     else if (v == "8.0")
       {
+      this->WriteString("<ApplicationTypeRevision>", 2);
+      (*this->BuildFileStream) << cmVS10EscapeXML(v)
+                               << "</ApplicationTypeRevision>\n";
       // Visual Studio 11.0 is necessary for building 8.0 apps
       this->WriteString("<MinimumVisualStudioVersion>11.0"
                         "</MinimumVisualStudioVersion>\n", 2);
@@ -3072,6 +3188,30 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
     (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
       "</WindowsTargetPlatformVersion>\n";
     }
+  const char* targetPlatformMinVersion =
+      this->Target->GetProperty("VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
+  if(targetPlatformMinVersion)
+    {
+    this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
+    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion) <<
+      "</WindowsTargetPlatformMinVersion>\n";
+    }
+  else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0"))
+    {
+    // If the min version is not set, then use the TargetPlatformVersion
+    if (!targetPlatformVersion.empty())
+      {
+      this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
+      (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
+        "</WindowsTargetPlatformMinVersion>\n";
+      }
+    }
+
+  // Added IoT Startup Task support
+  if(this->Target->GetPropertyAsBool("VS_IOT_STARTUP_TASK"))
+    {
+    this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2);
+    }
 }
 
 void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
@@ -3124,7 +3264,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
             {
             this->IsMissingFiles = true;
             }
-          else if (v == "8.1")
+          else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0"))
             {
             this->IsMissingFiles = true;
             }
@@ -3158,6 +3298,10 @@ void cmVisualStudio10TargetGenerator::WriteMissingFiles()
      {
      this->WriteMissingFilesWS81();
      }
+   else if (cmHasLiteralPrefix(v, "10.0"))
+     {
+     this->WriteMissingFilesWS10_0();
+     }
    }
 }
 
@@ -3363,7 +3507,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
 }
 
 void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
-{
+  {
   std::string manifestFile =
     this->DefaultArtifactDir + "/package.appxManifest";
   std::string artifactDir =
@@ -3417,7 +3561,65 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
     "</Package>\n";
 
   this->WriteCommonMissingFiles(manifestFile);
-}
+  }
+
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
+  {
+  std::string manifestFile =
+    this->DefaultArtifactDir + "/package.appxManifest";
+  std::string artifactDir =
+    this->LocalGenerator->GetTargetDirectory(*this->Target);
+  this->ConvertToWindowsSlash(artifactDir);
+  std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
+  std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
+
+  cmGeneratedFileStream fout(manifestFile.c_str());
+  fout.SetCopyIfDifferent(true);
+
+  fout <<
+    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+    "<Package\n\t"
+    "xmlns=\"http://schemas.microsoft.com/appx/manifest/foundation/windows10\""
+    "\txmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\"\n"
+    "\txmlns:uap=\"http://schemas.microsoft.com/appx/manifest/uap/windows10\""
+    "\n\tIgnorableNamespaces=\"uap mp\">\n\n"
+    "\t<Identity Name=\"" << this->GUID << "\" Publisher=\"CN=CMake\""
+    " Version=\"1.0.0.0\" />\n"
+    "\t<mp:PhoneIdentity PhoneProductId=\"" << this->GUID << 
+    "\" PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>\n"
+    "\t<Properties>\n"
+    "\t\t<DisplayName>" << targetNameXML << "</DisplayName>\n"
+    "\t\t<PublisherDisplayName>CMake</PublisherDisplayName>\n"
+    "\t\t<Logo>" << artifactDirXML << "\\StoreLogo.png</Logo>\n"
+    "\t</Properties>\n"
+    "\t<Dependencies>\n"
+    "\t\t<TargetDeviceFamily Name=\"Windows.Universal\" "
+    "MinVersion=\"10.0.0.0\" MaxVersionTested=\"10.0.0.0\" />\n"
+    "\t</Dependencies>\n"
+
+    "\t<Resources>\n"
+    "\t\t<Resource Language=\"x-generate\" />\n"
+    "\t</Resources>\n"
+    "\t<Applications>\n"
+    "\t\t<Application Id=\"App\""
+    " Executable=\"" << targetNameXML << ".exe\""
+    " EntryPoint=\"" << targetNameXML << ".App\">\n"
+    "\t\t\t<uap:VisualElements\n"
+    "\t\t\t\tDisplayName=\"" << targetNameXML << "\"\n"
+    "\t\t\t\tDescription=\"" << targetNameXML << "\"\n"
+    "\t\t\t\tBackgroundColor=\"#336699\"\n"
+    "\t\t\t\tSquare150x150Logo=\"" << artifactDirXML << "\\Logo.png\"\n"
+    "\t\t\t\tSquare44x44Logo=\"" << artifactDirXML <<
+    "\\SmallLogo44x44.png\">\n"
+    "\t\t\t\t<uap:SplashScreen"
+    " Image=\"" << artifactDirXML << "\\SplashScreen.png\" />\n"
+    "\t\t\t</uap:VisualElements>\n"
+    "\t\t</Application>\n"
+    "\t</Applications>\n"
+    "</Package>\n";
+
+  this->WriteCommonMissingFiles(manifestFile);
+  }
 
 void
 cmVisualStudio10TargetGenerator
@@ -3442,6 +3644,14 @@ cmVisualStudio10TargetGenerator
   (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
   this->AddedFiles.push_back(smallLogo);
 
+  std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png";
+  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png",
+                           smallLogo44, false);
+  this->ConvertToWindowsSlash(smallLogo44);
+  this->WriteString("<Image Include=\"", 2);
+  (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo44) << "\" />\n";
+  this->AddedFiles.push_back(smallLogo44);
+
   std::string logo = this->DefaultArtifactDir + "/Logo.png";
   cmSystemTools::CopyAFile(templateFolder + "/Logo.png",
                            logo, false);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index f2aaf05..15ed9f2 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -78,6 +78,13 @@ private:
   void WriteMissingFilesWP81();
   void WriteMissingFilesWS80();
   void WriteMissingFilesWS81();
+  void WriteMissingFilesWS10_0();
+  void WritePlatformExtensions();
+  void WriteSinglePlatformExtension(std::string const& extension,
+                                    std::string const& version);
+  void WriteSDKReferences();
+  void WriteSingleSDKReference(std::string const& extension,
+                               std::string const& version);
   void WriteCommonMissingFiles(const std::string& manifestFile);
   void WriteTargetSpecificReferences();
 
diff --git a/Templates/Windows/SmallLogo44x44.png b/Templates/Windows/SmallLogo44x44.png
new file mode 100644
index 0000000000000000000000000000000000000000..28810b7c0e16d80e40477bc1c8afacc7f680bc5b
GIT binary patch
literal 554
zcmV+_0@eMAP)<h;3K|Lk000e1NJLTq001li001lq1^@s69)wx}00001b5ch_0Itp)
z=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc02p*dSaefwW^{L9
za%BK;VQFr3E^cLXAT%y8E;js(W8VM(0h>ugK~z{r?b+LHgFq04VO~;mct{GNhol6c
z0cvqdaL$QlB*fxncJ^YU@Jk584(4-YS(ejXT}7Jb`TmNV@WOOpnx@-0jvv^+KVy@7
z-%MZ({>b3hFbr?9)GXeU_g-6MDU6GFb)R|x_bt(Dtn6tyd`tA(3tOPK_gt2R$32f_
zBus{TK5mKL!}2^H+rg{_`Vp4lI1S8dqGMQwbLn7K1AT;LIPU|ql4uK-Va*R_CD2wZ
z!+IW=<)Blr3^Vy)=0T@o8Rp7>Sqj>NWtc4oW)`#;%P?OS%wp&qEW<VB!E6s5dm+|v
zT^%r61M#)+o0~kJ3(IKXbI4(s+`t89gsq@|a4(k8!sn60FuBqH02795&+(R6W4Y(?
z-Z>dJhwI9NW3cVo(?8ZMf5jX$=F5RCSj~&ZY#DG0R`Z}Smk;(}wNx}_^1wM*Ed`Br
zKez-|v!b!)1DC{V7BtSMgKJ>5BQ(yXfoo#57#hcRa0{&V2#v=!a7(PVhsORGe7c`o
s@wM<=KWNL~dH!YaiktARuEM(R7rj@P2Nbm}mjD0&07*qoM6N<$g6uH!wEzGB

literal 0
HcmV?d00001

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index dc65a2e..c82cb68 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1955,13 +1955,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
     set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
     set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
+    set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]")
     set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
     set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
+    set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
     set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
     set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
     select_wince_sdk(reg_wince wince_sdk)
     set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
-    foreach(reg vs10 vs11 vs12 ws80 ws81 wp80 wp81 wince tegra)
+    foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra)
       get_filename_component(r "${reg_${reg}}" ABSOLUTE)
       if(IS_DIRECTORY "${r}")
         set(${reg} 1)
@@ -2008,6 +2010,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
                           -DCMAKE_SYSTEM_VERSION=8.1
         )
     endif()
+    if(vs14 AND ws10_0)
+      add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0)
+      add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015 ARM" WindowsStore 10.0)
+      add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015 Win64" WindowsStore 10.0)
+    endif()
     if(vs11 AND wp80)
       add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0)
       add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0)
diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt
index 8357d5f..ae82755 100644
--- a/Tests/VSWinStorePhone/CMakeLists.txt
+++ b/Tests/VSWinStorePhone/CMakeLists.txt
@@ -1,7 +1,8 @@
 cmake_minimum_required(VERSION 3.0)
 project(VSWinStorePhone)
-
-if(MSVC_VERSION GREATER 1700)
+if(MSVC_VERSION GREATER 1899)
+  set(COMPILER_VERSION "14")
+elseif(MSVC_VERSION GREATER 1700)
   set(COMPILER_VERSION "12")
 elseif(MSVC_VERSION GREATER 1600)
   set(COMPILER_VERSION "11")
@@ -91,6 +92,7 @@ elseif (NOT "${PLATFORM}" STREQUAL "DESKTOP")
     set(ASSET_FILES ${ASSET_FILES}
     Direct3DApp1/Assets/Logo.png
     Direct3DApp1/Assets/SmallLogo.png
+    Direct3DApp1/Assets/SmallLogo44x44.png
     Direct3DApp1/Assets/SplashScreen.png
     Direct3DApp1/Assets/StoreLogo.png
     )
@@ -124,4 +126,15 @@ source_group("Resource Files" FILES ${RESOURCE_FILES})
 
 add_executable(${EXE_NAME} WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES})
 set_property(TARGET ${EXE_NAME} PROPERTY VS_WINRT_COMPONENT TRUE)
+
+string(SUBSTRING "${CMAKE_SYSTEM_VERSION}" 0, 4, SHORT_VERSION)
+
+if("${SHORT_VERSION}" STREQUAL "10.0")
+  message(STATUS "Targeting Windows 10. Setting Extensions to version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+  set_property(TARGET ${EXE_NAME} PROPERTY VS_DESKTOP_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+  set_property(TARGET ${EXE_NAME} PROPERTY VS_MOBILE_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+  set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+endif()
+
+
 target_link_libraries(${EXE_NAME} d3d11)
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
new file mode 100644
index 0000000000000000000000000000000000000000..28810b7c0e16d80e40477bc1c8afacc7f680bc5b
GIT binary patch
literal 554
zcmV+_0@eMAP)<h;3K|Lk000e1NJLTq001li001lq1^@s69)wx}00001b5ch_0Itp)
z=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc02p*dSaefwW^{L9
za%BK;VQFr3E^cLXAT%y8E;js(W8VM(0h>ugK~z{r?b+LHgFq04VO~;mct{GNhol6c
z0cvqdaL$QlB*fxncJ^YU@Jk584(4-YS(ejXT}7Jb`TmNV@WOOpnx@-0jvv^+KVy@7
z-%MZ({>b3hFbr?9)GXeU_g-6MDU6GFb)R|x_bt(Dtn6tyd`tA(3tOPK_gt2R$32f_
zBus{TK5mKL!}2^H+rg{_`Vp4lI1S8dqGMQwbLn7K1AT;LIPU|ql4uK-Va*R_CD2wZ
z!+IW=<)Blr3^Vy)=0T@o8Rp7>Sqj>NWtc4oW)`#;%P?OS%wp&qEW<VB!E6s5dm+|v
zT^%r61M#)+o0~kJ3(IKXbI4(s+`t89gsq@|a4(k8!sn60FuBqH02795&+(R6W4Y(?
z-Z>dJhwI9NW3cVo(?8ZMf5jX$=F5RCSj~&ZY#DG0R`Z}Smk;(}wNx}_^1wM*Ed`Br
zKez-|v!b!)1DC{V7BtSMgKJ>5BQ(yXfoo#57#hcRa0{&V2#v=!a7(PVhsORGe7c`o
s@wM<=KWNL~dH!YaiktARuEM(R7rj@P2Nbm}mjD0&07*qoM6N<$g6uH!wEzGB

literal 0
HcmV?d00001

diff --git a/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in
new file mode 100644
index 0000000..6b27ab7
--- /dev/null
+++ b/Tests/VSWinStorePhone/cmake/Package_vc14.store.appxmanifest.in
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package
+  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
+  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
+  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
+  IgnorableNamespaces="uap mp">
+
+  <Identity Name="@PACKAGE_GUID@" Publisher="CN=mgong" Version="1.1.0.0" />
+  <mp:PhoneIdentity PhoneProductId="@PACKAGE_GUID@" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
+
+  <Properties>
+    <DisplayName>@SHORT_NAME@</DisplayName>
+    <PublisherDisplayName>mgong</PublisherDisplayName>
+    <Logo>Assets/StoreLogo.png</Logo>
+  </Properties>
+
+  <Dependencies>
+    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.65535.65535" />
+  </Dependencies>
+
+  <Resources>
+    <Resource Language="x-generate" />
+  </Resources>
+  <Applications>
+    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App">
+      <uap:VisualElements
+        DisplayName="@SHORT_NAME@"
+        Description="@SHORT_NAME@"
+        BackgroundColor="#336699"
+        Square150x150Logo="Assets/Logo.png"
+        Square44x44Logo="Assets/SmallLogo44x44.png">
+        <uap:SplashScreen Image="Assets/SplashScreen.png" />
+      </uap:VisualElements>
+    </Application>
+  </Applications>
+</Package>
-- 
2.5.1.windows.1

