﻿<!--
***********************************************************************************************
Microsoft.Cpp.Platform.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

This file defines the steps/targets required to build Visual C++ projects
specifically on x86 platforms.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="VCMessage" AssemblyFile="$(MSBuildThisFileDirectory)Microsoft.Build.CppTasks.Common.dll" />

  <PropertyGroup>
    <!-- VCMessages could only print messages from the active task dll.  Since the new message is only present in the current task dll,
    setting MinSupportedVCTargetsVersion prevents the redirection which will keep the task to current. -->
    <_Error64bitToolsNotInstalled Condition="'$(_Error64bitToolsNotInstalled)' == '' and '$(_CheckDev11ToolsInstalled)' == 'true' and '$(DefaultToolArchitecture)' == 'Native64bit' 
      and (('$(PlatformToolset)' == 'v110' and '$(_IgnoreInstalledPlatformToolset_v110)' != 'true') or ('$(PlatformToolset)' == 'v110_xp' and '$(_IgnoreInstalledPlatformToolset_v110_xp)' != 'true'))">true</_Error64bitToolsNotInstalled>
    <MinSupportedVCTargetsVersion Condition="'$(_Error64bitToolsNotInstalled)' == 'true'">v120</MinSupportedVCTargetsVersion>
  </PropertyGroup>

  <!-- Import Before -->
  <Import Condition="Exists('$(_PlatformFolder)ImportBefore')" Project="$(_PlatformFolder)ImportBefore\*.targets"/>
  <!-- Import platform toolset file if found in this version -->
  <Import Condition="'$(_ToolsetFound)' == 'true'" Project="$(_ToolsetTargetsPath)" />

  <!-- If toolset is not found, then use MissingToolset targets so the project can still load. -->
  <PropertyGroup  Condition="'$(_ToolsetFound)' != 'true'">
    <_MissingToolsetTargets Condition="'$(DefaultPlatformToolset)' != '' and Exists('$(_DefaultPlatformFolder)PlatformToolsets\$(DefaultPlatformToolset)\Toolset.targets')">$(_DefaultPlatformFolder)PlatformToolsets\$(DefaultPlatformToolset)\Toolset.targets</_MissingToolsetTargets>
    <_MissingToolsetTargets Condition="'$(_MissingToolsetTargets)' == ''">$(VCTargetsPathActual)\Microsoft.Cpp.MissingToolset.targets</_MissingToolsetTargets>
  </PropertyGroup>
  
  <Import Condition="'$(_ToolsetFound)' != 'true'" Project="$(_MissingToolsetTargets)" />

  <PropertyGroup>
    <PrepareForBuildDependsOn>PlatformPrepareForBuild;$(PrepareForBuildDependsOn)</PrepareForBuildDependsOn>
  </PropertyGroup>

  <Target Name="PlatformPrepareForBuild" DependsOnTargets="$(PlatformPrepareForBuildDependsOn)" Condition="'$(DesignTimeBuild)'!='true'">
    <PropertyGroup>
      <ConfigurationPlatformExists Condition="'%(ProjectConfiguration.Identity)' == '$(Configuration)|$(Platform)'">true</ConfigurationPlatformExists>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v110'">$(_PlatformToolsetShortNameFor_v110)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v110_xp'">$(_PlatformToolsetShortNameFor_v110_xp)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v100'">$(_PlatformToolsetShortNameFor_v100)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v90'">$(_PlatformToolsetShortNameFor_v90)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(_CurrentPlatformToolsetShortName)' == ''">$(PlatformToolset)</_CurrentPlatformToolsetShortName>
    </PropertyGroup>

    <!--
    Error out if the toolset is from Express and the environment is 64bit tools and down targetting. 
    MSB8032: The Platform or PlatformToolset is not available from a 64bit environment.  Consider building from 32bit environment instead.
    -->
    <VCMessage Code="MSB8032" Type="Error" Condition="'$(_Error64bitToolsNotInstalled)' == 'true'" />

    <!-- Error out if toolset is not defined -->
    <VCMessage Code="MSB8038" Type="Error" Condition="'$(DesignTimeBuild)'!='true' and '$(_ToolsetFound)' != 'true' and '$(PlatformToolset)' == ''" />

    <!-- Error out if toolset does not exists in older versions of Visual Studio -->
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_PlatformToolsetShortNameFor_v110);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(_ToolsetFound)' != 'true' and '$(PlatformToolset)' == 'v110'" />
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_PlatformToolsetShortNameFor_v100);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(_ToolsetFound)' != 'true' and '$(PlatformToolset)' == 'v100'" />
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_PlatformToolsetShortNameFor_v90);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(_ToolsetFound)' != 'true' and '$(PlatformToolset)' == 'v90'" />
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(PlatformToolset);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(_ToolsetFound)' != 'true' and '$(PlatformToolset)' != 'v90' and '$(PlatformToolset)' != 'v100' and '$(PlatformToolset)' != 'v110'" />
  </Target>

  <!-- Import After -->
  <Import Condition="'$(_ToolsetFound)' == 'true' and Exists('$(_PlatformFolder)ImportAfter')" Project="$(_PlatformFolder)ImportAfter\*.targets"/>
</Project>
