[vcpkg] Add special functions for wrappers#21783
[vcpkg] Add special functions for wrappers#21783dg0yt wants to merge 5 commits intomicrosoft:masterfrom
Conversation
|
Is there a reason you use the complicated way instead of doing two |
I hoped to explain it in the top post. Basically, I want to put the responsibility for correct vpckg library lookup into a single place, instead of scattering it over all wrappers. Again taking the gdal example. We come from: Problem: Doesn't systematically respect VCPKG_PREFER_SYSTEM_LIBS. Doesn't systematically find the vcpkg lib when gdal is built only for release. (Needed to avoid picking a non-vcpkg debug lib. There will be another You propose (and I add Problem: Doesn't systematically respect VCPKG_PREFER_SYSTEM_LIBS. Verbose syntax. I propose: Problem: Needs helper functions. (This PR.) ... and everything duplicated for release, and done in every wrapper. |
No i mean that you do two |
Okay. This leaves the problem that it doesn't respect This search order is the problem which is reliably addressed by locally inserting the configuration-specific item before the first occurence of the wrong item. This construction doesn't need particular parameters to |
I would say people should use empty overlays in this case since it is the only way to not screw up the binary cache ... |
I tend to agree. Mixing system libraries with vcpkg invites undefined behaviour at runtime. But |
|
@dg0yt Could you please handle the conflict? |
Done. But this is a PR for discussion. Merge conflicts can be resolved after discussion. Added two more functions. |
I think this (and linked issue) has exposed fundamental problems with VCPKG_PREFER_SYSTEM_LIBS. This suggests to me that we should instead deprecate it, emit a warning, and instruct users that they should use empty overlay ports to correctly stub out system libraries. |
|
Ping @ras0219-msft for review again. |
|
@dg0yt Could you please handle the conflicts? Thank you! |
|
Pinging @dg0yt for response. Is work still being done for this PR? |
|
I'm going to resolve the merge conflicts soon. But this PR is really waiting for feedback from @ras0219-msft since December. |
|
@dg0yt Could you please handle the conflicts? Thank you! |
|
I tend to withdraw the proposed special functions. |
|
If we consider defining Adding these special functions helps to make this illegal scenario less ambiguous, but I'm not sure they're worth their weight in that scenario since there are no longer other policies they need to implement and regularize. I would like to merge the |
-> #26449 |
This PR complements #21641 by an improved way for library lookup in cmake wrappers. If accepted, existing wrapper should be update for unified behaviour.
What does your PR fix?
The vcpkg cmake toolchain respectsVCPKG_PREFER_SYSTEM_LIBSwhen modifyingCMAKE_PREFIX_PATH,CMAKE_LIBRARY_PATHandCMAKE_FIND_ROOT_PATH.However, it is hard to respect this preference correctly in wrappers when looking specifically for debug or release variants of libraries. Current wrappers provide explicit paths and so completely igore
VCPKG_PREFER_SYSTEM_LIBS. This is inconsistent with behaviour for ports which do not need wrappers.In addition, it is difficult to deal with the fact that custom triplets may set a specific
VCPKG_BUILD_TYPEfor some ports.This PR adds two high level functions which can be used in wrappers before and after
_find_package. Two low level functions are used instead of plainfind_libraryin order to consistently respectVCPKG_PREFER_SYSTEM_LIBS.As an example and test case, port gdal's wrapper is updated to use these functions.
Limitations: WithVCPKG_PREFER_SYSTEM_LIBSactivated, variations in library names may still lead to inconsistencies (e.g. release variant from system, debug variant from vcpkg). However, the user can directly initialize the cache variables to system variants if needed.)Which triplets are supported/not supported? Have you updated the CI baseline?
all, no
Does your PR follow the maintainer guide?
yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --alland committed the result?yes