From b72c8ceb52f5d0235ce0fc268cfeff20ce56e8d8 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Wed, 15 Nov 2023 19:57:59 +0100 Subject: [PATCH] Set AR_ for cc-rs - Set the `AR_` variable for cc-rs. - Simplify condition for CC_ and CXX_. The target is always defined in corrosion, so there is no need to check if it set. Closes #454 --- cmake/Corrosion.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/Corrosion.cmake b/cmake/Corrosion.cmake index 5ec7398d..6185652c 100644 --- a/cmake/Corrosion.cmake +++ b/cmake/Corrosion.cmake @@ -774,15 +774,19 @@ function(_add_cargo_build out_cargo_build_out_dir) set(corrosion_cc_rs_flags) - if(CMAKE_C_COMPILER AND _CORROSION_RUST_CARGO_TARGET_UNDERSCORE) + if(CMAKE_C_COMPILER) # This variable is read by cc-rs (often used in build scripts) to determine the c-compiler. # It can still be overridden if the user sets the non underscore variant via the environment variables # on the target. list(APPEND corrosion_cc_rs_flags "CC_${_CORROSION_RUST_CARGO_TARGET_UNDERSCORE}=${CMAKE_C_COMPILER}") endif() - if(CMAKE_CXX_COMPILER AND _CORROSION_RUST_CARGO_TARGET_UNDERSCORE) + if(CMAKE_CXX_COMPILER) list(APPEND corrosion_cc_rs_flags "CXX_${_CORROSION_RUST_CARGO_TARGET_UNDERSCORE}=${CMAKE_CXX_COMPILER}") endif() + if(CMAKE_AR) + list(APPEND corrosion_cc_rs_flags "AR_${_CORROSION_RUST_CARGO_TARGET_UNDERSCORE}=${CMAKE_AR}") + endif() + # Since we instruct cc-rs to use the compiler found by CMake, it is likely one that requires also # specifying the target sysroot to use. CMake's generator makes sure to pass --sysroot with # CMAKE_OSX_SYSROOT. Fortunately the compilers Apple ships also respect the SDKROOT environment