<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- Must be included at the beginning of each .vcxproj file -->

  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>

  <Choose>
    <When Condition="'$(MSBuildToolsVersion)' == '14.0'">
      <PropertyGroup Label="Configuration">
        <PlatformToolset>v140</PlatformToolset>
      </PropertyGroup>
    </When>
    <When Condition="'$(MSBuildToolsVersion)' == '14.1'">
      <PropertyGroup Label="Configuration">
        <PlatformToolset>v141</PlatformToolset>
      </PropertyGroup>
    </When>
    <When Condition="'$(MSBuildToolsVersion)' == '14.2'">
      <PropertyGroup Label="Configuration">
        <PlatformToolset>v142</PlatformToolset>
      </PropertyGroup>
    </When>
    <When Condition="'$(MSBuildToolsVersion)' == '14.3'">
      <PropertyGroup Label="Configuration">
        <PlatformToolset>v143</PlatformToolset>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup Label="Configuration">
        <PlatformToolset>v143</PlatformToolset>
      </PropertyGroup>
    </Otherwise>
  </Choose>

  <!-- Definition of the Windows Kits, try various hacks, not a very generic method -->
  
  <PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'==''">
    <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
    <WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'==''">
    <WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</WindowsTargetPlatformVersion_10>
    <WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</WindowsTargetPlatformVersion_10>
    <!-- Sometimes the version in the registry has to .0 suffix, and sometimes it doesn't. Check and add it -->
    <WindowsTargetPlatformVersion_10 Condition="'$(WindowsTargetPlatformVersion_10)' != '' and !$(WindowsTargetPlatformVersion_10.EndsWith('.0'))">$(WindowsTargetPlatformVersion_10).0</WindowsTargetPlatformVersion_10>
    <WindowsTargetPlatformVersion>$(WindowsTargetPlatformVersion_10)</WindowsTargetPlatformVersion>
  </PropertyGroup>

  <PropertyGroup>
    <TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>
  </PropertyGroup>

</Project>
