Skip to content

Instantly share code, notes, and snippets.

@kassane
Last active March 18, 2024 09:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kassane/2b5fd8e5c4be2ff86b3ae4b7a1f2d663 to your computer and use it in GitHub Desktop.
Save kassane/2b5fd8e5c4be2ff86b3ae4b7a1f2d663 to your computer and use it in GitHub Desktop.
Zig compiler on C/C++ projects - CMake, Meson and other

Unix-like

$> export CC="zig cc $@"
$> export CXX="zig c++ $@"
...
# your build system
$> cmake or meson - commands

Windows

PS C:\Users\My-PC\project> $Env:CC="zig cc %*"
PS C:\Users\My-PC\project> cmake or meson - commands

or Batch script:

set PATH=zig_PATH;%PATH%
set ZIG_LOCAL_CACHE="%TEMP%"" && zig cc %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment