I have a dependency in my Cargo file that needs to be different by platform, specifically, the default features. Here's what I am trying to do:
[package]
name = "..blah.."
version = "..blah.."
authors = ["..blah.."]
[target.'cfg(target_os = "macos")'.dependencies]
hyper = { version = "0.9", default-features = false, features = ["security-framework"] }
[target.'cfg(target_os = "linux")'.dependencies]
hyper = { version = "0.9", default-features = true }
But this doesn't seem to do what I want. On my Mac it appears to be using the bottom target line as if I just specified hyper = "0.9"
. If I do cargo build
as specified, I get errors with regard to openssl:
cargo:warning=#include <openssl/ssl.h>
However, if I build it like this:
[dependencies]
hyper = { version = "0.9", default-features = false, features = ["security-framework"] }
Then it builds fine. This indicates to me that the cfg
for "macos" isn't working.
How do I make this work, or more specifically, how do I solve the problem where I need my dependency to use different features by platform?