corrosion-rs / corrosion

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

[Bug]: cross compilation from linux to windows with build tools fails. #476

Closed ogoffart closed 8 months ago

ogoffart commented 8 months ago

Current Behavior

corrosion adds ".exe" to the path of the tools it runs when it targets windows, but it shouldn't

Expected Behavior

the tools runs on linux so it shouldn't add .exe

Steps To Reproduce

This has been seen when trying to cross compile Slint application from linux that target windows. More info there: https://github.com/slint-ui/slint/issues/2508

Environment

No response

CMake configure log with Debug log-level

No response

CMake Build step log

No response

ogoffart commented 8 months ago

As per my comment on the Slint issue: https://github.com/slint-ui/slint/issues/2508#issuecomment-1893711655

https://github.com/corrosion-rs/corrosion/pull/437 fixes the other way around (windows to non-windows) But the condition in https://github.com/corrosion-rs/corrosion/blob/8d8ff67e506cdee4a69123f3bea31b0465a48fe2/cmake/Corrosion.cmake#L81 doesn't cover the target windows but host not windows.

jschwe commented 8 months ago

changing the condition to this should be sufficient to fix this right?

if( (hostbuild AND CMAKE_HOST_WIN32) 
     OR 
     ((NOT hostbuild) AND (Rust_CARGO_TARGET_OS STREQUAL "windows")) )
ogoffart commented 8 months ago

yes, exactly.

jschwe commented 8 months ago

Fixed in v0.4.6