On 09/23/2015 06:48 PM, Gilles Khouzam wrote:
> This adds only the WINDOWS_TARGET_PLATFORM_VERSION property as it
> currently only supports the desktop scenario and is extracted
> from the rest of the Windows 10 Store support.

Thanks.  While reviewing this much simpler patch I realized that
the WindowsTargetPlatformVersion is more like PlatformToolset than
I previously thought.  This led me to another design, perhaps closer
to one of your earlier patches, in which the VS 2015+ generators
select the WindowsTargetPlatformVersion up front based either on
CMAKE_WINDOWS_TARGET_PLATFORM_VERSION or on a computed default.
Either way we should set CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
to report the selection to CMakeDetermineCompilerId for use in
"CompilerId/VS-10.vcxproj.in".  For now I decided to leave out
support for per-target WINDOWS_TARGET_PLATFORM_VERSION properties.

While testing these changes I found a bug that I've now fixed:

 cmCoreTryCompile: Fix internal argument vector construction
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=710bde43

Please try out the attached patches based on that version.  Then
provide fixup patches based on the comments below if needed.

> If CMAKE_SYSTEM_VERSION is set to 10.0 then

After your change to add a third component to CMAKE_HOST_SYSTEM_VERSION
the value of CMAKE_SYSTEM_VERSION on a Windows 10 host may have
a third component.  Therefore we should check that the version
starts with "10.0" rather than is exactly this version.  Actually
perhaps we should use cmSystemTools::VersionCompare to do actual
integer version component checks.

> the latest Windows 10 SDK but not more recent than the current
> build of Windows.

Rather than using VerifyVersionInfo for this, shouldn't the check
simply compare the SDK version to the targeted CMAKE_SYSTEM_VERSION?
If we are cross-compiling or otherwise specifying a specific target
version of Windows then we do not want the SDK to exceed that
regardless of what the host is running.

Also, the sorting logic in GetWindows10SDKVersion appears to use
lexicographic string ordering rather than a component-wise integer
comparison.  This will not always produce the correct result.  This
is another candidate for using cmSystemTools::VersionCompare.

> There is one thing that I've changed that I want to make sure is
> the right thing. As it stands, CMAKE_SYSTEM_VERSION is only valid
> when cross-compiling, I've changed the CMakeDetermineSystem.cmake
> file to not use the HOST_SYSTEM_VERSION when CMAKE_SYSTEM_VERSION
> is set. Otherwise, we can only use this feature through
> CMAKE_SYSTEM_VERSION on cross-compiling scenarios.

That makes sense.  I've split that out into its own commit and
explained the motivation in the commit message.  See attached
patch.

> I'm not sure what the best way to test this feature, it can be
> added to any desktop project on Windows 10 and it should work
> properly. I've tried it with CMake itself and it's working fine
> and building against the Win10 SDK.

We could have the test suite detect when it is building on a
Windows 10 host and then add a test that sets
CMAKE_WINDOWS_TARGET_PLATFORM_VERSION and verifies that the
value ends up in a generated project file.  We already have
some tests that parse the generated .sln file to check for
specific content.

Also just simply by running on a Win 10 host then the entire test
suite should build with CMAKE_SYSTEM_VERSION set automatically high
enough to enable default SDK selection.  Please look at setting up
nightly testing submissions to the dashboard from such a host once
the changes are integrated.

Thanks,
-Brad
>From 267153a2ed1417fe16e679d21d34927802e31e2c Mon Sep 17 00:00:00 2001
Message-Id: <267153a2ed1417fe16e679d21d34927802e31e2c.1443126273.git.brad.k...@kitware.com>
From: Gilles Khouzam <gill...@microsoft.com>
Date: Wed, 23 Sep 2015 14:27:07 -0700
Subject: [PATCH 1/3] Allow CMAKE_SYSTEM_VERSION to be set without
 CMAKE_SYSTEM_NAME

