A build dependency for Cargo libraries to find libraries in a vcpkg tree.
A number of environment variables are available to globally configure which libraries are selected.
-
VCPKG_ROOT
- Set the directory to look in for a vcpkg installation. If it is not set, vcpkg will use the user-wide installation if one has been set up withvcpkg integrate install
-
FOO_NO_VCPKG
- if set, vcpkg will not attempt to find the library namedfoo
.
There are also a number of environment variables which can configure how a
library is linked to (dynamically vs statically). These variables control
whether the --static
flag is passed. Note that this behavior can be
overridden by configuring explicitly on Config
. The variables are checked
in the following order:
FOO_STATIC
- find the static version offoo
FOO_DYNAMIC
- find the dll version offoo
VCPKG_ALL_STATIC
- find the static version of all librariesVCPKG_ALL_DYNAMIC
- find the dll version of all libraries
If the search was successful all appropriate Cargo metadata will be printed on stdout.
This cargo build helper is derived from and intended to work like the
pkg-config
build helper to the extent that is possible, but pkg-config
the tool has functionality that vcpkg
does not. In particular, vcpkg
does not allow mapping from a package name to the libs that it provides,
so this build helper must be called once for each library that is required
rather than once for the overall package. A better interface is no doubt
possible.
There is a companion crate vcpkg_cli
that allows testing of environment
and flag combinations.
C:\src> vcpkg_cli probe -l static mysqlclient
Found library mysqlclient
Include paths:
C:\src\diesel_build\vcpkg-dll\installed\x64-windows-static\include
Library paths:
C:\src\diesel_build\vcpkg-dll\installed\x64-windows-static\lib
Cargo metadata:
cargo:rustc-link-search=native=C:\src\diesel_build\vcpkg-dll\installed\x64-windows-static\lib
cargo:rustc-link-lib=static=mysqlclient