Merge pull request #61938 from azat/build/rust-connectivity-check

Check is Rust avaiable for build, if not, suggest a way to disable Rust support
This commit is contained in:
Alexey Milovidov 2024-03-27 01:51:59 +03:00 committed by GitHub
commit 2790f9a787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -99,6 +99,19 @@ function(add_rust_subdirectory src)
message(STATUS "Copy ${src} to ${dst}")
file(COPY "${src}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}"
PATTERN target EXCLUDE)
# Check is Rust available or not.
#
# `cargo update --dry-run` will not update anything, but will check the internet connectivity.
execute_process(COMMAND ${Rust_CARGO_CACHED} update --dry-run
WORKING_DIRECTORY "${dst}"
RESULT_VARIABLE CARGO_UPDATE_RESULT
OUTPUT_VARIABLE CARGO_UPDATE_STDOUT
ERROR_VARIABLE CARGO_UPDATE_STDERR)
if (CARGO_UPDATE_RESULT)
message(FATAL_ERROR "Rust (${Rust_CARGO_CACHED}) support is not available (likely there is no internet connectivity):\n${CARGO_UPDATE_STDERR}\nYou can disable Rust support with -DENABLE_RUST=OFF")
endif()
add_subdirectory("${dst}" "${dst}")
# cmake -E copy* do now know how to exclude files