aboutsummaryrefslogtreecommitdiff
path: root/scripts/buildsystems
diff options
context:
space:
mode:
authorAlexander Neumann <30894796+Neumann-A@users.noreply.github.com>2020-06-15 23:24:14 +0200
committerGitHub <noreply@github.com>2020-06-15 14:24:14 -0700
commit14514508d8d30bdbd645b2bec89696aec25497f1 (patch)
tree347b6905d7a15e9b2d5d755144adfadae178d8c6 /scripts/buildsystems
parent36b2f28bbb499a1150a69db13c84d5d499e1d664 (diff)
downloadvcpkg-14514508d8d30bdbd645b2bec89696aec25497f1.tar.gz
vcpkg-14514508d8d30bdbd645b2bec89696aec25497f1.zip
[vcpkg] Add vcpkg item to project settings in Visual Studio (#4361)
Co-authored-by: Curtis J Bezault <curtbezault@gmail.com> Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'scripts/buildsystems')
-rw-r--r--scripts/buildsystems/msbuild/vcpkg-general.xml57
-rw-r--r--scripts/buildsystems/msbuild/vcpkg.props35
-rw-r--r--scripts/buildsystems/msbuild/vcpkg.targets84
3 files changed, 131 insertions, 45 deletions
diff --git a/scripts/buildsystems/msbuild/vcpkg-general.xml b/scripts/buildsystems/msbuild/vcpkg-general.xml
new file mode 100644
index 000000000..2ee5599be
--- /dev/null
+++ b/scripts/buildsystems/msbuild/vcpkg-general.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Rule
+ Name="VcpkgGeneral"
+ DisplayName="Vcpkg"
+ PageTemplate="generic"
+ Description="Vcpkg"
+ xmlns="http://schemas.microsoft.com/build/2009/properties">
+ <Rule.Categories>
+ <Category Name="General" DisplayName="General" Description="General" />
+ </Rule.Categories>
+ <Rule.DataSource>
+ <DataSource Persistence="ProjectFile" Label="Vcpkg" HasConfigurationCondition="true" />
+ </Rule.DataSource>
+ <BoolProperty Name="VcpkgEnabled"
+ DisplayName="Use Vcpkg"
+ Description="Use Vcpkg for includes and libraries."
+ Category="General"
+ Default="true">
+ </BoolProperty>
+ <BoolProperty Name="VcpkgUseStatic"
+ DisplayName="Use static libraries"
+ Description="Vcpkg can build static libraries (e.g. x64-windows-static). This options changes the default triplet to use these static libraries by appending -static to $(VcpkgTriplet). This will not be shown in the evaluation of the Triplet within the UI."
+ Category="General"
+ Default="false">
+ </BoolProperty>
+ <BoolProperty Name="VcpkgAutoLink"
+ DisplayName="Use AutoLink"
+ Description="Enables automatic linking with libraries build using Vcpkg"
+ Category="General"
+ Default="true">
+ </BoolProperty>
+ <StringProperty Name="VcpkgUserTriplet"
+ DisplayName="Triplet"
+ Description="Specifies the triplet used by Vcpkg"
+ Category="General"
+ Subtype="Text">
+ </StringProperty>
+ <StringProperty Name="VcpkgRoot"
+ DisplayName="Vcpkg Root"
+ Description="Root path where Vcpkg is located. Be careful with changing this one. It is, for example, unable to update this property page from the new location without restarting visual studio."
+ Category="General"
+ Subtype="folder"
+ Visible="false">
+ </StringProperty>
+ <StringProperty Name="VcpkgCurrentInstalledDir"
+ DisplayName="Package install directory"
+ Description="Defines the direct path to the installed Vcpkg packages. Only change this if you know what you are doing!"
+ Category="General"
+ Subtype="folder">
+ </StringProperty>
+ <EnumProperty Name="VcpkgConfiguration" DisplayName="Vcpkg Configuration" Description="Specifies if release or debug libraries build with vcpkg should be used." Category="General">
+ <EnumValue Name="Release" Switch="Release" DisplayName="Release" Description="Uses release libraries">
+ </EnumValue>
+ <EnumValue Name="Debug" Switch="Debug" DisplayName="Debug" Description="Uses debug libraries">
+ </EnumValue>
+ </EnumProperty>
+</Rule> \ No newline at end of file
diff --git a/scripts/buildsystems/msbuild/vcpkg.props b/scripts/buildsystems/msbuild/vcpkg.props
new file mode 100644
index 000000000..a9b97348f
--- /dev/null
+++ b/scripts/buildsystems/msbuild/vcpkg.props
@@ -0,0 +1,35 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <VcpkgHasProps>true</VcpkgHasProps>
+ <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
+ <VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
+ <VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
+ <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))</VcpkgRoot>
+ <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
+ <VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
+ </PropertyGroup>
+
+ <!-- Set default OS Target-->
+ <PropertyGroup Condition="'$(ApplicationType)|$(ApplicationTypeRevision)' == 'Windows Store|10.0'">
+ <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">uwp</VcpkgOSTarget>
+ </PropertyGroup>
+ <PropertyGroup>
+ <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">windows</VcpkgOSTarget>
+ </PropertyGroup>
+
+ <!-- Set default Platform Target. $(PlatformTarget) is not available at the top of the .vcxproj file. -->
+ <PropertyGroup Condition="'$(Platform)' == 'Win32'">
+ <VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">x86</VcpkgPlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup>
+ <VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">$(Platform)</VcpkgPlatformTarget>
+ </PropertyGroup>
+
+ <!-- Set other defaults-->
+ <PropertyGroup>
+ <VcpkgUserTriplet Condition="'$(VcpkgUserTriplet)' == ''">$(VcpkgPlatformTarget)-$(VcpkgOSTarget)</VcpkgUserTriplet>
+ <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgUserTriplet)</VcpkgTriplet>
+ <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
+ <VcpkgPageSchema>$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
+ </PropertyGroup>
+</Project>
diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets
index 329f7ba70..626e72228 100644
--- a/scripts/buildsystems/msbuild/vcpkg.targets
+++ b/scripts/buildsystems/msbuild/vcpkg.targets
@@ -1,64 +1,58 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgRoot;VcpkgCurrentInstalledDir">
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32||'">
+ <!-- Setting reasonable defaults if vcpkg.props was not loaded-->
+ <PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows</VcpkgTriplet>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32|Windows Store|10.0'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp</VcpkgTriplet>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '||'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows</VcpkgTriplet>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '|Windows Store|10.0'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp</VcpkgTriplet>
+ <VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
+ <VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
+ <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))</VcpkgRoot>
+ <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
+ <VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
</PropertyGroup>
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64||'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-windows</VcpkgTriplet>
+ <!-- Set default OS Target-->
+ <PropertyGroup Condition="'$(ApplicationType)|$(ApplicationTypeRevision)' == 'Windows Store|10.0' And '$(VcpkgHasProps)'!='true'">
+ <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">uwp</VcpkgOSTarget>
</PropertyGroup>
-
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm||'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-windows</VcpkgTriplet>
+ <PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
+ <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">windows</VcpkgOSTarget>
</PropertyGroup>
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64||'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-windows</VcpkgTriplet>
- </PropertyGroup>
+ <!-- Set other defaults-->
+ <PropertyGroup Condition="'$(VcpkgHasProps)'!='true'" >
+ <VcpkgUserTriplet Condition="'$(VcpkgUserTriplet)' == ''">$(PlatformTarget)-$(VcpkgOSTarget)</VcpkgUserTriplet>
+ <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgUserTriplet)</VcpkgTriplet>
+ <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
+ </PropertyGroup>
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64|Windows Store|10.0'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-uwp</VcpkgTriplet>
- </PropertyGroup>
+ <!--Import property page for vcpkg -->
+ <ItemGroup Condition="'$(VcpkgPageSchema)' != '' ">
+ <PropertyPageSchema Include="$(VcpkgPageSchema)">
+ <Context>Project</Context>
+ </PropertyPageSchema>
+ </ItemGroup>
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm|Windows Store|10.0'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm-uwp</VcpkgTriplet>
+ <!-- Update properties if using static libs-->
+ <PropertyGroup Condition="'$(VcpkgUseStatic)' == 'true'">
+ <VcpkgTripletTmp>$(VcpkgUserTriplet)</VcpkgTripletTmp>
+ <VcpkgTriplet>$(VcpkgTripletTmp)-static</VcpkgTriplet>
+ <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == '$(VcpkgRoot)\installed\$(VcpkgTripletTmp)\'">$(VcpkgRoot)\installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
+ <VcpkgTripletTmp />
</PropertyGroup>
- <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm64|Windows Store|10.0'">
- <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
- <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">arm64-uwp</VcpkgTriplet>
+ <PropertyGroup Condition="'$(VcpkgUseStatic)' != 'true'">
+ <VcpkgTripletTmp>$(VcpkgTriplet)</VcpkgTripletTmp>
+ <VcpkgTriplet Condition="'$(VcpkgTriplet)'!='$(VcpkgUserTriplet)'">$(VcpkgUserTriplet)</VcpkgTriplet>
+ <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == '$(VcpkgRoot)\installed\$(VcpkgTripletTmp)\'">$(VcpkgRoot)\installed\$(VcpkgUserTriplet)\</VcpkgCurrentInstalledDir>
+ <VcpkgTripletTmp />
</PropertyGroup>
<PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
- <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration>
- <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\</VcpkgRoot>
<VcpkgRoot Condition="!$(VcpkgRoot.EndsWith('\'))">$(VcpkgRoot)\</VcpkgRoot>
- <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
<VcpkgCurrentInstalledDir Condition="!$(VcpkgCurrentInstalledDir.EndsWith('\'))">$(VcpkgCurrentInstalledDir)\</VcpkgCurrentInstalledDir>
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
- <!-- Deactivate Autolinking if lld is used as a linker. (Until a better way to solve the problem is found!).
+ <!-- Deactivate Autolinking if lld is used as a linker. (Until a better way to solve the problem is found!).
Tried to add /lib as a parameter to the linker call but was unable to find a way to pass it as the first parameter. -->
<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true' and '$(VcpkgAutoLink)' == ''">false</VcpkgAutoLink>
</PropertyGroup>
@@ -79,8 +73,8 @@
</ItemDefinitionGroup>
<Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile">
- <Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDir)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/>
- <Message Text="Not using Vcpkg because VcpkgEnabled is &quot;$(VcpkgEnabled)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/>
+ <Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDir)&quot;" Importance="High" Condition="'$(VcpkgEnabled)' == 'true'"/>
+ <Message Text="Not using Vcpkg because VcpkgEnabled is &quot;$(VcpkgEnabled)&quot;" Importance="High" Condition="'$(VcpkgEnabled)' != 'true'"/>
<Message Text="Vcpkg is unable to link because we cannot decide between Release and Debug libraries. Please define the property VcpkgConfiguration to be 'Release' or 'Debug' (currently '$(VcpkgConfiguration)')." Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgNormalizedConfiguration)' == ''"/>
</Target>
@@ -104,4 +98,4 @@
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
</ItemGroup>
</Target>
-</Project>
+</Project> \ No newline at end of file