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

  <PropertyGroup>
    <!-- this will trigger the use of a project-specific out dir -->
    <OpenConsoleCppWinRTProject>true</OpenConsoleCppWinRTProject>
  </PropertyGroup>

  <Import Project="..\common.openconsole.props" Condition="'$(OpenConsoleDir)'==''" />

  <PropertyGroup Label="Globals">
    <CppWinRTEnabled>true</CppWinRTEnabled>
    <CppWinRTOptimized>true</CppWinRTOptimized>
    <DefaultLanguage>en-US</DefaultLanguage>
    <MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
    <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
  </PropertyGroup>

  <!-- These settings tell MsBuild to treat the project as a "Universal Windows"
       application. This includes doing things like creating a separate
       subdirectory for our binary output, and making sure that a wapproj looks
       at the winmd we build to generate type info.
       In general, cppwinrt projects all want this.
  -->
  <PropertyGroup Condition="'$(OpenConsoleUniversalApp)'=='true'">
    <MinimalCoreWin>true</MinimalCoreWin>
    <AppContainerApplication>true</AppContainerApplication>
    <WindowsStoreApp>true</WindowsStoreApp>
    <ApplicationType>Windows Store</ApplicationType>
    <UseCrtSDKReference Condition="'$(EnableHybridCRT)'=='true'">false</UseCrtSDKReference> <!-- The SDK reference breaks the Hybrid CRT -->
  </PropertyGroup>
  <PropertyGroup Condition="'$(OpenConsoleUniversalApp)'!='true'">
    <!-- Some of our projects include the cppwinrt build options to
         just build cppwinrt things, but don't want the store bits
         in full swing. MinimalCoreWin != false means "don't let me
         use win32 APIs"
    -->
    <MinimalCoreWin>false</MinimalCoreWin>
  </PropertyGroup>

  <!-- This is magic that tells msbuild to link against the Desktop platform
       instead of the App platform. This you definitely want, because we're not
       building a true universal "app", we're building a desktop application
       with xaml.
       Linking against the App CRT will require the VCRT forwarders to be dropped next to the final binary for
       desktop situations, but it will let non-desktop situations work since there is no redist off desktop.
       The forwarders can be found at https://github.com/microsoft/vcrt-forwarders and are already included
       in our CascadiaPackage project.
  -->
  <PropertyGroup>
    <!-- We have to use the Desktop platform for Hybrid CRT to work. -->
    <_VC_Target_Library_Platform>Desktop</_VC_Target_Library_Platform>
    <_NoWinAPIFamilyApp>true</_NoWinAPIFamilyApp>
  </PropertyGroup>

  <PropertyGroup Label="Configuration">
    <GenerateManifest>false</GenerateManifest>
  </PropertyGroup>

  <Import Project="$(MSBuildThisFileDirectory)common.build.pre.props" />

  <!-- Overrides for common build settings -->
  <ItemDefinitionGroup>
    <ClCompile>
      <!-- C++/WinRT hard-codes pch.h -->
      <PrecompiledHeader>Use</PrecompiledHeader>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>

      <!-- Big objects for C++/WinRT. -->
      <AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
      <DisableSpecificWarnings>5104;28204;%(DisableSpecificWarnings)</DisableSpecificWarnings>

      <AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>

      <PreprocessorDefinitions>WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem Condition="'%(SubSystem)'==''">Console</SubSystem>
      <GenerateWindowsMetadata>true</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>

  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>$(OpenConsoleDir)\src\cascadia\WinRTUtils\inc;$(OpenConsoleDir)src\cascadia\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalDependencies>WindowsApp.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <AppContainer>false</AppContainer>
    </Link>
  </ItemDefinitionGroup>

  <!-- DLLs -->
  <ItemDefinitionGroup Condition="'$(ConfigurationType)'=='DynamicLibrary'">
    <ClCompile>
      <PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <ModuleDefinitionFile Condition="Exists('$(ProjectName).def')">$(ProjectName).def</ModuleDefinitionFile>
    </Link>
  </ItemDefinitionGroup>

</Project>
