| 1 | # system-deps [](https://crates.io/crates/system-deps) [](https://docs.rs/system-deps) [](https://codecov.io/gh/gdesmott/system-deps) [](https://github.com/gdesmott/system-deps/actions) |
| 2 | |
| 3 | `system-deps` lets you write system dependencies in `Cargo.toml` metadata, |
| 4 | rather than programmatically in `build.rs`. This makes those dependencies |
| 5 | declarative, so other tools can read them as well. |
| 6 | |
| 7 | For now only `pkg-config` dependencies are supported, but we are planning to |
| 8 | [expand it](https://github.com/gdesmott/system-deps/issues/3) at some point. |
| 9 | |
| 10 | Users can override dependency flags using environment variables if needed. |
| 11 | `system-deps` also allows `-sys` crates to optionally internally build and |
| 12 | static link the required system library. |
| 13 | |
| 14 | `system-deps` has been started as a fork of the |
| 15 | [metadeps](https://github.com/joshtriplett/metadeps) project. |
| 16 | |
| 17 | ## Documentation |
| 18 | |
| 19 | See the [crate documentation](https://docs.rs/system-deps/). |
| 20 | |
| 21 | ## Usage |
| 22 | |
| 23 | In your `Cargo.toml`: |
| 24 | |
| 25 | ```toml |
| 26 | [build-dependencies] |
| 27 | system-deps = "2.0" |
| 28 | ``` |
| 29 | |
| 30 | Then, to declare a dependency on `testlib >= 1.2` add the following section: |
| 31 | |
| 32 | ```toml |
| 33 | [package.metadata.system-deps] |
| 34 | testlib = "1.2" |
| 35 | ``` |
| 36 | |
| 37 | Finally, in your `build.rs`, add: |
| 38 | |
| 39 | ```rust |
| 40 | fn main() { |
| 41 | system_deps::Config::new().probe().unwrap(); |
| 42 | } |
| 43 | ``` |
| 44 | |
| 45 | See the [crate documentation](https://docs.rs/system-deps/) for more advanced features. |