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

  <PropertyGroup>
    <OutDir Condition="'$(ConfigurationType)'=='DynamicLibrary'">$(AegisubBinaryDir)</OutDir>
    <OutDir Condition="'$(ConfigurationType)'=='Application'">$(AegisubBinaryDir)</OutDir>
    <OutDir Condition="'$(ConfigurationType)'=='StaticLibrary'">$(AegisubLibraryDir)</OutDir>
    <IntDir>$(AegisubObjectDir)</IntDir>
    <TargetName Condition="'$(ConfigurationType)'=='DynamicLibrary'">$(ProjectName)_$(AegisubPlatformSuffix)</TargetName>
    <TargetName Condition="'$(ConfigurationType)'=='Application'">$(ProjectName)$(AegisubPlatformSuffix)</TargetName>
    <TargetName Condition="'$(ConfigurationType)'=='StaticLibrary'">$(ProjectName)</TargetName>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <InputRelativeSourceDir></InputRelativeSourceDir>
    </ClCompile>
    <Link>
      <OutputFile>$(AegisubBinaryDir)$(TargetName)$(TargetExt)</OutputFile>
      <ProgramDatabaseFile>$(AegisubBinaryDir)$(TargetName).pdb</ProgramDatabaseFile>
      <ImportLibrary>$(AegisubLibraryDir)$(ProjectName).lib</ImportLibrary>
    </Link>
    <Lib>
      <OutputFile>$(AegisubLibraryDir)$(ProjectName).lib</OutputFile>
    </Lib>
  </ItemDefinitionGroup>
  
  <!-- Add ObjectFileName for ClCompile items that need to be placed in subdirs
       for linking to work, for projects with same-named files in separate dirs.
       
       To use this feature, add a InputRelativeSourceDir metadata to ClCompile for
       a project.
  -->
  <PropertyGroup>
    <ComputeCompileInputsTargets>
      ComputeClRelativeObjectFileName;
      $(ComputeCompileInputsTargets)
    </ComputeCompileInputsTargets>
  </PropertyGroup>
  <Target
    Name="ComputeClRelativeObjectFileName"
    Inputs="@(ClCompile)"
    Outputs="%(InputRelativeSourceDir)|%(RelativeDir)"
    >
    <!-- Transform paths on items -->
    <CalculateOutputDir
      Items="@(ClCompile)"
      SourceDir="%(InputRelativeSourceDir)"
      DestinationDir="."
      Condition="'%(ClCompile.InputRelativeSourceDir)' != ''"
      >
      <Output ItemName="_RelativeClCompile" TaskParameter="Outputs" />
    </CalculateOutputDir>
    <ItemGroup>
      <!-- Add the ObjectFileName -->
      <_RelativeClCompile Condition="'%(_RelativeClCompile.OutputDir)' != ''">
        <ObjectFileName>$(IntDir)%(_RelativeClCompile.OutputDir)</ObjectFileName>
      </_RelativeClCompile>
      <!-- Remove old items and replace them with new -->
      <ClCompile Remove="@(_RelativeClCompile->'%(Identity)')" />
      <ClCompile Include="@(_RelativeClCompile)" />
      <!-- Forget about the temporary ones -->
      <_RelativeClCompile Remove="@(_RelativeClCompile)" />
    </ItemGroup>
  </Target>
</Project>
