Skip to content

Commit

Permalink
Improve support for building on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpana authored and andrewrk committed Oct 11, 2021
1 parent 4be3ad6 commit 3dbb8de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -32,3 +32,10 @@ A simple tetris clone written in
```
zig build play
```

## Building on windows using vcpkg

* Install vcpkg https://github.com/microsoft/vcpkg
* Install dependencies using `x64-windows` triplet
* Use the flags `-Dwindows -Dvcpkg` when building the project

10 changes: 9 additions & 1 deletion build.zig
Expand Up @@ -4,6 +4,7 @@ const builtin = @import("builtin");
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const windows = b.option(bool, "windows", "create windows build") orelse false;
const vcpkg = b.option(bool, "vcpkg", "Add vcpkg paths to the build") orelse false;

var exe = b.addExecutable("tetris", "src/main.zig");
exe.addCSourceFile("stb_image-2.22/stb_image_impl.c", &[_][]const u8{"-std=c99"});
Expand All @@ -15,12 +16,19 @@ pub fn build(b: *Builder) void {
.os_tag = .windows,
.abi = .gnu,
});

exe.linkSystemLibrary("glfw3dll");
} else {
exe.linkSystemLibrary("glfw");
}

if (vcpkg) {
exe.addVcpkgPaths(builtin.LinkMode.Dynamic) catch @panic("Cannot add vcpkg paths.");
}

exe.addIncludeDir("stb_image-2.22");

exe.linkSystemLibrary("c");
exe.linkSystemLibrary("glfw");
exe.linkSystemLibrary("epoxy");
exe.install();

Expand Down

0 comments on commit 3dbb8de

Please sign in to comment.