Skip to content

Commit 53fd0f0

Browse files
committed
Honor MSVC WindowsSDKVersion if set
Add a line to the project file setting the target SDK. Otherwise, in for example VS2017, if the default but optional 8.1 SDK is not installed the build will fail. Patch from Peifeng Qiu, slightly edited by me. Discussion: https://postgr.es/m/CABmtVJhw1boP_bd4=b3Qv5YnqEdL696NtHFi2ruiyQ6mFHkeQQ@mail.gmail.com Backpatch to all live branches.
1 parent 0e259d4 commit 53fd0f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/tools/msvc/MSBuildProject.pm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ EOF
3838
</ItemGroup>
3939
<PropertyGroup Label="Globals">
4040
<ProjectGuid>$self->{guid}</ProjectGuid>
41+
EOF
42+
# Check whether WindowsSDKVersion env variable is present.
43+
# Add WindowsTargetPlatformVersion node if so.
44+
my $sdkVersion = $ENV{'WindowsSDKVersion'};
45+
if (defined($sdkVersion))
46+
{
47+
# remove trailing backslash if necessary.
48+
$sdkVersion, =~ s/\\$//;
49+
print $f <<EOF
50+
<WindowsTargetPlatformVersion>$sdkVersion</WindowsTargetPlatformVersion>
51+
EOF
52+
}
53+
print $f <<EOF;
4154
</PropertyGroup>
4255
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
4356
EOF

0 commit comments

Comments
 (0)