From 1c978f7ec564ececef44d114c7ea82b01ff5fd14 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 30 Mar 2023 12:01:23 +0800 Subject: [PATCH] cmake: add support for vendored cmake Use a "cmake-vendored" directory if it exists, to avoid accessing the network if it's available, and a target to create an appropriate tarball to create that directory. --- cmake/Rust.cmake | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index b6137d812..0ce085779 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -1,15 +1,25 @@ -include(FetchContent) +if(EXISTS "${CMAKE_SOURCE_DIR}/corrosion-vendor/") + add_subdirectory("${CMAKE_SOURCE_DIR}/corrosion-vendor/") +else() + include(FetchContent) -# Don't let Corrosion's tests interfere with ours. -set(CORROSION_TESTS OFF CACHE BOOL "" FORCE) + # Don't let Corrosion's tests interfere with ours. + set(CORROSION_TESTS OFF CACHE BOOL "" FORCE) -FetchContent_Declare( - Corrosion - GIT_REPOSITORY https://github.com/mqudsi/corrosion - GIT_TAG fish -) + FetchContent_Declare( + Corrosion + GIT_REPOSITORY https://github.com/mqudsi/corrosion + GIT_TAG fish + ) -FetchContent_MakeAvailable(Corrosion) + FetchContent_MakeAvailable(Corrosion) + + add_custom_target(corrosion-vendor.tar.gz + COMMAND git archive --format tar.gz --output "${CMAKE_BINARY_DIR}/corrosion-vendor.tar.gz" + --prefix corrosion-vendor/ HEAD + WORKING_DIRECTORY ${corrosion_SOURCE_DIR} + ) +endif() set(fish_rust_target "fish-rust")