Skip to content

Commit ae88df0

Browse files
jschweogoffart
authored andcommitted
Relax Cargo version parsing
Some cargo versions shipped with rust nightlies seem to be reporting their version without the cargo prefix, e.g.: ```$ cargo +nightly-2021-07-24 --version 1.55.0-nightly (cebef2951 2021-07-22)```. This commit relaxes the parsing slightly by adding an else condition that matches on the expression without the leading `cargo `. It's not an elegant solution, but it works for now.
1 parent 1aa7db5 commit ae88df0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmake/FindRust.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ if (_CARGO_VERSION_RAW MATCHES "cargo ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
198198
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}")
199199
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}")
200200
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}")
201+
# Workaround for the version strings where the `cargo ` prefix is missing.
202+
elseif(_CARGO_VERSION_RAW MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
203+
set(Rust_CARGO_VERSION_MAJOR "${CMAKE_MATCH_1}")
204+
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}")
205+
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}")
206+
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}")
201207
else()
202208
message(
203209
FATAL_ERROR

0 commit comments

Comments
 (0)