Platform specific `.cargo/config.toml`

Hi!

I am building some C++ code using the cc crate. Unfortunately, the build only works on the gnu flavor of windows x86_64-pc-windows-gnu. So simple enough I can add the following config.toml

[build]
target = "x86_64-pc-windows-gnu"

However, using Linux I do not want to force this target! How can I achieve this without manually changing my build commands? -> I still want to be able to just use cargo b for building.

I just cannot figure out how to achieve this. Do you have any hints?

Thanks and greetings,
Christian

The configuration is meant to configure the behaviour of your local Cargo installation. Hence there is no way to define multiple default targets for every host OS. You can override the default target via the command line, i.e. cargo build --target <triple>.

There is the unstable host-config feature, but AFAICT in its current form it does not support setting a host specific default target.

A workaround might be to always build for windows and linux:

[build]
target = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-gnu"]