From 8228bd98194dde53a0f9e165ef6fe44a3bd1a92a Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Tue, 19 Dec 2023 10:15:42 -0500 Subject: [PATCH] CMake+Rust: Fix offline builds w. vendored git repos Some builds using the tarball with the vendored Rust dependencies are failing. The onenote-rs dependency is presently tied to a git branch from github rather than using a release from crates.io. This is the differing factor though I'm unsure why it is causing the build to try to update the repo rather than just building the vendored source. This commit adds a `--offline` parameter to the build options if the vendored source is detected, in an attempt to force Cargo to use what it has and stay offline. --- cmake/FindRust.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index 6e6b5fc264..45f11b5acd 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -460,6 +460,10 @@ endif() set(CARGO_ARGS "build") +if(EXISTS "${ARGS_SOURCE_DIRECTORY}/.cargo/vendor") + list(APPEND CARGO_ARGS "--offline") +endif() + if(NOT "${RUST_COMPILER_TARGET}" MATCHES "^universal-apple-darwin$") # Don't specify the target for macOS universal builds, we'll do that manually for each build. list(APPEND CARGO_ARGS "--target" ${RUST_COMPILER_TARGET})