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.
This commit is contained in:
David Adam 2023-03-30 12:01:23 +08:00
parent 3ae16a5b95
commit 1c978f7ec5

View file

@ -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. # Don't let Corrosion's tests interfere with ours.
set(CORROSION_TESTS OFF CACHE BOOL "" FORCE) set(CORROSION_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_Declare( FetchContent_Declare(
Corrosion Corrosion
GIT_REPOSITORY https://github.com/mqudsi/corrosion GIT_REPOSITORY https://github.com/mqudsi/corrosion
GIT_TAG fish 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") set(fish_rust_target "fish-rust")