Skip to content

Commit

Permalink
fix: try to set cargo target for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyconover committed Jul 2, 2024
1 parent c2ac43c commit 295963d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ set(CORROSION_VERBOSE_OUTPUT ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED 1)



# Propagate arch to rust build for CI
set(Rust_CARGO_TARGET "")
if("${OS_NAME}" STREQUAL "linux")
if ("${OS_ARCH}" STREQUAL "arm64")
set(Rust_CARGO_TARGET "aarch64-unknown-linux-gnu")
elseif("${CMAKE_CXX_COMPILER}" MATCHES "aarch64")
set(Rust_CARGO_TARGET ${RUST_ENV_VARS} CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc)
set(Rust_CARGO_TARGET "aarch64-unknown-linux-gnu")
else()
set(Rust_CARGO_TARGET "x86_64-unknown-linux-gnu")
endif()
elseif("${OS_NAME}" STREQUAL "osx")
if ("${OSX_BUILD_ARCH}" STREQUAL "arm64")
set(Rust_CARGO_TARGET "aarch64-apple-darwin")
elseif ("${OSX_BUILD_ARCH}" STREQUAL "x86_64")
set(Rust_CARGO_TARGET "x86_64-apple-darwin")
elseif ("${OS_ARCH}" STREQUAL "arm64")
set(Rust_CARGO_TARGET "aarch64-apple-darwin")
endif()
elseif(WIN32)
if (MINGW AND "${OS_ARCH}" STREQUAL "arm64")
set(Rust_CARGO_TARGET "aarch64-pc-windows-gnu")
elseif (MINGW AND "${OS_ARCH}" STREQUAL "amd64")
set(Rust_CARGO_TARGET "x86_64-pc-windows-gnu")
elseif (MSVC AND "${OS_ARCH}" STREQUAL "arm64")
set(Rust_CARGO_TARGET "aarch64-pc-windows-msvc")
elseif (MSVC AND "${OS_ARCH}" STREQUAL "amd64")
set(Rust_CARGO_TARGET "x86_64-pc-windows-msvc")
endif()
endif()

# We currently only support the predefined targets.
if ("${Rust_CARGO_TARGET}" STREQUAL "")
message(FATAL_ERROR "Failed to detect the correct platform")
endif()


include(FetchContent)

FetchContent_Declare(
Expand Down

0 comments on commit 295963d

Please sign in to comment.