Always pass --target to cargo test when CMake Rust_CARGO_TARGET is set

The CMake `cargo test` integration was broken if Rust_CARGO_TARGET were used
with `CARGO_FLAGS` set to `-Zbuild-std` (e.g. to target i586 under i686 without
the i586 toolchain installed).
This commit is contained in:
Mahmoud Al-Qudsi 2024-06-21 11:56:50 -05:00
parent 14fd7bd9af
commit 298cdb0c5b

View file

@ -138,6 +138,9 @@ if(DEFINED ASAN)
message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
intended target triple") intended target triple")
endif() endif()
endif()
if(DEFINED Rust_CARGO_TARGET)
list(APPEND cargo_test_flags "--target" ${Rust_CARGO_TARGET}) list(APPEND cargo_test_flags "--target" ${Rust_CARGO_TARGET})
list(APPEND cargo_test_flags "--lib") list(APPEND cargo_test_flags "--lib")
endif() endif()