vcpkg 0.2.0

A library to find native dependencies in a vcpkg tree at build time in order to be used in Cargo build scripts.
Documentation

A build dependency for Cargo libraries to find libraries in a Vcpkg tree.

The simplest possible usage for a library whose Vcpkg port name matches the name of the lib and DLL that are being looked for looks like this :-

vcpkg::probe_library("libssh2").unwrap();

In practice the .lib and .dll often differ in name from the package itself, in which case the library names must be specified, like this :-

vcpkg::Config::new()
    .lib_names("zlib","zlib1")
    .probe("zlib").unwrap();

If the search was successful all appropriate Cargo metadata will be printed on stdout.

The decision to choose static variants of libraries is driven by the rustc flag -C target-feature=crt-static. This requires a nightly compiler but is scheduled to be stable in rustc 1.19.

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 with vcpkg integrate install

  • FOO_NO_VCPKG - if set, vcpkg will not attempt to find the library named foo.

  • NO_VCPKG - if set, vcpkg will not attempt to find any libraries.

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