Skip to content

Commit

Permalink
Set AR_<triple> for cc-rs
Browse files Browse the repository at this point in the history
- Set the `AR_<triple>` variable for cc-rs.
- Simplify condition for CC_<triple> and CXX_<triple>.
  The target is always defined in corrosion,
  so there is no need to check if it set.

Closes #454
  • Loading branch information
jschwe committed Nov 15, 2023
1 parent b2ecb09 commit b72c8ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b72c8ce

Please sign in to comment.