#metadata #build-dependencies #pkg-config #manifest #build-depends

build system-deps

Discover and configure system dependencies from declarative dependencies in Cargo.toml

34 stable releases (6 major)

new 7.0.5 May 22, 2025
7.0.3 Sep 22, 2024
7.0.1 Jun 18, 2024
6.2.2 Mar 19, 2024
1.3.2 Jul 10, 2020

#12 in Build Utils

Download history 199255/week @ 2025-02-04 215989/week @ 2025-02-11 211448/week @ 2025-02-18 232185/week @ 2025-02-25 229918/week @ 2025-03-04 228382/week @ 2025-03-11 242769/week @ 2025-03-18 243304/week @ 2025-03-25 254096/week @ 2025-04-01 263123/week @ 2025-04-08 207314/week @ 2025-04-15 233727/week @ 2025-04-22 247761/week @ 2025-04-29 305118/week @ 2025-05-06 316807/week @ 2025-05-13 298664/week @ 2025-05-20

1,205,721 downloads per month
Used in 1,813 crates (163 directly)

MIT/Apache

120KB
2.5K SLoC

system-deps codecov CI

system-deps lets you write system dependencies in Cargo.toml metadata, rather than programmatically in build.rs. This makes those dependencies declarative, so other tools can read them as well.

For now only pkg-config dependencies are supported, but we are planning to expand it at some point.

Users can override dependency flags using environment variables if needed. system-deps also allows -sys crates to optionally internally build and static link the required system library.

system-deps has been started as a fork of the metadeps project.

Documentation

See the crate documentation.

Usage

In your Cargo.toml:

[build-dependencies]
system-deps = "2.0"

Then, to declare a dependency on testlib >= 1.2 add the following section:

[package.metadata.system-deps]
testlib = "1.2"

Finally, in your build.rs, add:

fn main() {
    system_deps::Config::new().probe().unwrap();
}

See the crate documentation for more advanced features.

Dependencies

~3MB
~70K SLoC