From 17b3ee2f7d91606d601efd01b036bd57ef0a1e18 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Tue, 31 Jan 2023 03:06:43 +0800
Subject: [PATCH 2/3] cmake-rust-build-target

---
 build/fbcode_builder/CMake/RustStaticLibrary.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/build/fbcode_builder/CMake/RustStaticLibrary.cmake b/build/fbcode_builder/CMake/RustStaticLibrary.cmake
index dd57b2b3d..41fec49ae 100644
--- a/build/fbcode_builder/CMake/RustStaticLibrary.cmake
+++ b/build/fbcode_builder/CMake/RustStaticLibrary.cmake
@@ -117,7 +117,7 @@ function(rust_static_library TARGET)
   endif()
 
   set(cargo_target "${TARGET}.cargo")
-  set(target_dir $<IF:$<CONFIG:Debug>,debug,release>)
+  set(target_dir $ENV{CARGO_BUILD_TARGET}/$<IF:$<CONFIG:Debug>,debug,release>)
   set(staticlib_name "${CMAKE_STATIC_LIBRARY_PREFIX}${crate_name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
   set(rust_staticlib "${CMAKE_CURRENT_BINARY_DIR}/${target_dir}/${staticlib_name}")
 
@@ -179,7 +179,7 @@ function(rust_executable TARGET)
 
   set(crate_name "${TARGET}")
   set(cargo_target "${TARGET}.cargo")
-  set(target_dir $<IF:$<CONFIG:Debug>,debug,release>)
+  set(target_dir $ENV{CARGO_BUILD_TARGET}/$<IF:$<CONFIG:Debug>,debug,release>)
 
   if(DEFINED ARG_BINARY_NAME)
     set(executable_name "${ARG_BINARY_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
-- 
2.39.1

