From 5175b0608178e294f19d7878e856893d87d44fb6 Mon Sep 17 00:00:00 2001 From: abueno Date: Thu, 5 Dec 2024 08:43:46 +0100 Subject: [PATCH] feat: Support for cross compiling --- rust_part/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust_part/CMakeLists.txt b/rust_part/CMakeLists.txt index c14be7c..33826ee 100644 --- a/rust_part/CMakeLists.txt +++ b/rust_part/CMakeLists.txt @@ -6,6 +6,13 @@ else () set(TARGET_DIR "release") endif () +# If the user is cross compiling to a different target, update the location of the target directory +# *Note*: Make sure to install the target with rustup, as well as setting the proper environment variables, such as CC, HOST_CC, CARGO_TARGET__LINKER, ... +# See https://doc.rust-lang.org/cargo/reference/environment-variables.html#configuration-environment-variables +if (DEFINED ENV{CARGO_BUILD_TARGET}) + set(TARGET_DIR "$ENV{CARGO_BUILD_TARGET}/${TARGET_DIR}") +endif() + if(ENABLE_LTO) set(RUST_FLAGS "-Clinker-plugin-lto" "-Clinker=clang-17" "-Clink-arg=-fuse-ld=lld-17") endif()