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

[Bug]: On error, FindRust puts `Rust_FOUND` in wrong scope #527

Closed obsgolem closed 1 month ago

obsgolem commented 1 month ago

Current Behavior

See https://github.com/corrosion-rs/corrosion/blob/062e03c7653e58ffc9a5e8b04251413f07d06bf3/cmake/FindRust.cmake#L28C9-L28C19. When run with the appropriate conditions, we get the error

Cannot set "Rust_FOUND": current scope has no parent.

Or the variable gets set in the wrong scope.

Expected Behavior

FindRust should not have the PARENT_SCOPE argument on that line. This is due to macros not introducing a scope.

Steps To Reproduce

Run find_package(Rust) from a top level CMakeLists.txt with Rust not installed.

Environment

- OS:
- CMake:
- CMake Generator:

CMake configure log with Debug log-level

No response

CMake Build step log

No response

jschwe commented 1 month ago

Thanks for the report!