Alright, so my CS class makes me build for Windows (my entire college runs pretty much entirely on Microsoft stuff). Anyone who knows me also knows that I am very much not a Windows user.
So what do I do? Cross compile, right? No! Not only is it a pain in the ass (and MinGW builds massive executables), but the ARM transition on the Mac side is right around the corner, and I really don’t want my build system for x86 Windows machines to break in a few months.
So this is where GitHub Actions comes in — I can use a GitHub Action to build for Mac, Windows (with MinGW and MSVC), and Linux, all on machines natively running those OSes (no cross-compiling!)
I took Cristian Adam’s Hello World template and modified it to be better as a template (removed the README, added a .gitignore and .prettierrc, and forced MinGW to statically link everything as it would refuse to run in my test VM otherwise).
So I just create a new repo with that template, then write my code with that template, and then just push when I want to build for other people’s machines, and hey presto:
I have Windows, Mac, and Linux builds of C++ projects.
My template with all of the modifications that make it more useful to me is available here. I hope it’s useful to you, too!