diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2021-02-10 16:22:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-10 16:22:33 -0800 |
| commit | 8d7cd1d09ee522fc29f02b27fa93808edc66682a (patch) | |
| tree | 71ed2ce91a716802bf5509c4d281361b6e78209c | |
| parent | 545c165ce08bff237b1468f42b0607e899dab959 (diff) | |
| download | vcpkg-8d7cd1d09ee522fc29f02b27fa93808edc66682a.tar.gz vcpkg-8d7cd1d09ee522fc29f02b27fa93808edc66682a.zip | |
[vcpkg integrate install] Allow setting the vcpkg installed dir (#16173)
* [vcpkg integrate install] Allow setting the vcpkg installed dir
* fix the cache-y thing
* robert crs
| -rw-r--r-- | docs/users/manifests.md | 6 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/vcpkg-general.xml | 7 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/vcpkg.targets | 34 |
3 files changed, 26 insertions, 21 deletions
diff --git a/docs/users/manifests.md b/docs/users/manifests.md index 8f62ea81b..c5addbba7 100644 --- a/docs/users/manifests.md +++ b/docs/users/manifests.md @@ -15,7 +15,7 @@ rather than global to a system or user. In manifest mode, an installed tree is associated with a particular project rather than the vcpkg installation. The set of installed ports is controlled by editing the project's "manifest file", and the installed tree is placed in the project directory or build directory. -This mode acts more similarly to language package managers like Cargo, or npm. +This mode acts more similarly to language package managers like Cargo, or npm. We recommend using this manifest mode whenever possible, because it allows one to encode a project's dependencies explicitly in a project file, rather than in the documentation, making your project much easier to consume. @@ -351,3 +351,7 @@ This property must be set to true in order to consume from a local vcpkg.json fi 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. +#### `VcpkgInstalledDirectory` (Installed Directory) + +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. + diff --git a/scripts/buildsystems/msbuild/vcpkg-general.xml b/scripts/buildsystems/msbuild/vcpkg-general.xml index 0c32c4a84..49865e74e 100644 --- a/scripts/buildsystems/msbuild/vcpkg-general.xml +++ b/scripts/buildsystems/msbuild/vcpkg-general.xml @@ -55,11 +55,8 @@ </StringProperty.DataSource> </StringProperty> - <StringProperty Name="VcpkgCurrentInstalledDir" DisplayName="Package install directory" Category="General" Subtype="folder" Visible="false" - Description="Defines the direct path to the installed Vcpkg packages."> - <StringProperty.DataSource> - <DataSource Persistence="ProjectFile" Label="Vcpkg" HasConfigurationCondition="false" /> - </StringProperty.DataSource> + <StringProperty Name="VcpkgInstalledDir" DisplayName="Installed Directory" Category="General" Subtype="folder" Visible="true" + Description="The location where headers and binaries will be consumed from. In manifest mode, this directory will be created and populated based on vcpkg.json."> </StringProperty> <BoolProperty Name="VcpkgUseStatic" DisplayName="Use Static Libraries" Category="Conditional" Default="false" diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 196e52ddc..074d35d90 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -1,4 +1,4 @@ -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgConfigSubdir;VcpkgCurrentInstalledDir;VcpkgInstalledDir;VcpkgNormalizedConfiguration"> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="VcpkgConfigSubdir;_ZVcpkgCurrentInstalledDir;VcpkgNormalizedConfiguration"> <!-- Import default properties if not done yet. This does not overwrite any previously defined properties. --> <Import Condition="'$(VcpkgPropsImported)' != 'true'" Project="vcpkg.props" /> @@ -18,12 +18,12 @@ <VcpkgRoot Condition="'$(VcpkgRoot)' != '' and !$(VcpkgRoot.EndsWith('\'))">$(VcpkgRoot)\</VcpkgRoot> <VcpkgManifestRoot Condition="'$(VcpkgManifestRoot)' != '' and !$(VcpkgManifestRoot.EndsWith('\'))">$(VcpkgManifestRoot)\</VcpkgManifestRoot> - <VcpkgInstalledDir>$([System.IO.Path]::Combine($(VcpkgRoot), 'installed'))</VcpkgInstalledDir> - <VcpkgInstalledDir Condition="'$(VcpkgEnableManifest)' == 'true'">$([System.IO.Path]::Combine($(VcpkgManifestRoot), 'vcpkg_installed'))</VcpkgInstalledDir> + <VcpkgInstalledDir Condition="'$(VcpkgInstalledDir)' == '' and '$(VcpkgEnableManifest)' != 'true'">$([System.IO.Path]::Combine($(VcpkgRoot), 'installed'))</VcpkgInstalledDir> + <VcpkgInstalledDir Condition="'$(VcpkgInstalledDir)' == '' and '$(VcpkgEnableManifest)' == 'true'">$([System.IO.Path]::Combine($(VcpkgManifestRoot), 'vcpkg_installed'))</VcpkgInstalledDir> <VcpkgInstalledDir Condition="!$(VcpkgInstalledDir.EndsWith('\'))">$(VcpkgInstalledDir)\</VcpkgInstalledDir> - <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$([System.IO.Path]::Combine($(VcpkgInstalledDir), $(VcpkgTriplet)))</VcpkgCurrentInstalledDir> - <VcpkgCurrentInstalledDir Condition="!$(VcpkgCurrentInstalledDir.EndsWith('\'))">$(VcpkgCurrentInstalledDir)\</VcpkgCurrentInstalledDir> + <_ZVcpkgCurrentInstalledDir>$([System.IO.Path]::Combine($(VcpkgInstalledDir), $(VcpkgTriplet)))</_ZVcpkgCurrentInstalledDir> + <_ZVcpkgCurrentInstalledDir Condition="!$(_ZVcpkgCurrentInstalledDir.EndsWith('\'))">$(_ZVcpkgCurrentInstalledDir)\</_ZVcpkgCurrentInstalledDir> <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration> <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration> @@ -42,14 +42,14 @@ <ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'"> <Link> - <AdditionalDependencies Condition="'$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\*.lib</AdditionalDependencies> - <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(VcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib;$(VcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\manual-link</AdditionalLibraryDirectories> + <AdditionalDependencies Condition="'$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\*.lib</AdditionalDependencies> + <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)lib\manual-link</AdditionalLibraryDirectories> </Link> <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories> </ClCompile> <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(_ZVcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories> </ResourceCompile> </ItemDefinitionGroup> @@ -61,7 +61,7 @@ </Target> <Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile"> - <Message Text="Using triplet "$(VcpkgTriplet)" from "$(VcpkgCurrentInstalledDir)"" + <Message Text="Using triplet "$(VcpkgTriplet)" from "$(_ZVcpkgCurrentInstalledDir)"" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/> <Message Text="Not using Vcpkg because VcpkgEnabled is "$(VcpkgEnabled)"" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/> @@ -70,26 +70,30 @@ </Target> <ItemGroup> - <_VcpkgInstallManifestDependenciesInputs Include="$(VcpkgManifestRoot)vcpkg.json"/> - <_VcpkgInstallManifestDependenciesInputs Include="$(VcpkgManifestRoot)vcpkg-configuration.json" Condition="Exists('$(VcpkgManifestRoot)vcpkg-configuration.json')"/> + <_ZVcpkgInstallManifestDependenciesInputs Include="$(VcpkgManifestRoot)vcpkg.json"/> + <_ZVcpkgInstallManifestDependenciesInputs Include="$(VcpkgManifestRoot)vcpkg-configuration.json" Condition="Exists('$(VcpkgManifestRoot)vcpkg-configuration.json')"/> </ItemGroup> <Target Name="VcpkgInstallManifestDependencies" BeforeTargets="ClCompile" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgEnableManifest)' == 'true' and '$(VcpkgManifestInstall)' == 'true'" - Inputs="@(_VcpkgInstallManifestDependenciesInputs)" - Outputs="$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).read.1u.tlog"> + Inputs="@(_ZVcpkgInstallManifestDependenciesInputs)" + Outputs="$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).read.1u.tlog;$(VcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet)"> <Message Text="Installing vcpkg dependencies to $(VcpkgInstalledDir)" Importance="High" /> <MakeDir Directories="$(TLogLocation)" /> <ItemGroup> <_VcpkgItemToDelete Include="$(TLogLocation)VcpkgInstallManifest*.read.1u.tlog" /> + <_VcpkgItemToDelete Include="$(VcpkgInstalledDir).msbuildstamp-*" /> </ItemGroup> <Delete Files="@(_VcpkgItemToDelete)" /> + <Message Text="%22$([System.IO.Path]::Combine($(VcpkgRoot), 'vcpkg.exe'))%22 install --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)" + Importance="High" /> <Exec Command="%22$([System.IO.Path]::Combine($(VcpkgRoot), 'vcpkg.exe'))%22 install --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)" StandardOutputImportance="High" /> <WriteLinesToFile File="$(TLogLocation)VcpkgInstallManifest$(VcpkgTriplet).read.1u.tlog" Lines="@(_VcpkgInstallManifestDependenciesInputs -> '^%(Identity)')" Encoding="Unicode" Overwrite="true"/> + <Touch Files="$(VcpkgInstalledDir).msbuildstamp-$(VcpkgTriplet)" AlwaysCreate="true" /> <CreateProperty Value="false"> <Output TaskParameter="ValueSetByTask" PropertyName="Link_MinimalRebuildFromTracking" /> @@ -100,7 +104,7 @@ Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgApplocalDeps)' == 'true' and '$(LinkSkippedExecution)' != 'true'"> <Message Text="[vcpkg] Starting VcpkgApplocalDeps" Importance="low" /> <PropertyGroup> - <_VcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(VcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"</_VcpkgAppLocalPowerShellCommonArguments> + <_VcpkgAppLocalPowerShellCommonArguments>-ExecutionPolicy Bypass -noprofile -File "$(MSBuildThisFileDirectory)applocal.ps1" "$(TargetPath)" "$(_ZVcpkgCurrentInstalledDir)$(VcpkgConfigSubdir)bin" "$(TLogLocation)$(ProjectName).write.1u.tlog" "$(IntDir)vcpkg.applocal.log"</_VcpkgAppLocalPowerShellCommonArguments> </PropertyGroup> <!-- Search %PATH% for pwsh.exe if it is available. --> <Exec |
