Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make FindRust gracefully fail if rustc not found #111

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,19 @@ if (_RESOLVE_RUSTUP_TOOLCHAINS)
NO_DEFAULT_PATH)
else()
find_program(Rust_COMPILER_CACHED rustc)
if (Rust_COMPILER_CACHED)
get_filename_component(_RUST_TOOLCHAIN_PATH ${Rust_COMPILER_CACHED} DIRECTORY)
get_filename_component(_RUST_TOOLCHAIN_PATH ${_RUST_TOOLCHAIN_PATH} DIRECTORY)
endif()
endif()

get_filename_component(_RUST_TOOLCHAIN_PATH ${Rust_COMPILER_CACHED} DIRECTORY)
get_filename_component(_RUST_TOOLCHAIN_PATH ${_RUST_TOOLCHAIN_PATH} DIRECTORY)
if (NOT Rust_COMPILER_CACHED)
message(
WARNING "The rustc executable was not found. "
"Rust not installed or ~/.cargo/bin not added to path? "
trondhe marked this conversation as resolved.
Show resolved Hide resolved
"Aborting further actions of find_package(Rust). ")
set(Rust_FOUND false)
return()
endif()

# Look for Cargo next to rustc.
Expand Down Expand Up @@ -352,4 +362,5 @@ if(NOT TARGET Rust::Rustc)
TARGET Rust::Cargo
PROPERTY IMPORTED_LOCATION ${Rust_CARGO_CACHED}
)
set(Rust_FOUND true)
endif()