Crate vcpkg [−] [src]
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.
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
there is a test of diesel and it's dependencies that should be easy to set up at https://github.com/mcgoo/vcpkg_diesel_build check out that project and then
make_vcpkg_static build_diesel_static
or
make_vcpkg_dll build_diesel_dll
and you should get a working binary.
more notes for this work in progress :-
could run vcpkg and parse it's output to determine what package versions are installed. at present it just generates plausible link lines
vcpkg has common include and lib dirs so there is a chance that someone is going to end up picking up a vcpkg lib on their link line in preference to some other version at some point. I believe cmake handles this by using absolute paths for libs wherever possible.
vcpkg has a per-package output dir that looks like it would be helpful, but at present it is undocumented and subject to change. (what I read mentioned the possibility of compressing the contents.)
x86 is not done, only x86_64
could automatically copy dlls to the target directory so that dynamic builds will actually run
there is a lib\no_auto_link folder that some packages generate that needs to be added to the link line
should it link rust debug builds against debug libraries? it does not at present.
there is some (expected) weirdness when you link to a static lib that needs
other components to link against. I was only able to resolve libpq.lib
needing the openssl libs (ssleay32.lib and libssl32.lib) by making the
top level binary crate create a reference using extern crate openssl-sys
.
Structs
Config | |
Library |
Enums
Error |
Functions
probe_library | |
target_supported |