Conditionally compile dependencies: how to pass features from root crate to libs

In my project I have root crate (bin) and some external libraries I use to split code. When I tried to use #[cfg(feature = "foo")] to compile conditionally, it appeared that bin and lib crates don't share features passed to cargo build.

How can my binary package and dependent libs use the same set of features passed to cargo at compile time?

Your feature can activate features of direct dependencies:

foo = ["abc/foo", "xyz/foo"]
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.