Skip to content

Commit

Permalink
Relax Cargo version parsing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jschwe authored and ogoffart committed Sep 15, 2021
1 parent 1aa7db5 commit ae88df0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ if (_CARGO_VERSION_RAW MATCHES "cargo ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}")
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}")
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}")
# Workaround for the version strings where the `cargo ` prefix is missing.
elseif(_CARGO_VERSION_RAW MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(Rust_CARGO_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}")
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}")
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}")
else()
message(
FATAL_ERROR
Expand Down

0 comments on commit ae88df0

Please sign in to comment.