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

Fix Windows CMake build error #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
if: matrix.toolchain != '1.63.0'
shell: bash
run: |
set -e
set -euo pipefail
git clone --recurse-submodules https://github.com/gyscos/zstd-rs.git tests/zstd-rs
cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target aarch64-unknown-linux-gnu
cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target x86_64-pc-windows-gnu
Expand All @@ -97,7 +97,7 @@ jobs:
env:
SDK: MacOSX11.3.sdk
run: |
set -e
set -euo pipefail
curl -sqL https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/$SDK.tar.xz | tar -Jx
export SDKROOT=$PWD/$SDK

Expand Down Expand Up @@ -127,7 +127,9 @@ jobs:
ldd -r -v ./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild
./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild --help
- name: Linux - Test glibc build
shell: bash
run: |
set -euo pipefail
cargo run zigbuild --target aarch64-unknown-linux-gnu
cargo run zigbuild --target aarch64-unknown-linux-gnu.2.17

Expand All @@ -142,6 +144,7 @@ jobs:
- name: Linux - Test glibc run/test
if: matrix.os == 'ubuntu-latest'
run: |
set -euo pipefail
# Install qemu for `cargo-zigbuild run` support
sudo apt-get update
sudo apt-get install -y qemu-user qemu-user-static gcc-aarch64-linux-gnu binfmt-support
Expand All @@ -160,7 +163,9 @@ jobs:
cargo run zigbuild --target aarch64-unknown-linux-musl
cargo run zigbuild --target aarch64-unknown-linux-musl --manifest-path tests/hello-rustls/Cargo.toml
- name: Windows - Test gnu build
shell: bash
run: |
set -euo pipefail
cargo run zigbuild --target x86_64-pc-windows-gnu
cargo run zigbuild --target x86_64-pc-windows-gnu --manifest-path tests/hello-windows/Cargo.toml
cargo run zigbuild --target i686-pc-windows-gnu
Expand All @@ -171,7 +176,9 @@ jobs:
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml --features curl
- name: Windows - Test run
if: matrix.os == 'windows-latest'
shell: bash
run: |
set -euo pipefail
./target/x86_64-pc-windows-gnu/debug/cargo-zigbuild.exe zigbuild --help
./tests/hello-windows/target/x86_64-pc-windows-gnu/debug/hello-windows.exe

Expand Down
9 changes: 5 additions & 4 deletions src/zig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,10 @@ impl Zig {
r#"
set(CMAKE_SYSTEM_NAME {system_name})
set(CMAKE_SYSTEM_PROCESSOR {system_processor})
set(CMAKE_C_COMPILER {cc})
set(CMAKE_CXX_COMPILER {cxx})
set(CMAKE_RANLIB {ranlib})"#,
set(CMAKE_C_COMPILER {cc} CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER {cxx} CACHE FILEPATH "")
set(CMAKE_LINKER {cc} CACHE FILEPATH "")
set(CMAKE_RANLIB {ranlib} CACHE FILEPATH "")"#,
system_name = system_name,
system_processor = system_processor,
cc = zig_wrapper.cc.to_slash_lossy(),
Expand All @@ -877,7 +878,7 @@ set(CMAKE_RANLIB {ranlib})"#,
);
if enable_zig_ar {
content.push_str(&format!(
"\nset(CMAKE_AR {})\n",
"\nset(CMAKE_AR {} CACHE FILEPATH \"\")\n",
zig_wrapper.ar.to_slash_lossy()
));
}
Expand Down