From d79b2b59b2fab9a4337f544a3895e119f05b1b77 Mon Sep 17 00:00:00 2001 From: Geoff Martin Date: Thu, 22 Aug 2024 15:58:47 +0100 Subject: [PATCH] Ensure build directory contains a copy of rust-toolchain.toml. When building using cargo's --manifest-path option the toolchain configuration file within the manifest directory is ignored. Ensuring a copy of the rust-toolchain.toml file is in the build directory ensures the toolchain settings are pciked up when building via cmake. --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0e13dbed..9a5885c77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,16 @@ else() configure_cargo_toml(${cargo_toml_dir_release} ${project_version} ${cargo_lib_name_release}) endif() +# +# Copy toolchain configuration to build directory to ensure it is used when cargo is invoked from a directory other +# than the directory containing the manifest file +# +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/rust-toolchain.toml") + file(COPY + ${CMAKE_CURRENT_SOURCE_DIR}/rust-toolchain.toml + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endif() + # # Configure result library names #