Teach CMakeDetermineSystem to check for a CMAKE_SYSTEM_VERSION setting
even when CMAKE_SYSTEM_NAME is not set.  This will allow builds on the
host OS to target other versions of the OS without full cross-compiling.
---
 Modules/CMakeDetermineSystem.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index fa14641..d9f7579 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -123,7 +123,9 @@ elseif(CMAKE_VS_WINCE_VERSION)
   set(PRESET_CMAKE_SYSTEM_NAME TRUE)
 else()
   set(CMAKE_SYSTEM_NAME      "${CMAKE_HOST_SYSTEM_NAME}")
-  set(CMAKE_SYSTEM_VERSION   "${CMAKE_HOST_SYSTEM_VERSION}")
+  if(NOT DEFINED CMAKE_SYSTEM_VERSION)
+    set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
+  endif()
   set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
   set(CMAKE_CROSSCOMPILING FALSE)
   set(PRESET_CMAKE_SYSTEM_NAME FALSE)
-- 
2.5.1

>From b199b0442c06cc80cd5212d89561ee712fef3408 Mon Sep 17 00:00:00 2001
Message-Id: <b199b0442c06cc80cd5212d89561ee712fef3408.1443126273.git.brad.k...@kitware.com>
In-Reply-To: <267153a2ed1417fe16e679d21d34927802e31e2c.1443126273.git.brad.k...@kitware.com>
References: <267153a2ed1417fe16e679d21d34927802e31e2c.1443126273.git.brad.k...@kitware.com>
From: Gilles Khouzam <gill...@microsoft.com>
Date: Wed, 23 Sep 2015 14:27:07 -0700
Subject: [PATCH 2/3] VS: Add hook to initialize Windows platform settings

Give VS 10+ generators a chance to choose Windows platform settings just
as they already can for WindowsCE, WindowsStore, and WindowsPhone.
---
 Source/cmGlobalVisualStudio10Generator.cxx | 19 ++++++++++++++++---
 Source/cmGlobalVisualStudio10Generator.h   |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 44d632d..59e8f8c 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -176,7 +176,14 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
 //----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
 {
-  if (this->SystemName == "WindowsCE")
+  if (this->SystemName == "Windows")
+    {
+    if (!this->InitializeWindows(mf))
+      {
+      return false;
+      }
+    }
+  else if (this->SystemName == "WindowsCE")
     {
     this->SystemIsWindowsCE = true;
     if (!this->InitializeWindowsCE(mf))
@@ -184,7 +191,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
       return false;
       }
     }
-  else if(this->SystemName == "WindowsPhone")
+  else if (this->SystemName == "WindowsPhone")
     {
     this->SystemIsWindowsPhone = true;
     if(!this->InitializeWindowsPhone(mf))
@@ -192,7 +199,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
       return false;
       }
     }
-  else if(this->SystemName == "WindowsStore")
+  else if (this->SystemName == "WindowsStore")
     {
     this->SystemIsWindowsStore = true;
     if(!this->InitializeWindowsStore(mf))
@@ -229,6 +236,12 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
 }
 
 //----------------------------------------------------------------------------
+bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
+{
+  return true;
+}
+
+//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
 {
   if (this->DefaultPlatformName != "Win32")
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 8de7b09..49c5616 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -105,6 +105,7 @@ public:
 protected:
   virtual void Generate();
   virtual bool InitializeSystem(cmMakefile* mf);
+  virtual bool InitializeWindows(cmMakefile* mf);
   virtual bool InitializeWindowsCE(cmMakefile* mf);
   virtual bool InitializeWindowsPhone(cmMakefile* mf);
   virtual bool InitializeWindowsStore(cmMakefile* mf);
-- 
2.5.1

>From 491b3cd720492c2982c8facad7af193616aa2ece Mon Sep 17 00:00:00 2001
Message-Id: <491b3cd720492c2982c8facad7af193616aa2ece.1443126273.git.brad.k...@kitware.com>
In-Reply-To: <267153a2ed1417fe16e679d21d34927802e31e2c.1443126273.git.brad.k...@kitware.com>
References: <267153a2ed1417fe16e679d21d34927802e31e2c.1443126273.git.brad.k...@kitware.com>
From: Brad King <brad.k...@kitware.com>
Date: Thu, 24 Sep 2015 15:52:14 -0400
Subject: [PATCH 3/3] VS: Add support for selecting the Windows 10 SDK

Teach the VS 2015 generator to produce a WindowsTargetPlatformVersion
value.  Offer a new CMAKE_WINDOWS_TARGET_PLATFORM_VERSION variable to
specify the value and if not set choose a default based on available
SDKs.  Activate this behavior when targeting Windows 10.

Co-Author: Gilles Khouzam <gill...@microsoft.com>
---
 Help/manual/cmake-variables.7.rst                  |   2 +
 .../CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst   |  11 +++
 .../CMAKE_WINDOWS_TARGET_PLATFORM_VERSION.rst      |  10 ++
 Modules/CMakeDetermineCompilerId.cmake             |   3 +
 Modules/CompilerId/VS-10.vcxproj.in                |   1 +
 Source/cmCoreTryCompile.cxx                        |   7 ++
 Source/cmGlobalVisualStudio10Generator.h           |   5 +
 Source/cmGlobalVisualStudio14Generator.cxx         | 101 +++++++++++++++++++++
 Source/cmGlobalVisualStudio14Generator.h           |   4 +
 Source/cmVisualStudio10TargetGenerator.cxx         |  10 ++
 10 files changed, 154 insertions(+)
 create mode 100644 Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
 create mode 100644 Help/variable/CMAKE_WINDOWS_TARGET_PLATFORM_VERSION.rst

diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 635db00..ab84da7 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -82,6 +82,7 @@ Variables that Provide Information
    /variable/CMAKE_VS_NsightTegra_VERSION
    /variable/CMAKE_VS_PLATFORM_NAME
    /variable/CMAKE_VS_PLATFORM_TOOLSET
+   /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
    /variable/CMAKE_XCODE_PLATFORM_TOOLSET
    /variable/PROJECT_BINARY_DIR
    /variable/PROJECT-NAME_BINARY_DIR
@@ -293,6 +294,7 @@ Variables that Control the Build
    /variable/CMAKE_VISIBILITY_INLINES_HIDDEN
    /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
    /variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
+   /variable/CMAKE_WINDOWS_TARGET_PLATFORM_VERSION
    /variable/CMAKE_WIN32_EXECUTABLE
    /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute
    /variable/EXECUTABLE_OUTPUT_PATH
diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
new file mode 100644
index 0000000..6f901cd
--- /dev/null
+++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
@@ -0,0 +1,11 @@
+CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
+----------------------------------------
+
+Visual Studio Windows Target Platform Version.
+
+When targeting Windows 10 and above Visual Studio 2015 and above support
+specification of a target Windows version to select a corresponding SDK.
+The :variable:`CMAKE_WINDOWS_TARGET_PLATFORM_VERSION` variable may be
+set to specify a version.  Otherwise CMake computes a default version
+based on the Windows SDK versions available.  The chosen Windows target
+version number is provided in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``.
diff --git a/Help/variable/CMAKE_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_WINDOWS_TARGET_PLATFORM_VERSION.rst
new file mode 100644
index 0000000..097669e
--- /dev/null
+++ b/Help/variable/CMAKE_WINDOWS_TARGET_PLATFORM_VERSION.rst
@@ -0,0 +1,10 @@
+CMAKE_WINDOWS_TARGET_PLATFORM_VERSION
+-------------------------------------
+
+Windows Target Platform Version
+
+When targeting Windows 10 and above Visual Studio 2015 and above support
+specification of a target Windows version to select a corresponding SDK.
+The ``CMAKE_WINDOWS_TARGET_PLATFORM_VERSION`` variable may be set to
+specify a version, e.g. ``10.0.10240.0``.  Otherwise CMake computes a
+default version based on the Windows SDK versions available.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index df6daf3..81c2509 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -209,6 +209,9 @@ Id flags: ${testflags}
     else()
       set(id_system_version "")
     endif()
+    if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
+      set(id_WindowsTargetPlatformVersion "<WindowsTargetPlatformVersion>${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}</WindowsTargetPlatformVersion>")
+    endif()
     if(id_platform STREQUAL ARM)
       set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>")
     else()
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index a17d03d..2870a11 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -12,6 +12,7 @@
     <Keyword>Win32Proj</Keyword>
     @id_system@
     @id_system_version@
+    @id_WindowsTargetPlatformVersion@
     @id_WindowsSDKDesktopARMSupport@
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 3d9c4bf..3ee0640 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -427,6 +427,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
       flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
       cmakeFlags.push_back(flag);
       }
