Drag FindRust.cmake back into the land of the living
Some checks failed
make fish_run_tests / ubuntu (push) Has been cancelled
make fish_run_tests / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make fish_run_tests / ubuntu-asan (push) Has been cancelled
make fish_run_tests / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled

rustup has changed its output for 'rustup toolchain list --verbose`.
Teach FindRust.cmake about it, so that it may shamble on.

Cherry-picked from b38551dde9daaab501b4f20d5d16a65bef9fa43f
This commit is contained in:
Peter Ammon 2025-03-05 21:37:21 -08:00
parent aca6836103
commit 83f29ed09c
No known key found for this signature in database

View File

@ -306,18 +306,23 @@ if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
set(_DISCOVERED_TOOLCHAINS_VERSION "")
foreach(_TOOLCHAIN_RAW ${_TOOLCHAINS_RAW})
if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
# We're going to try to parse the output of `rustup toolchain list --verbose`.
# We expect output like this:
# stable-random-toolchain-junk (parenthesized-random-stuff-like-active-or-default) /path/to/toolchain/blah/more-blah
# In the following regex, we capture the toolchain name, any parenthesized stuff, and then the path.
message(STATUS "Parsing toolchain: ${_TOOLCHAIN_RAW}")
if (_TOOLCHAIN_RAW MATCHES "([^\t ]+)[\t ]*(\\(.*\\))?[\t ]*(.+)")
set(_TOOLCHAIN "${CMAKE_MATCH_1}")
set(_TOOLCHAIN_TYPE "${CMAKE_MATCH_2}")
set(_TOOLCHAIN_PATH "${CMAKE_MATCH_3}")
set(_TOOLCHAIN_${_TOOLCHAIN}_PATH "${CMAKE_MATCH_3}")
if (_TOOLCHAIN_TYPE MATCHES ".*\\(default\\).*")
if (_TOOLCHAIN_TYPE MATCHES "default")
set(_TOOLCHAIN_DEFAULT "${_TOOLCHAIN}")
endif()
if (_TOOLCHAIN_TYPE MATCHES ".*\\(override\\).*")
if (_TOOLCHAIN_TYPE MATCHES "override")
set(_TOOLCHAIN_OVERRIDE "${_TOOLCHAIN}")
endif()