aboutsummaryrefslogtreecommitdiff
path: root/scripts/buildsystems/msbuild/vcpkg.targets
blob: e6a321ffdb0ece024403390a2da0ad7648e8cbda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 <Target Name="VcpkgCompileInputs" BeforeTargets="GetClCommandLines;ClCompile">
    <PropertyGroup>
      <VcpkgRuntimeLibrary Condition="'%(ClCompile.RuntimeLibrary)' == ''"></VcpkgRuntimeLibrary>
      <VcpkgRuntimeLibrary Condition="'%(ClCompile.RuntimeLibrary)' == 'MultiThreadedDebugDLL'"></VcpkgRuntimeLibrary>
      <VcpkgRuntimeLibrary Condition="'%(ClCompile.RuntimeLibrary)' == 'MultiThreadedDebug'">-static</VcpkgRuntimeLibrary>
      <VcpkgRuntimeLibrary Condition="'%(ClCompile.RuntimeLibrary)' == 'MultiThreadedDLL'"></VcpkgRuntimeLibrary>
      <VcpkgRuntimeLibrary Condition="'%(ClCompile.RuntimeLibrary)' == 'MultiThreaded'">-static</VcpkgRuntimeLibrary>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32||'">
      <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
      <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows$(VcpkgRuntimeLibrary)</VcpkgTriplet>
    </PropertyGroup>

      <Message Text="BeforeCompile: RuntimeLibrary=[%(ClCompile.RuntimeLibrary)]" />

    <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32|Windows Store|10.0'">
      <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
      <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp$(VcpkgRuntimeLibrary)</VcpkgTriplet>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64||'">
      <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
      <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-windows$(VcpkgRuntimeLibrary)</VcpkgTriplet>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64|Windows Store|10.0'">
      <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
      <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-uwp$(VcpkgRuntimeLibrary)</VcpkgTriplet>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm|Windows Store|10.0'">
      <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
      <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-uwp$(VcpkgRuntimeLibrary)</VcpkgTriplet>
    </PropertyGroup>

    <PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
      <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
      <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\installed\$(VcpkgTriplet)\</VcpkgRoot>
    </PropertyGroup>

      <Message Text="Selecting VcpkgTriplet: $(VcpkgTriplet)"/>
      <Message Text="Selecting VcpkgRoot: $(VcpkgRoot)"/>
    <ItemGroup Condition="'$(VcpkgEnabled)' == 'true'">
      <ClCompile>
        <AdditionalIncludeDirectories>$(VcpkgRoot)include;%(ClCompile.AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      </ClCompile>
    </ItemGroup>
  </Target>

  <Target Name="VcpkgLinkInputs" 
      DependsOnTargets="ComputeRCGeneratedLinkInputs;
                        ComputeManifestGeneratedLinkerInputs;
                        ComputeCustomBuildOutput;
                        ComputeCLGeneratedLinkInputs;
                        ComputeLinkInputsFromProject;
                        ComputeReferenceLinkInputs;" 
      BeforeTargets="Link">
    <Message Text="LinkInputs: @(Link)" />
    <ItemGroup Condition="'$(VcpkgEnabled)' == 'true'">
      <VcpkgLink Include="$(VcpkgRoot)debug\lib\*.lib" Condition="'$(VcpkgConfiguration)' == 'Debug'"/>
      <VcpkgLink Include="$(VcpkgRoot)lib\*.lib" Condition="'$(VcpkgConfiguration)' == 'Release'"/>

      <Link>
        <AdditionalDependencies>@(VcpkgLink);%(Link.AdditionalDependencies)</AdditionalDependencies>
      </Link>
    </ItemGroup>
    <Message Text="VcpkgLinkInputs: @(VcpkgLink)" />
  </Target>

  <PropertyGroup>
    <ComputeLinkInputsTargets >$(ComputeLinkInputsTargets);VcpkgLinkInputs</ComputeLinkInputsTargets >
  </PropertyGroup>

  <Target Name="AppLocalFromInstalled" AfterTargets="CopyFilesToOutputDirectory" BeforeTargets="CopyLocalFilesOutputGroup" Condition="'$(VcpkgEnabled)' == 'true' and '$(OutputType)' == 'exe'">
    <WriteLinesToFile
    File="$(TLogLocation)$(ProjectName).write.1u.tlog"
    Lines="^$(OutputPath)$(TargetName).$(OutputType);" Encoding="Unicode"/>
    <Exec Condition="'$(VcpkgConfiguration)' == 'Debug'"
      Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(OutputPath)$(TargetName).$(OutputType)%22 %22$(VcpkgRoot)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22"
      ConsoleToMSBuild="true">
        <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" />
    </Exec>
    <Exec Condition="'$(VcpkgConfiguration)' == 'Release'"
      Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(OutputPath)$(TargetName).$(OutputType)%22 %22$(VcpkgRoot)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22"
      ConsoleToMSBuild="true">
        <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" />
    </Exec>
  </Target>
</Project>