2022-10-02 18:25:10 +00:00
|
|
|
if (NOT ENABLE_LIBRARIES)
|
|
|
|
set(DEFAULT_ENABLE_RUST FALSE)
|
|
|
|
else()
|
|
|
|
list (APPEND CMAKE_MODULE_PATH "${ClickHouse_SOURCE_DIR}/contrib/corrosion/cmake")
|
|
|
|
find_package(Rust)
|
|
|
|
set(DEFAULT_ENABLE_RUST ${Rust_FOUND})
|
2022-09-13 20:09:39 +00:00
|
|
|
endif()
|
|
|
|
|
2022-10-02 18:25:10 +00:00
|
|
|
option(ENABLE_RUST "Enable rust" ${DEFAULT_ENABLE_RUST})
|
2022-09-13 20:09:39 +00:00
|
|
|
if(NOT ENABLE_RUST)
|
|
|
|
message(STATUS "Not using rust")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Checking Rust toolchain for current target")
|
|
|
|
|
2023-07-25 05:00:14 +00:00
|
|
|
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html
|
2023-07-25 05:00:14 +00:00
|
|
|
|
2024-01-28 15:46:37 +00:00
|
|
|
if(DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
|
|
if(CMAKE_TOOLCHAIN_FILE MATCHES "ppc64le")
|
|
|
|
set(Rust_CARGO_TARGET "powerpc64le-unknown-linux-gnu")
|
|
|
|
elseif((CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-x86_64") AND (CMAKE_TOOLCHAIN_FILE MATCHES "musl"))
|
|
|
|
set(Rust_CARGO_TARGET "x86_64-unknown-linux-musl")
|
|
|
|
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-x86_64")
|
|
|
|
set(Rust_CARGO_TARGET "x86_64-unknown-linux-gnu")
|
|
|
|
elseif((CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-aarch64") AND (CMAKE_TOOLCHAIN_FILE MATCHES "musl"))
|
|
|
|
set(Rust_CARGO_TARGET "aarch64-unknown-linux-musl")
|
|
|
|
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-aarch64")
|
|
|
|
set(Rust_CARGO_TARGET "aarch64-unknown-linux-gnu")
|
|
|
|
elseif((CMAKE_TOOLCHAIN_FILE MATCHES "darwin") AND (CMAKE_TOOLCHAIN_FILE MATCHES "x86_64"))
|
|
|
|
set(Rust_CARGO_TARGET "x86_64-apple-darwin")
|
|
|
|
elseif((CMAKE_TOOLCHAIN_FILE MATCHES "darwin") AND (CMAKE_TOOLCHAIN_FILE MATCHES "aarch64"))
|
|
|
|
set(Rust_CARGO_TARGET "aarch64-apple-darwin")
|
|
|
|
elseif((CMAKE_TOOLCHAIN_FILE MATCHES "freebsd") AND (CMAKE_TOOLCHAIN_FILE MATCHES "x86_64"))
|
|
|
|
set(Rust_CARGO_TARGET "x86_64-unknown-freebsd")
|
|
|
|
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-riscv64")
|
|
|
|
set(Rust_CARGO_TARGET "riscv64gc-unknown-linux-gnu")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported rust target")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Switched Rust target to ${Rust_CARGO_TARGET}")
|
|
|
|
endif ()
|
2022-09-16 17:54:46 +00:00
|
|
|
|
2022-12-14 10:50:12 +00:00
|
|
|
# FindRust.cmake
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${ClickHouse_SOURCE_DIR}/contrib/corrosion/cmake")
|
2022-09-16 17:54:46 +00:00
|
|
|
# Define function corrosion_import_crate()
|
|
|
|
include ("${ClickHouse_SOURCE_DIR}/contrib/corrosion/cmake/Corrosion.cmake")
|