3
votes

How do I enable crate features per-platform in a Cargo.toml configuration? I've tried two methods, neither of which work.

Method 1:

[target.'cfg(windows)'.dependencies.rusqlite]
version = "0.19.0"
features = ["bundled"]

[target.'cfg(unix)'.dependencies.rusqlite] # same behavior with cfg(not(windows))
version = "0.19.0"

Method 2:

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.19.0", features = ["bundled"] }

[target.'cfg(unix)'.dependencies]
rusqlite = { version = "0.19.0" }

I'm trying to use the 'bundled' feature only on Windows platforms, but regardless of which way I try to configure cargo it always adds the 'bundled' feature when building on an Ubuntu system.

Is it possible to enable features only on one platform?

1
Unfortunately the features system of Cargo is, right now, very very limited and makes working on cross platform applications very painfulDenys Séguret

1 Answers

3
votes

Is it possible to enable features only on one platform?

No, it is not possible, due to Cargo issue #1197.

See also: