corrosion-rs / corrosion

Marrying Rust and CMake - Easy Rust and C/C++ Integration!
https://corrosion-rs.github.io/corrosion/
MIT License
1.02k stars 97 forks source link

msvc: handle flags that come from native-static-libs #511

Closed russelltg closed 2 months ago

russelltg commented 2 months ago

As of https://github.com/rust-lang/rust/pull/122268, rust emits /defaultlib:msvcrt in native-static-libs

This ends up in INTERFACE_LINK_LIBRARIES, and then ninja thinks it's a file:

ninja: error: '/defaultlib:msvcrt', needed by 'cpp-exe.exe', missing and no known rule to make it

This check to see if libraries start with a slash, and then assuming that they are a flag, and putting those in INTERFACE_LINK_OPTIONS instead. If there is some better way to detect flags, I'm all for it. We could also have it have anything that starts with - but not start with -l be detected as a flag, but that seems a bit more likely to be disruptive.

I checked commandlines and it does indeed get propaged properly to the commandline.

jschwe commented 2 months ago

Could you also add an entry to the changelog in RELEASES.md?

jschwe commented 2 months ago

thanks!