ClickHouse/contrib/corrosion-cmake/CMakeLists.txt

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.8 KiB
CMake
Raw Normal View History

2022-09-13 20:09:39 +00:00
if (NOT ENABLE_LIBRARIES)
option(ENABLE_RUST "Enable rust" FALSE)
else()
list (APPEND CMAKE_MODULE_PATH "${ClickHouse_SOURCE_DIR}/contrib/corrosion/cmake")
find_package(Rust)
option(ENABLE_RUST "Enable rust" $Rust_FOUND)
endif()
if(NOT ENABLE_RUST)
message(STATUS "Not using rust")
return()
endif()
message(STATUS "Checking Rust toolchain for current target")
if(CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-x86_64")
set(Rust_CARGO_TARGET "x86_64-unknown-linux-gnu")
execute_process(COMMAND rustup target add x86_64-unknown-linux-gnu)
endif()
if(CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-aarch64")
set(Rust_CARGO_TARGET "aarch64-unknown-linux-gnu")
execute_process(COMMAND rustup target add aarch64-unknown-linux-gnu)
endif()
if((CMAKE_TOOLCHAIN_FILE MATCHES "darwin") AND (CMAKE_TOOLCHAIN_FILE MATCHES "toolchain-aarch64"))
set(Rust_CARGO_TARGET "aarch64-apple-darwin")
execute_process(COMMAND rustup target add aarch64-apple-darwin)
endif()
if((CMAKE_TOOLCHAIN_FILE MATCHES "darwin") AND (CMAKE_TOOLCHAIN_FILE MATCHES "x86_64"))
set(Rust_CARGO_TARGET "x86_64-apple-darwin")
execute_process(COMMAND rustup target add x86_64-apple-darwin)
endif()
if((CMAKE_TOOLCHAIN_FILE MATCHES "freebsd") AND (CMAKE_TOOLCHAIN_FILE MATCHES "x86_64"))
set(Rust_CARGO_TARGET "x86_64-unknown-freebsd")
execute_process(COMMAND rustup target add x86_64-unknown-freebsd)
endif()
if(CMAKE_TOOLCHAIN_FILE MATCHES "ppc64le")
set(Rust_CARGO_TARGET "powerpc64le-unknown-linux-gnu")
execute_process(COMMAND rustup target add powerpc64le-unknown-linux-gnu)
endif()
2022-09-16 17:54:46 +00:00
execute_process(COMMAND rustup default stable-${Rust_CARGO_TARGET})
2022-09-13 20:09:39 +00:00
message(STATUS "Switched Rust target to ${Rust_CARGO_TARGET}")
2022-09-16 17:54:46 +00:00
# Define function corrosion_import_crate()
include ("${ClickHouse_SOURCE_DIR}/contrib/corrosion/cmake/Corrosion.cmake")