+    if(const char* windowsTargetPlatformVersion =
+       this->Makefile->GetDefinition("CMAKE_WINDOWS_TARGET_PLATFORM_VERSION"))
+      {
+      std::string flag="-DCMAKE_WINDOWS_TARGET_PLATFORM_VERSION=";
+      flag += windowsTargetPlatformVersion;
+      cmakeFlags.push_back(flag);
+      }
     if (const char *cxxDef
               = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET"))
       {
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 49c5616..5ae1c1c 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -74,6 +74,10 @@ public:
   /** Return the CMAKE_SYSTEM_VERSION.  */
   std::string const& GetSystemVersion() const { return this->SystemVersion; }
 
+  /** Return the Windows version targeted on VS 2015 and above.  */
+  std::string const& GetWindowsTargetPlatformVersion() const
+    { return this->WindowsTargetPlatformVersion;}
+
   /** Return true if building for WindowsCE */
   bool TargetsWindowsCE() const
     { return this->SystemIsWindowsCE; }
@@ -120,6 +124,7 @@ protected:
 
   std::string GeneratorToolset;
   std::string DefaultPlatformToolset;
+  std::string WindowsTargetPlatformVersion;
   std::string SystemName;
   std::string SystemVersion;
   std::string NsightTegraVersion;
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index d73eedf..f227084 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -9,6 +9,7 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#include "windows.h" // For Windows 10 SDK detection
 #include "cmGlobalVisualStudio14Generator.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
@@ -111,6 +112,39 @@ cmGlobalVisualStudio14Generator::MatchesGeneratorName(
 }
 
 //----------------------------------------------------------------------------
+bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
+{
+  if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
+    {
+    return this->SelectWindows10SDK(mf);
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
+{
+  this->WindowsTargetPlatformVersion =
+    mf->GetSafeDefinition("CMAKE_WINDOWS_TARGET_PLATFORM_VERSION");
+  if (this->WindowsTargetPlatformVersion.empty())
+    {
+    // Find the default version of the Windows 10 SDK.
+    this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
+    }
+  if (this->WindowsTargetPlatformVersion.empty())
+    {
+    std::ostringstream  e;
+    e << "Could not find an appropriate version of the Windows 10 SDK"
+      << "installed on this machine";
+    mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+    return false;
+    }
+  mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
+                    this->WindowsTargetPlatformVersion.c_str());
+  return true;
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
 {
   // Visual Studio 14 writes .sln format 12.00
@@ -137,3 +171,70 @@ cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const
   return cmSystemTools::GetRegistrySubKeys(desktop10Key,
     vc14, cmSystemTools::KeyWOW64_32);
 }
+
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  // This logic is taken from the vcvarsqueryregistry.bat file from VS2015
+  std::string win10Root;
+  if (!cmSystemTools::ReadRegistryValue(
+    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;"
+    "KitsRoot10", win10Root, cmSystemTools::KeyWOW64_32))
+    {
+    // If we can't find the root in HKLM try HKCU
+    if (!cmSystemTools::ReadRegistryValue(
+      "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;"
+      "KitsRoot10", win10Root, cmSystemTools::KeyWOW64_32))
+      {
+      return std::string();
+      }
+    }
+
+  std::vector<std::string> sdks;
+  std::string path = win10Root + "Include/*";
+  // Grab the paths of the different SDKs that are installed
+  cmSystemTools::GlobDirs(path, sdks);
+  if (!sdks.empty())
+    {
+    // Each component of the comparison mask needs to be done seperately
+    ULONGLONG dwlConditionMask = 0;
+    dwlConditionMask = VerSetConditionMask(dwlConditionMask,
+      VER_MAJORVERSION, VER_GREATER_EQUAL);
+    dwlConditionMask = VerSetConditionMask(dwlConditionMask,
+      VER_MINORVERSION, VER_GREATER_EQUAL);
+    dwlConditionMask = VerSetConditionMask(dwlConditionMask,
+      VER_BUILDNUMBER, VER_GREATER_EQUAL);
+
+    // Sort the results to make sure we select the most recent one that
+    // has a version less or equal to our version of the operating system
+    std::sort(sdks.begin(), sdks.end(), std::greater<std::string>());
+    for(std::vector<std::string>::iterator i = sdks.begin();
+        i != sdks.end(); ++i)
+      {
+      // Get the SDK version in the form 10.0.10240.0 and split into tokens
+      std::string sdkVersion = cmSystemTools::GetFilenameName(*i);
+      std::vector<std::string> tokens =
+        cmSystemTools::tokenize(sdkVersion, ".");
+      if (tokens.size()>=3)
+        {
+        OSVERSIONINFOEX osviex;
+        ZeroMemory(&osviex, sizeof(osviex));
+        osviex.dwOSVersionInfoSize = sizeof(osviex);
+        osviex.dwMajorVersion = atoi(tokens[0].c_str());
+        osviex.dwMinorVersion = atoi(tokens[1].c_str());
+        osviex.dwBuildNumber = atoi(tokens[2].c_str());
+        if (VerifyVersionInfo(&osviex,
+          VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER,
+          dwlConditionMask))
+          {
+          // This is the most recent SDK that we can run safely
+          return sdkVersion;
+          }
+        }
+      }
+    }
+#endif
+  // Return an empty string
+  return std::string();
+}
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 02c6274..fcade85 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -30,12 +30,16 @@ public:
 
   virtual const char* GetToolsVersion() { return "14.0"; }
 protected:
+  virtual bool InitializeWindows(cmMakefile* mf);
   virtual const char* GetIDEVersion() { return "14.0"; }
+  virtual bool SelectWindows10SDK(cmMakefile* mf);
 
   // Used to verify that the Desktop toolset for the current generator is
   // installed on the machine.
   virtual bool IsWindowsDesktopToolsetInstalled() const;
 
+  std::string GetWindows10SDKVersion();
+
 private:
   class Factory;
 };
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 92403e3..6b2a8bc 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3002,6 +3002,8 @@ IsXamlSource(const std::string& sourceFile)
 
 void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
 {
+  cmGlobalVisualStudio10Generator* gg =
+    static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
   bool isAppContainer = false;
   bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
   bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
@@ -3058,6 +3060,14 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
     this->WriteString("<WindowsSDKDesktopARMSupport>true"
                       "</WindowsSDKDesktopARMSupport>\n", 2);
     }
+  std::string const& targetPlatformVersion =
+    gg->GetWindowsTargetPlatformVersion();
+  if (!targetPlatformVersion.empty())
+    {
+    this->WriteString("<WindowsTargetPlatformVersion>", 2);
+    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
+      "</WindowsTargetPlatformVersion>\n";
+    }
 }
 
 void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
-- 
2.5.1

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to