CMake: Helpful error message when Rust version too old

It isn't obvious if a build fails because the Rust version is too low.

The FindRust.cmake module already has logic to check the min supported
Rus version. This commit make use of that, adding a Rust version var at
the top of CMakeLists.txt. We will have to update it any time we run
`cargo update`, before releasing a new feature version.

If your Rust version is too low (or you artificially crank up the min
version for testing, the error will look like this:

-- Rust tool `cargo` found: /home/micah/.cargo/bin/cargo, 1.85.0
-- Rust tool `rustc` found: /home/micah/.cargo/bin/rustc, 1.85.0
-- Rust tool `rustup` found: /home/micah/.cargo/bin/rustup, 1.28.1
-- Rust tool `rust-gdb` found: /home/micah/.cargo/bin/rust-gdb, 9.2
-- Rust tool `rust-lldb` not found: Failed to determine version.
-- Rust tool `rustdoc` found: /home/micah/.cargo/bin/rustdoc, 1.85.0
-- Rust tool `rustfmt` found: /home/micah/.cargo/bin/rustfmt, 1.8.0
-- Rust tool `bindgen` not found.
CMake Error at cmake/FindRust.cmake:412 (message):
  Your Rust toolchain is to old to build this project:

      1.85.0 < 1.100.0
Call Stack (most recent call first):
  CMakeLists.txt:144 (find_package)

-- Configuring incomplete, errors occurred!

Fixes: https://github.com/Cisco-Talos/clamav/issues/1480
pull/1481/head
Valerie Snyder 1 month ago
parent 00886ee90d
commit 4f361f23e8
No known key found for this signature in database
GPG Key ID: DCBE519BFAF4C517
  1. 4
      CMakeLists.txt

@ -52,6 +52,10 @@ math(EXPR LIBFRESHCLAM_SOVERSION "${LIBFRESHCLAM_CURRENT} - ${LIBFRESHCLAM_AGE}"
set(LIBFRESHCLAM_VERSION "${LIBFRESHCLAM_SOVERSION}.${LIBFRESHCLAM_AGE}.${LIBFRESHCLAM_REVISION}")
HexVersion(LIBFRESHCLAM_VERSION_NUM ${LIBFRESHCLAM_CURRENT} ${LIBFRESHCLAM_REVISION} ${LIBFRESHCLAM_AGE})
# Minimum Rust Supported Version
# To determine this, install cargo-msrv and run: `cargo msrv`
set(RUSTC_MINIMUM_REQUIRED "1.81.0")
set(GENERATE_WARNING "WARNING: This file was generated by CMake. Do not edit!")
#

Loading…
Cancel
Save