mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 20:13:07 +08:00
[vcpkg] Repair msbuild damage and workaround the way we integrate on VS2015. (#19767)
* Repair msbuild damage and workaround the way we integrate on VS2015. This is a fix for a pile of issues discovered by https://github.com/microsoft/vcpkg/pull/18906 * VS 2015 has a bug that the <VcpkgInstalledDir Condition="!$(VcpkgInstalledDir.EndsWith('\'))">$(VcpkgInstalledDir)\</VcpkgInstalledDir> dance we do to get a trailing slash is not applied correctly when VcpkgInstalledDir was edited in the same property group attempting to add the trailing slash. * We need a trailing slash on VcpkgInstalledDir at all times, but https://github.com/microsoft/vcpkg/pull/16173 damaged this by removing it from TreatAsLocalProperty. Add the right TreatAsLocalPropertys back. Add all such slash defenses to the top of the file just beneath, eliminating need to call Path::Combine and friends by following msbuild "directory properties have a trailing slash" convention. * Move VcpkgOSTarget and VcpkgPlatformTarget into the .targets, as they aren't intended to be overridable by users and don't appear in our selection dialog box(es). * Don't bother avoiding setting vcpkg properties when VcpkgEnabled is off; after all, VcpkgEnabled is itself a vcpkg property :). I left attempts to skip creating items since creating items can hit the disk. * Add _Z to several internal msbuild variables. * Move VcpkgApplocalDeps to the .props since it's a user setting. * Don't unconditionally use $(TLogLocation) because it is not set on 2015, and also it's per-project. * Fixed typo in docs "VcpkgInstalledDirectory", and document the limitation that it doesn't work in 2015. * In manifest mode, put the installed tree in a subdirectory including the triplet to make changing configurations faster. Known limitations: * If you change vcpkg.json without changing any .cpp files, we don't rebuild the dependencies even though we should. I don't know how to fix this but it doesn't appear to be a regression. * Fix .tlog handling. * Further defend against modified properties on VS2015. * Document more VS2015 limitations. * Remove TreatAsLocalProperty comment.
This commit is contained in:
parent
7734e8b89d
commit
97e7ac8d74
@ -441,7 +441,7 @@ See the `--feature-flags=` command line option for more information.
|
|||||||
## MSBuild Integration
|
## MSBuild Integration
|
||||||
|
|
||||||
To use manifests with MSBuild, first you need to use an [existing integration method](integration.md#with-msbuild).
|
To use manifests with MSBuild, first you need to use an [existing integration method](integration.md#with-msbuild).
|
||||||
Then, simply add a vcpkg.json above your project file (such as in the root of your source repository) and set the
|
Then, add a vcpkg.json above your project file (such as in the root of your source repository) and set the
|
||||||
property `VcpkgEnableManifest` to `true`. You can set this property via the IDE in `Project Properties -> Vcpkg -> Use
|
property `VcpkgEnableManifest` to `true`. You can set this property via the IDE in `Project Properties -> Vcpkg -> Use
|
||||||
Vcpkg Manifest`.
|
Vcpkg Manifest`.
|
||||||
|
|
||||||
@ -453,9 +453,21 @@ Note: It is critical that all project files in a single build consuming the same
|
|||||||
you need to use different triplets for different projects in your solution, they must consume from different
|
you need to use different triplets for different projects in your solution, they must consume from different
|
||||||
`vcpkg.json` files.
|
`vcpkg.json` files.
|
||||||
|
|
||||||
|
### Known issues
|
||||||
|
|
||||||
|
* Visual Studio 2015 does not correctly track edits to the `vcpkg.json` and `vcpkg-configuration.json` files, and will
|
||||||
|
not respond to changes unless a `.cpp` is edited.
|
||||||
|
|
||||||
### MSBuild Properties
|
### MSBuild Properties
|
||||||
|
|
||||||
These properties can be defined via the VS GUI under `Project Properties -> Vcpkg` or via a common `.props` file.
|
When using Visual Studio 2015 integration, these properties can be set in your project file before the
|
||||||
|
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
|
||||||
|
line, which unfortunately requires manual editing of the `.vcxproj` or passing on the msbuild command line with `/p:`.
|
||||||
|
With 2017 or later integration, These properties can additionally be set via the Visual Studio GUI under
|
||||||
|
`Project Properties -> Vcpkg` or via a common `.props` file imported between `Microsoft.Cpp.props` and
|
||||||
|
`Microsoft.Cpp.targets`.
|
||||||
|
|
||||||
#### `VcpkgEnabled` (Use Vcpkg)
|
#### `VcpkgEnabled` (Use Vcpkg)
|
||||||
|
|
||||||
@ -495,7 +507,7 @@ vcpkg.json files will be ignored. This will default to true in the future.
|
|||||||
This property can be set to "false" to disable automatic dependency restoration on project build. Dependencies can be
|
This property can be set to "false" to disable automatic dependency restoration on project build. Dependencies can be
|
||||||
manually restored via the vcpkg command line.
|
manually restored via the vcpkg command line.
|
||||||
|
|
||||||
#### `VcpkgInstalledDirectory` (Installed Directory)
|
#### `VcpkgInstalledDir` (Installed Directory)
|
||||||
|
|
||||||
This property defines the location where headers and binaries are consumed from. In manifest mode, this directory is
|
This property defines the location where headers and binaries are consumed from. In manifest mode, this directory is
|
||||||
created and populated based on your manifest.
|
created and populated based on your manifest.
|
||||||
|
@ -1,34 +1,21 @@
|
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<!-- Do not define derived properties here. This file may be imported once and some of the properties below may be overridden afterwards -->
|
<!-- Do not define derived properties here. This file may be imported once and some of the properties below may be overridden afterwards -->
|
||||||
|
|
||||||
<!-- Set default OS Target-->
|
|
||||||
<PropertyGroup Condition="'$(VcpkgOSTarget)' == ''">
|
|
||||||
<VcpkgOSTarget>windows</VcpkgOSTarget>
|
|
||||||
<VcpkgOSTarget Condition="'$(AppContainerApplication)' == 'true'">uwp</VcpkgOSTarget>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Set default Platform Target. $(PlatformTarget) is not available at the top of the .vcxproj file. -->
|
|
||||||
<PropertyGroup Condition="'$(VcpkgPlatformTarget)' == ''">
|
|
||||||
<VcpkgPlatformTarget>$(Platform)</VcpkgPlatformTarget>
|
|
||||||
<VcpkgPlatformTarget Condition="'$(Platform)' == 'Win32'">x86</VcpkgPlatformTarget>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VcpkgPropsImported>true</VcpkgPropsImported>
|
<VcpkgPropsImported>true</VcpkgPropsImported>
|
||||||
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
|
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
|
||||||
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
|
<VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration>
|
||||||
<VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
|
<VcpkgUseStatic Condition="'$(VcpkgUseStatic)' == ''">false</VcpkgUseStatic>
|
||||||
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..\..\..'))</VcpkgRoot>
|
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\..'))</VcpkgRoot>
|
||||||
|
|
||||||
<VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
|
<VcpkgAutoLink Condition="'$(VcpkgAutoLink)' == ''">true</VcpkgAutoLink>
|
||||||
<!-- 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. -->
|
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'">false</VcpkgAutoLink>
|
<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true'">false</VcpkgAutoLink>
|
||||||
|
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
|
||||||
|
|
||||||
<!-- Manifest files -->
|
<!-- Manifest files -->
|
||||||
<VcpkgEnableManifest Condition="'$(VcpkgEnableManifest)' == ''">false</VcpkgEnableManifest>
|
<VcpkgEnableManifest Condition="'$(VcpkgEnableManifest)' == ''">false</VcpkgEnableManifest>
|
||||||
<VcpkgManifestInstall Condition="'$(VcpkgManifestInstall)' == ''">true</VcpkgManifestInstall>
|
<VcpkgManifestInstall Condition="'$(VcpkgManifestInstall)' == ''">true</VcpkgManifestInstall>
|
||||||
<VcpkgManifestRoot Condition="'$(VcpkgManifestRoot)' == ''">$([MSbuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), vcpkg.json))</VcpkgManifestRoot>
|
<VcpkgManifestRoot Condition="'$(VcpkgManifestRoot)' == ''">$([MSbuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), vcpkg.json))</VcpkgManifestRoot>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,53 +1,91 @@
|
|||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgConfigSubdir;_ZVcpkgCurrentInstalledDir;VcpkgNormalizedConfiguration">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
|
||||||
<!-- Import default properties if not done yet. This does not overwrite any previously defined properties. -->
|
<!-- Import default properties if not done yet. This does not overwrite any previously defined properties. -->
|
||||||
<Import Condition="'$(VcpkgPropsImported)' != 'true'" Project="vcpkg.props" />
|
<Import Condition="'$(VcpkgPropsImported)' != 'true'" Project="vcpkg.props" />
|
||||||
|
|
||||||
<!-- Define properties derived from those defined in vcpkg.props, in the project file or specified on the command line. -->
|
<!-- VS2015's version of "vcpkg integrate install" imports both the props and targets together in the "props" area,
|
||||||
<PropertyGroup>
|
meaning we have no opportunity to respond to user customizations in their project files. It also means that this
|
||||||
<!-- Note: Overwrite VcpkgPageSchema with a non-existing path to disable the VcPkg property sheet in your projects -->
|
.targets must defend against normal properties being unset. (For example, VcpkgPlatformTarget below.)
|
||||||
<VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$([System.IO.Path]::Combine($(VcpkgRoot), 'scripts\buildsystems\msbuild\vcpkg-general.xml'))</VcpkgPageSchema>
|
|
||||||
|
Also, we copy all initial values to internal values to avoid properties being inconsistently evaluated in targets
|
||||||
|
and dependent properties.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgRoot>$(VcpkgRoot)</_ZVcpkgRoot>
|
||||||
|
<_ZVcpkgManifestRoot>$(VcpkgManifestRoot)</_ZVcpkgManifestRoot>
|
||||||
|
<_ZVcpkgInstalledDir>$(VcpkgInstalledDir)</_ZVcpkgInstalledDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
<!-- Add trailing slashes to inputs that must have them to conform with msbuild conventions. -->
|
||||||
<!-- Triplet defining platform, OS, and linkage -->
|
<PropertyGroup>
|
||||||
<VcpkgLinkage />
|
<_ZVcpkgRoot Condition="!$(_ZVcpkgRoot.EndsWith('\'))">$(_ZVcpkgRoot)\</_ZVcpkgRoot>
|
||||||
<VcpkgLinkage Condition="'$(VcpkgUseStatic)' == 'true'">-static</VcpkgLinkage>
|
<_ZVcpkgManifestRoot Condition="'$(_ZVcpkgManifestRoot)' != '' and !$(_ZVcpkgManifestRoot.EndsWith('\'))">$(_ZVcpkgManifestRoot)\</_ZVcpkgManifestRoot>
|
||||||
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(VcpkgLinkage)</VcpkgTriplet>
|
<_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' != '' and !$(_ZVcpkgInstalledDir.EndsWith('\'))">$(_ZVcpkgInstalledDir)\</_ZVcpkgInstalledDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<VcpkgRoot Condition="'$(VcpkgRoot)' != '' and !$(VcpkgRoot.EndsWith('\'))">$(VcpkgRoot)\</VcpkgRoot>
|
<!-- Determine the triplet to use. Note that $(PlatformTarget) is not available at the top of the .vcxproj file. -->
|
||||||
<VcpkgManifestRoot Condition="'$(VcpkgManifestRoot)' != '' and !$(VcpkgManifestRoot.EndsWith('\'))">$(VcpkgManifestRoot)\</VcpkgManifestRoot>
|
<PropertyGroup Condition="'$(VcpkgOSTarget)' == ''">
|
||||||
|
<VcpkgOSTarget>windows</VcpkgOSTarget>
|
||||||
|
<VcpkgOSTarget Condition="'$(AppContainerApplication)' == 'true'">uwp</VcpkgOSTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<VcpkgInstalledDir Condition="'$(VcpkgInstalledDir)' == '' and '$(VcpkgEnableManifest)' != 'true'">$([System.IO.Path]::Combine($(VcpkgRoot), 'installed'))</VcpkgInstalledDir>
|
<PropertyGroup Condition="'$(VcpkgPlatformTarget)' == ''">
|
||||||
<VcpkgInstalledDir Condition="'$(VcpkgInstalledDir)' == '' and '$(VcpkgEnableManifest)' == 'true'">$([System.IO.Path]::Combine($(VcpkgManifestRoot), 'vcpkg_installed'))</VcpkgInstalledDir>
|
<VcpkgPlatformTarget>$(Platform)</VcpkgPlatformTarget>
|
||||||
<VcpkgInstalledDir Condition="!$(VcpkgInstalledDir.EndsWith('\'))">$(VcpkgInstalledDir)\</VcpkgInstalledDir>
|
<VcpkgPlatformTarget Condition="'$(Platform)' == 'Win32'">x86</VcpkgPlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<_ZVcpkgCurrentInstalledDir>$([System.IO.Path]::Combine($(VcpkgInstalledDir), $(VcpkgTriplet)))</_ZVcpkgCurrentInstalledDir>
|
<PropertyGroup>
|
||||||
<_ZVcpkgCurrentInstalledDir Condition="!$(_ZVcpkgCurrentInstalledDir.EndsWith('\'))">$(_ZVcpkgCurrentInstalledDir)\</_ZVcpkgCurrentInstalledDir>
|
<_ZVcpkgLinkage />
|
||||||
|
<_ZVcpkgLinkage Condition="'$(VcpkgUseStatic)' == 'true'">-static</_ZVcpkgLinkage>
|
||||||
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration>
|
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">$(VcpkgPlatformTarget)-$(VcpkgOSTarget)$(_ZVcpkgLinkage)</VcpkgTriplet>
|
||||||
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration>
|
</PropertyGroup>
|
||||||
|
|
||||||
<VcpkgConfigSubdir Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug'">debug\</VcpkgConfigSubdir>
|
|
||||||
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
|
|
||||||
|
|
||||||
<_ZVcpkgHostTripletParameter Condition="'$(VcpkgHostTriplet)' != ''">"--host-triplet=$(VcpkgHostTriplet)"</_ZVcpkgHostTripletParameter>
|
|
||||||
<_ZVcpkgExecutable>$([System.IO.Path]::Combine($(VcpkgRoot), 'vcpkg.exe'))</_ZVcpkgExecutable>
|
|
||||||
|
|
||||||
|
<!-- Include the triplet in ProjectStateLine to force VS2017 and later to fully rebuild if the user changes it. -->
|
||||||
|
<PropertyGroup>
|
||||||
<ProjectStateLine>VcpkgTriplet=$(VcpkgTriplet):$(ProjectStateLine)</ProjectStateLine>
|
<ProjectStateLine>VcpkgTriplet=$(VcpkgTriplet):$(ProjectStateLine)</ProjectStateLine>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Import property page 'Vcpkg' -->
|
<!-- Determine the locations trees we want to consume. _ZVcpkgInstalledDir is special in that it doesn't have a default
|
||||||
<ItemGroup Condition="'$(VcpkgPageSchema)' != '' and exists('$(VcpkgPageSchema)')">
|
value in the .props because we normally derive it, but users may override the value. -->
|
||||||
|
<Choose>
|
||||||
|
<When Condition="'$(VcpkgEnableManifest)' == 'true'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgManifestRoot)vcpkg_installed\$(VcpkgTriplet)\</_ZVcpkgInstalledDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<Otherwise>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgInstalledDir Condition="'$(_ZVcpkgInstalledDir)' == ''">$(_ZVcpkgRoot)installed\</_ZVcpkgInstalledDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Otherwise>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgCurrentInstalledDir>$(_ZVcpkgInstalledDir)\$(VcpkgTriplet)\</_ZVcpkgCurrentInstalledDir>
|
||||||
|
<_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</_ZVcpkgNormalizedConfiguration>
|
||||||
|
<_ZVcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</_ZVcpkgNormalizedConfiguration>
|
||||||
|
|
||||||
|
<_ZVcpkgConfigSubdir Condition="'$(_ZVcpkgNormalizedConfiguration)' == 'Debug'">debug\</_ZVcpkgConfigSubdir>
|
||||||
|
<_ZVcpkgExecutable>$(_ZVcpkgRoot)vcpkg.exe</_ZVcpkgExecutable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Note: Overwrite VcpkgPageSchema with a non-existing path to disable the VcPkg property sheet in your projects -->
|
||||||
|
<VcpkgPageSchema Condition="'$(VcpkgPageSchema)' == ''">$(_ZVcpkgRoot)scripts\buildsystems\msbuild\vcpkg-general.xml</VcpkgPageSchema>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(VcpkgPageSchema)' != '' and exists('$(VcpkgPageSchema)') and '$(MSBuildToolsVersion)' != '14.0'">
|
||||||
<PropertyPageSchema Include="$(VcpkgPageSchema)">
|
<PropertyPageSchema Include="$(VcpkgPageSchema)">
|
||||||
<Context>Project</Context>
|
<Context>Project</Context>
|
||||||
</PropertyPageSchema>
|
</PropertyPageSchema>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Install settings to get headers and import libs for the currently selected _ZVcpkgCurrentInstalledDir -->
|
||||||
<ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
<ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies Condition="'$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\*.lib</AdditionalDependencies>
|
<AdditionalDependencies Condition="'$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\*.lib</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\manual-link</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\manual-link</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories>
|
||||||
@ -59,9 +97,9 @@
|
|||||||
|
|
||||||
<Target Name="VcpkgCheckManifestRoot" BeforeTargets="VcpkgInstallManifestDependencies" Condition="'$(VcpkgEnabled)' == 'true'">
|
<Target Name="VcpkgCheckManifestRoot" BeforeTargets="VcpkgInstallManifestDependencies" Condition="'$(VcpkgEnabled)' == 'true'">
|
||||||
<Error Text="The vcpkg manifest was enabled, but we couldn't find a manifest file (vcpkg.json) in any directories above $(MSBuildProjectDirectory). Please add a manifest, disable manifests in your properties page, or pass /p:VcpkgEnableManifest=false."
|
<Error Text="The vcpkg manifest was enabled, but we couldn't find a manifest file (vcpkg.json) in any directories above $(MSBuildProjectDirectory). Please add a manifest, disable manifests in your properties page, or pass /p:VcpkgEnableManifest=false."
|
||||||
Condition="'$(VcpkgEnableManifest)' == 'true' and '$(VcpkgManifestRoot)' == ''" />
|
Condition="'$(VcpkgEnableManifest)' == 'true' and '$(_ZVcpkgManifestRoot)' == ''" />
|
||||||
<Message Text="The vcpkg manifest was disabled, but we found a manifest file in $(VcpkgManifestRoot). You may want to enable vcpkg manifests in your properties page or pass /p:VcpkgEnableManifest=true to the msbuild invocation."
|
<Message Text="The vcpkg manifest was disabled, but we found a manifest file in $(_ZVcpkgManifestRoot). You may want to enable vcpkg manifests in your properties page or pass /p:VcpkgEnableManifest=true to the msbuild invocation."
|
||||||
Importance="High" Condition="'$(VcpkgEnableManifest)' != 'true' and '$(VcpkgManifestRoot)' != ''" />
|
Importance="High" Condition="'$(VcpkgEnableManifest)' != 'true' and '$(_ZVcpkgManifestRoot)' != ''" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile">
|
<Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile">
|
||||||
@ -70,41 +108,52 @@
|
|||||||
<Message Text="Not using Vcpkg because VcpkgEnabled is "$(VcpkgEnabled)""
|
<Message Text="Not using Vcpkg because VcpkgEnabled is "$(VcpkgEnabled)""
|
||||||
Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/>
|
Importance="Normal" 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)')."
|
<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)' == ''"/>
|
Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(_ZVcpkgNormalizedConfiguration)' == ''"/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
<Choose>
|
||||||
<_ZVcpkgManifestFileLocation>$(VcpkgManifestRoot)vcpkg.json </_ZVcpkgManifestFileLocation>
|
<When Condition="'$(VcpkgHostTriplet)' != ''">
|
||||||
<_ZVcpkgConfigurationFileLocation>$(VcpkgManifestRoot)vcpkg-configuration.json</_ZVcpkgConfigurationFileLocation>
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgHostTripletParameter>"--host-triplet=$(VcpkgHostTriplet)"</_ZVcpkgHostTripletParameter>
|
||||||
|
<_ZVcpkgHostTripletSuffix>$(VcpkgHostTriplet).</_ZVcpkgHostTripletSuffix>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<Otherwise>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ZVcpkgHostTripletParameter />
|
||||||
|
<_ZVcpkgHostTripletSuffix />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Otherwise>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
<_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(VcpkgHostTriplet).read.1u.tlog</_ZVcpkgTLogFileLocation>
|
<PropertyGroup>
|
||||||
<_ZVcpkgMSBuildStampFile>$(VcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(VcpkgHostTriplet).stamp</_ZVcpkgMSBuildStampFile>
|
<_ZVcpkgManifestFileLocation>$(_ZVcpkgManifestRoot)vcpkg.json</_ZVcpkgManifestFileLocation>
|
||||||
|
<_ZVcpkgConfigurationFileLocation>$(_ZVcpkgManifestRoot)vcpkg-configuration.json</_ZVcpkgConfigurationFileLocation>
|
||||||
|
<_ZVcpkgMSBuildStampFile>$(_ZVcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)stamp</_ZVcpkgMSBuildStampFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
<ItemGroup Condition="'$(VcpkgEnabled)' == 'true'">
|
||||||
<_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgManifestFileLocation)"/>
|
<_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgManifestFileLocation)"/>
|
||||||
<_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgConfigurationFileLocation)" Condition="Exists('$(_ZVcpkgConfigurationFileLocation)')"/>
|
<_ZVcpkgInstallManifestDependenciesInputs Include="$(_ZVcpkgConfigurationFileLocation)" Condition="Exists('$(_ZVcpkgConfigurationFileLocation)')"/>
|
||||||
|
|
||||||
<_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgTLogFileLocation)"/>
|
|
||||||
<_ZVcpkgInstallManifestDependenciesOutputs Include="$(_ZVcpkgMSBuildStampFile)"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="VcpkgInstallManifestDependencies" BeforeTargets="ClCompile"
|
<Target Name="VcpkgInstallManifestDependencies" BeforeTargets="ClCompile"
|
||||||
Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgEnableManifest)' == 'true' and '$(VcpkgManifestInstall)' == 'true'"
|
Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgEnableManifest)' == 'true' and '$(VcpkgManifestInstall)' == 'true'"
|
||||||
Inputs="@(_ZVcpkgInstallManifestDependenciesInputs)"
|
Inputs="@(_ZVcpkgInstallManifestDependenciesInputs)"
|
||||||
Outputs="@(_ZVcpkgInstallManifestDependenciesOutputs)">
|
Outputs="$(_ZVcpkgMSBuildStampFile)">
|
||||||
<Message Text="Installing vcpkg dependencies to $(VcpkgInstalledDir)" Importance="High" />
|
<!-- This is set inside the target because $(TLogLocation) may not be set yet when parsing the .targets on VS2015 -->
|
||||||
<MakeDir Directories="$(TLogLocation)" />
|
<PropertyGroup>
|
||||||
<ItemGroup>
|
<_ZVcpkgTLogFileLocation>$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).$(_ZVcpkgHostTripletSuffix)read.1u.tlog</_ZVcpkgTLogFileLocation>
|
||||||
<_ZVcpkgItemToDelete Include="$(TLogLocation)VcpkgInstallManifest*.read.1u.tlog" />
|
</PropertyGroup>
|
||||||
<_ZVcpkgItemToDelete Include="$(VcpkgInstalledDir).msbuildstamp-*" />
|
<Message Text="Installing vcpkg dependencies to $(_ZVcpkgInstalledDir)" Importance="High" />
|
||||||
</ItemGroup>
|
<MakeDir Directories="$(_ZVcpkgInstalledDir)" />
|
||||||
<Delete Files="@(_ZVcpkgItemToDelete)" />
|
<Delete Files="$(_ZVcpkgMSBuildStampFile)" />
|
||||||
<Message Text="%22$(_ZVcpkgExecutable)%22 install $(_ZVcpkgHostTripletParameter) --x-wait-for-lock --triplet %22$(VcpkgTriplet)%22 --vcpkg-root %22$(VcpkgRoot)\%22 %22--x-manifest-root=$(VcpkgManifestRoot)\%22 %22--x-install-root=$(VcpkgInstalledDir)\%22 $(VcpkgAdditionalInstallOptions)"
|
<Message Text="%22$(_ZVcpkgExecutable)%22 install $(_ZVcpkgHostTripletParameter) --x-wait-for-lock --triplet %22$(VcpkgTriplet)%22 --vcpkg-root %22$(_ZVcpkgRoot)\%22 %22--x-manifest-root=$(_ZVcpkgManifestRoot)\%22 %22--x-install-root=$(_ZVcpkgInstalledDir)\%22 $(VcpkgAdditionalInstallOptions)"
|
||||||
Importance="High" />
|
Importance="High" />
|
||||||
<Exec Command="%22$(_ZVcpkgExecutable)%22 install $(_ZVcpkgHostTripletParameter) --x-wait-for-lock --triplet %22$(VcpkgTriplet)%22 --vcpkg-root %22$(VcpkgRoot)\%22 %22--x-manifest-root=$(VcpkgManifestRoot)\%22 %22--x-install-root=$(VcpkgInstalledDir)\%22 $(VcpkgAdditionalInstallOptions)"
|
<Exec Command="%22$(_ZVcpkgExecutable)%22 install $(_ZVcpkgHostTripletParameter) --x-wait-for-lock --triplet %22$(VcpkgTriplet)%22 --vcpkg-root %22$(_ZVcpkgRoot)\%22 %22--x-manifest-root=$(_ZVcpkgManifestRoot)\%22 %22--x-install-root=$(_ZVcpkgInstalledDir)\%22 $(VcpkgAdditionalInstallOptions)"
|
||||||
StandardOutputImportance="High" />
|
StandardOutputImportance="High" />
|
||||||
<WriteLinesToFile File="$(_ZVcpkgTLogFileLocation)"
|
<WriteLinesToFile File="$(_ZVcpkgTLogFileLocation)"
|
||||||
Lines="@(_VcpkgInstallManifestDependenciesInputs -> '^%(Identity)')"
|
Lines="@(_ZVcpkgInstallManifestDependenciesInputs -> '^%(Identity)')"
|
||||||
Encoding="Unicode"
|
Encoding="Unicode"
|
||||||
Overwrite="true"/>
|
Overwrite="true"/>
|
||||||
<Touch Files="$(_ZVcpkgMSBuildStampFile)" AlwaysCreate="true" />
|
<Touch Files="$(_ZVcpkgMSBuildStampFile)" AlwaysCreate="true" />
|
||||||
@ -118,40 +167,40 @@
|
|||||||
Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'">
|
Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'">
|
||||||
<Message Text="[vcpkg] Starting VcpkgApplocalDeps" Importance="low" />
|
<Message Text="[vcpkg] Starting VcpkgApplocalDeps" Importance="low" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_VcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"</_VcpkgAppLocalPowerShellCommonArguments>
|
<_ZVcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"</_ZVcpkgAppLocalPowerShellCommonArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- Search %PATH% for pwsh.exe if it is available. -->
|
<!-- Search %PATH% for pwsh.exe if it is available. -->
|
||||||
<Exec
|
<Exec
|
||||||
Command="pwsh.exe $(_VcpkgAppLocalPowerShellCommonArguments)"
|
Command="pwsh.exe $(_ZVcpkgAppLocalPowerShellCommonArguments)"
|
||||||
StandardOutputImportance="Normal"
|
StandardOutputImportance="Normal"
|
||||||
StandardErrorImportance="Normal"
|
StandardErrorImportance="Normal"
|
||||||
IgnoreExitCode="true"
|
IgnoreExitCode="true"
|
||||||
UseCommandProcessor="false">
|
UseCommandProcessor="false">
|
||||||
<Output TaskParameter="ExitCode"
|
<Output TaskParameter="ExitCode"
|
||||||
PropertyName="_VcpkgAppLocalExitCode" />
|
PropertyName="_ZVcpkgAppLocalExitCode" />
|
||||||
</Exec>
|
</Exec>
|
||||||
<!-- Fall back to well known system PowerShell location otherwise. -->
|
<!-- Fall back to well known system PowerShell location otherwise. -->
|
||||||
<Message Text="[vcpkg] Failed to run applocal.ps1 using pwsh, falling back to system PowerShell." Importance="low"
|
<Message Text="[vcpkg] Failed to run applocal.ps1 using pwsh, falling back to system PowerShell." Importance="low"
|
||||||
Condition="$(_VcpkgAppLocalExitCode) == 9009" />
|
Condition="$(_ZVcpkgAppLocalExitCode) == 9009" />
|
||||||
<Exec
|
<Exec
|
||||||
Command="%22$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe%22 $(_VcpkgAppLocalPowerShellCommonArguments)"
|
Command="%22$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe%22 $(_ZVcpkgAppLocalPowerShellCommonArguments)"
|
||||||
StandardOutputImportance="Normal"
|
StandardOutputImportance="Normal"
|
||||||
StandardErrorImportance="Normal"
|
StandardErrorImportance="Normal"
|
||||||
IgnoreExitCode="true"
|
IgnoreExitCode="true"
|
||||||
UseCommandProcessor="false"
|
UseCommandProcessor="false"
|
||||||
Condition="$(_VcpkgAppLocalExitCode) == 9009">
|
Condition="$(_ZVcpkgAppLocalExitCode) == 9009">
|
||||||
<Output TaskParameter="ExitCode"
|
<Output TaskParameter="ExitCode"
|
||||||
PropertyName="_VcpkgAppLocalExitCode" />
|
PropertyName="_ZVcpkgAppLocalExitCode" />
|
||||||
</Exec>
|
</Exec>
|
||||||
<!-- We're ignoring the above exit codes, so translate into a warning if both failed. -->
|
<!-- We're ignoring the above exit codes, so translate into a warning if both failed. -->
|
||||||
<Warning Text="[vcpkg] Failed to gather app local DLL dependencies, program may not run. Set VcpkgApplocalDeps to false in your project file to suppress this warning. PowerShell arguments: $(_VcpkgAppLocalPowerShellCommonArguments)"
|
<Warning Text="[vcpkg] Failed to gather app local DLL dependencies, program may not run. Set VcpkgApplocalDeps to false in your project file to suppress this warning. PowerShell arguments: $(_ZVcpkgAppLocalPowerShellCommonArguments)"
|
||||||
Condition="$(_VcpkgAppLocalExitCode) != 0"/>
|
Condition="$(_ZVcpkgAppLocalExitCode) != 0"/>
|
||||||
<ReadLinesFromFile File="$(IntDir)vcpkg.applocal.log"
|
<ReadLinesFromFile File="$(IntDir)vcpkg.applocal.log"
|
||||||
Condition="$(_VcpkgAppLocalExitCode) == 0">
|
Condition="$(_ZVcpkgAppLocalExitCode) == 0">
|
||||||
<Output TaskParameter="Lines" ItemName="VcpkgAppLocalDLLs" />
|
<Output TaskParameter="Lines" ItemName="VcpkgAppLocalDLLs" />
|
||||||
</ReadLinesFromFile>
|
</ReadLinesFromFile>
|
||||||
<Message Text="@(VcpkgAppLocalDLLs,'%0A')" Importance="Normal" Condition="$(_VcpkgAppLocalExitCode) == 0" />
|
<Message Text="@(VcpkgAppLocalDLLs,'%0A')" Importance="Normal" Condition="$(_ZVcpkgAppLocalExitCode) == 0" />
|
||||||
<ItemGroup Condition="$(_VcpkgAppLocalExitCode) == 0">
|
<ItemGroup Condition="$(_ZVcpkgAppLocalExitCode) == 0">
|
||||||
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
|
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
Loading…
Reference in New Issue
Block a user