diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 3f29464aa..60439863f 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -41,6 +41,12 @@ corrosion_import_crate( FLAGS "${CARGO_FLAGS}" ) +if (Rust_CARGO_TARGET) + set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_TARGET}") +else() + set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_HOST_TARGET}") +endif() + # Temporary hack to propogate CMake flags/options to build.rs. We need to get CMake to evaluate the # truthiness of the strings if they are set. set(CMAKE_WITH_GETTEXT "1") diff --git a/cmake/Tests.cmake b/cmake/Tests.cmake index 885cf367d..3c0b63058 100644 --- a/cmake/Tests.cmake +++ b/cmake/Tests.cmake @@ -163,7 +163,7 @@ endif() if(NOT DEFINED ASAN) add_test( NAME "cargo-test" - COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package fish-rust --target-dir target ${cargo_target_opt} + COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package fish-rust --target-dir ${rust_target_dir} ${cargo_target_opt} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE}) @@ -172,7 +172,7 @@ endif() add_test( NAME "cargo-test-widestring" - COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package widestring-suffix --target-dir target ${cargo_target_opt} + COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package widestring-suffix --target-dir ${rust_target_dir} ${cargo_target_opt} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) add_test_target("cargo-test-widestring")