Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass sysroot when cross compiling #469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,13 @@ function(_add_cargo_build out_cargo_build_out_dir)
list(APPEND corrosion_cc_rs_flags "AR_${_CORROSION_RUST_CARGO_TARGET_UNDERSCORE}=${CMAKE_AR}")
endif()

# when cross compiling, the sysroot is a necessary element to pass to the compiler
if (CMAKE_CROSSCOMPILING AND NOT ANDROID)
list (
APPEND corrosion_cc_rs_flags
CFLAGS_${Rust_CARGO_TARGET}="${CMAKE_C_FLAGS} --sysroot ${CMAKE_SYSROOT}")
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