Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ jobs:
# If this isn't specified the default is iOS 7, for which zlib-ng will not compile due to the lack of thread-local storage.
IPHONEOS_DEPLOYMENT_TARGET: 16

win_cross_compile_test:
name: Test Cross Compile - ${{ matrix.platform.target }}
needs: [ test ]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform:
- target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
- name: build
run: cargo build -vv --target ${{ matrix.platform.target }}
working-directory: test-crate

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
22 changes: 15 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ impl Config {
};
let host = self.host.clone().unwrap_or_else(|| getenv_unwrap("HOST"));

let generator = self
.generator
.clone()
.or_else(|| self.getenv_target_os("CMAKE_GENERATOR"));

let msvc = target.contains("msvc");

// Some decisions later on are made if CMAKE_TOOLCHAIN_FILE is defined,
// so we need to read it from the environment variables from the beginning.
if !self.defined("CMAKE_TOOLCHAIN_FILE") {
Expand All @@ -454,7 +461,14 @@ impl Config {
if !self.defined("CMAKE_SYSTEM_NAME") {
self.define("CMAKE_SYSTEM_NAME", "Generic");
}
} else if target != host && !self.defined("CMAKE_SYSTEM_NAME") {
} else if target != host
&& !self.defined("CMAKE_SYSTEM_NAME")
&& !(msvc
&& self
.generator
.as_deref()
.map_or(true, |g| g.to_string_lossy().starts_with("Visual Studio")))
{
// Set CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR when cross compiling
let os = getenv_unwrap("CARGO_CFG_TARGET_OS");
let arch = getenv_unwrap("CARGO_CFG_TARGET_ARCH");
Expand Down Expand Up @@ -507,12 +521,6 @@ impl Config {
}
}

let generator = self
.generator
.clone()
.or_else(|| self.getenv_target_os("CMAKE_GENERATOR"));

let msvc = target.contains("msvc");
let ndk = self.uses_android_ndk();
let mut c_cfg = self.c_cfg.clone().unwrap_or_default();
c_cfg
Expand Down
Loading