[vcpkg.targets] Allow specifying the root for the installed directory#49738
[vcpkg.targets] Allow specifying the root for the installed directory#49738stinos wants to merge 1 commit intomicrosoft:masterfrom
Conversation
In manifest mode overriding VcPkgInstalledDir leads to each triplet being put in that directory so if VcPkgInstalledDir isn't unique per triplet, each ends up in the same directory. That isn't intended vcpkg usage and hence causes various build issues. The user could circumvent that by crafting a unique VcPkgInstalledDir for each triplet - which is exactly what vcpkg.targets does already when deriving the VcPkgTriplet value - but the user would need to do that manually since they don't have access to VcPkgTriplet before importing vcpkg.targets, and afterwards it is too late. So introduce a new property VcpkgInstalledDirRoot which allows the user to specify where they want the installed directory, but append the VcPkgTriplet subdirectory to it. This is fully backwards compatible since this root defaults to $(VcpkgManifestRoot)/vcpkg_installed and that is what was used already.
|
@microsoft-github-policy-service agree |
|
The paths vcpkg chooses for these are chosen carefully to avoid multiple vcxprojs and/or multiple platform settings stomping on each other. This ends up being kind of a meaningful feature ask as a result. Can you provide:
and then mark 'Ready for Review'? |
Here's an illustration of the problem already. In short: fairly standard project, one configuration using Multithreaded Debug Dll, the other using Multithreaded Debug, with corresponding Building in a VS2022 x64 command prompt, vcpkg config was added using resulting in vcpkg.json and vcpkg-configuration.json Now build each configuration - irrelevant output omitted: This was the normal and expected output. Now add the following into the .vcxproj, in the PropertyGroup with label Vcpkg, to illustrate the issue: vcpkg puts everything in the same directory and by doing so deletes the previous triplets' files plus confuses the up-to-date tracking. Build output: So far so good, but now build the Debug configuration again: Note this can be resolved by removing the .stamp files to force vcpkg has to go through the install process again, but that's not really a solution because of the time that takes. |
|
Docs update added in MicrosoftDocs/vcpkg-docs#566. To continue from previous comment: instead of changing Result: |
|
Your writeup above is a great example of how the option works and the docs PR is great, thank you! What I'm missing is really the problem being solved: why is
kinda takes it as a given that that value is set to something dangerous. |
Right maybe that should be in the docs as well. I prefer out of tree artefacts for everything. It's a habit of which I don't actually remember the origin but putting everything next to the project file means for example:
Also, though I still have to experiment with it, if pointing VcpkgInstalledDir to the same directory for multiple projects works then a package has to be built only once even when multiple projects depend on it. |
In manifest mode overriding VcPkgInstalledDir leads to each triplet being put in that directory so if VcPkgInstalledDir isn't unique per triplet, each ends up in the same directory. That isn't intended vcpkg usage and hence causes various build issues.
The user could circumvent that by crafting a unique VcPkgInstalledDir for each triplet - which is exactly what vcpkg.targets does already when deriving the VcPkgTriplet value - but the user would need to do that manually since they don't have access to VcPkgTriplet before importing vcpkg.targets, and afterwards it is too late.
So introduce a new property VcpkgInstalledDirRoot which allows the user to specify where they want the installed directory, but append the VcPkgTriplet subdirectory to it. This is fully backwards compatible since this root defaults to $(VcpkgManifestRoot)/vcpkg_installed and that is what was used already.
Note: the alternative (which is the behavior I assumed vcpkg would have) would be that when the user specifies VcPkgInstalledDir in manifest mode, vcpkg.targets appends VcpkgTriplet to it then uses that as actual installed directory, but that's not backwards compatible.