Skip to content

Commit

Permalink
Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwe committed Apr 12, 2022
1 parent 9579597 commit 46ed9af
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ function(_add_cargo_build)
set(target_artifact_dir "$<IF:${if_not_host_build_condition},${_CORROSION_RUST_CARGO_TARGET},${_CORROSION_RUST_CARGO_HOST_TARGET}>")

# Rust will add `-lSystem` as a flag for the linker on macOS. Adding the -L flag via RUSTFLAGS only fixes the
# problem partially - buildscripts still break, since they won't receive the RUSTFLAGS.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
corrosion_add_target_rustflags(${target_name} "-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
# problem partially - buildscripts still break, since they won't receive the RUSTFLAGS. This seems to only be a
# problem if we specify the linker ourselves (which we do, since this is necessary for e.g. linking C++ code).
# We can however set `LIBRARY_PATH`, which is propagated to the build-script-build properly.
if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(cargo_library_path "LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
elseif(CMAKE_CROSSCOMPILING AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
set(cargo_library_path "$<IF:${if_not_host_build_condition},,LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib>")
endif()

if(cargo_profile_name)
Expand Down Expand Up @@ -326,6 +330,7 @@ function(_add_cargo_build)
${rustflags_genex_test}
${cargo_target_linker}
${corrosion_cc_rs_flags}
${cargo_library_path}
CORROSION_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
CARGO_BUILD_RUSTC="${_CORROSION_RUSTC}"
"${_CORROSION_CARGO}"
Expand Down

0 comments on commit 46ed9af

Please sign in to comment.