Cargo conditional output name


#1

Hi all!
I am using the feature in Cargo and rust to be able to compile the same application for different uses.
This works great but I want to be able to use features to give the compiled program different name depending on feature option.
I have searched the web but no luck there.

Many thanks in advance!

Best regards
Marcus


#2

You can set the CARGO_TARGET_DIR environment variable to change the target directory, but I don’t think you can change just the binary name dynamically.


#3

I don’t know for sure, but that sounds like something you might be able to do with some [[bin]] sections, see http://doc.crates.io/manifest.html#configuring-a-target

I used when playing with my advent of code stuff last year. I used different files for main for each one, but you might be able to use the same one for each, not sure.