Skip to content

Commit

Permalink
Improve LLVM version parsing robustness
Browse files Browse the repository at this point in the history
With the Rust toolchain 1.44.1 the reported LLVM version is 9.0,
i.e. without a patch version.

Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Mar 27, 2022
1 parent 3b2f040 commit c6ecc28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ else()
)
endif()

if (_RUSTC_VERSION_RAW MATCHES "LLVM version: ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
if (_RUSTC_VERSION_RAW MATCHES "LLVM version: ([0-9]+)\\.([0-9]+)(\\.([0-9]+))?")
set(Rust_LLVM_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(Rust_LLVM_VERSION_MINOR "${CMAKE_MATCH_2}")
set(Rust_LLVM_VERSION_PATCH "${CMAKE_MATCH_3}")
# With the Rust toolchain 1.44.1 the reported LLVM version is 9.0, i.e. without a patch version.
# Since cmake regex does not support non-capturing groups, just ignore Match 3.
set(Rust_LLVM_VERSION_PATCH "${CMAKE_MATCH_4}")
set(Rust_LLVM_VERSION "${Rust_LLVM_VERSION_MAJOR}.${Rust_LLVM_VERSION_MINOR}.${Rust_LLVM_VERSION_PATCH}")
else()
message(
Expand Down

0 comments on commit c6ecc28

Please sign in to comment.