Lately I’ve been getting interested in zig as a build tool. I am wondering if I can replace cmake with it.
I am working in a project that depends on opengl, glfw and imgui . I am on windows 11 and use mingw compiler from msys2. I am not really looking for a cross compatible solution, I just need something reliable since cmake is causing a lot of problem for me.
Will it be possible for me to ditch my ide and cmake(even mingw if possible), and replace them with just build.zig for building the executable? if so then how?
Note that the build file format has changed a bit in the meantime, but the core concepts stay the same. More recent examples can be found at All Your Codebase · GitHub, which contains Git repos of popular software ported to the Zig build system.
It depends on how many non-Zig external libraries, and how willing are you to rewrite the build scripts for those libraries. I ran into this problem (How to tell Zig not to rerun a certain step?) while trying to use Zig as a compiler to build a library and link it to Zig’s outputs. Compare to CMake, Zig is still not a full fledged build system regarding integrating non-Zig external libraries.
As for using Zig as the build system for C or C++ code base, you can check out Raylib, it’s a big C library that uses Zig as the build system.