https://github.com/mcgoo/cargo-vcpkg
Get external dependencies in one step by specifying vcpkg details in Cargo.toml
https://github.com/mcgoo/cargo-vcpkg
cargo rust vcpkg
Last synced: about 1 year ago
JSON representation
Get external dependencies in one step by specifying vcpkg details in Cargo.toml
- Host: GitHub
- URL: https://github.com/mcgoo/cargo-vcpkg
- Owner: mcgoo
- License: apache-2.0
- Created: 2021-02-02T00:06:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T07:58:02.000Z (about 2 years ago)
- Last Synced: 2025-05-16T22:37:57.804Z (about 1 year ago)
- Topics: cargo, rust, vcpkg
- Language: Rust
- Homepage:
- Size: 425 KB
- Stars: 44
- Watchers: 4
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# cargo-vcpkg [](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AWindows) [](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3AmacOS) [](https://github.com/mcgoo/vcpkg-rs/actions?query=workflow%3ALinux)
[Changelog](https://github.com/mcgoo/cargo-vcpkg/blob/master/CHANGELOG.md)
This command `cargo vcpkg` will create a [vcpkg](https://github.com/microsoft/vcpkg) tree and install the packages specified in `Cargo.toml` files in the crate being built and crates it depends on. Crates that use the [vcpkg crate](https://crates.io/crates/vcpkg) will be able to find libraries automatically.
## Example
```toml
[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "4c1db68"
dependencies = ["pkg1", "pkg2"]
```
```
$ cargo install cargo-vcpkg
$ cargo vcpkg build
Fetching vcpkg
Checkout rev/tag/branch 4c1db68
Compiling pkg1, pkg2
Finished in 1.93s
$ cargo build
[...]
```
## Per target configuration
It is also possible to install different sets of packages per target, and override the vcpkg triplet to install.
```toml
[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "4c1db68"
dependencies = ["sdl2"]
[package.metadata.vcpkg.target]
x86_64-apple-darwin = { dependencies = ["sdl2", "sdl2-gfx" ] }
x86_64-unknown-linux-gnu = { dependencies = ["sdl2", "opencv"] }
x86_64-pc-windows-msvc = { triplet = "x64-windows-static", dependencies = ["sdl2", "zeromq"] }
```
## Development dependencies
Setting the `dev-dependencies` key allows building libraries that are required by binaries in this crate. Only the packages in the `dependencies` key will be installed if `cargo vcpkg` is run on a crate that depends on this crate.
```toml
[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "4c1db68"
dependencies = ["sdl2"]
dev-dependencies = ["sdl2-image"]
[package.metadata.vcpkg.target]
x86_64-apple-darwin = { dev-dependencies = ["sdl2-gfx" ] }
```
## Overlay triplets
Setting the `overlay-triplets-path` key allows you use custom [triplet files] in
your build. The value of this key should be the path to a directory containing
triplet files. These files will be made available during the vcpkg build through
its `--overlay-triplets` argument.
[triplet files]: https://vcpkg.readthedocs.io/en/latest/users/triplets/
```toml
[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "4c1db68"
dependencies = ["sdl2"]
overlay-triplets-path = "support/custom-triplets"
[package.metadata.vcpkg.target]
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release" }
```
Here, the repository should contain a file named
`support/custom-triplets/x64-windows-static-release.cmake`.
## Installation
Install by running
```
cargo install cargo-vcpkg
```
crates.io/vcpkg needs older Rust for compatibility with older projects, while cargo-vcpkg would like to track new versions for the latest features in Cargo.toml, hense the split of repos between components.
## License
See LICENSE-APACHE, and LICENSE-MIT for details.