Required Feature with Target

Hi,
I would like to know in the Cargo file
Can I do something like this?

[[bin]]
#if target_arch = x86
required-features = ["A"]
#else
required-features = ["B"]

Basically I would like to build binaries with different features depending on the target arch

Thanks!

Does [target.'cfg(target_arch = "x86")'.dependencies] work?

1 Like

Hi,
It works if it is a dependency
But I would like to know if it works under [[bin]] & required-features?
That is, I would like to have different output binaries depending on the arch
I though that the way you mentioned only work on dependencies?

Thanks for your help again!

required-features might not do what you want anyway. It does not cause a feature to be enabled when the binary is built — rather, it skips the binary if the feature is not enabled.