Help move emglken over to using CMake

I’d like to move emglken over to using CMake, and thought I’d ask here if anyone has experience with CMake and would be willing to help. I’ve actually tried twice already (you can see my last try here) and I made some progress, but didn’t get all the pieces working together. I suspect it wouldn’t be that involved for someone very proficient with CMake, but it’s a big shift from Make for someone who’s new to it.

If you could help, that would be awesome, please get in touch.

I have experience with it, and I can advise you to keep clear of it and go with Meson, xmake or ftjam instead. CMake is one of those “enterprise-grade” build systems that people use only because they have to. If you don’t have to, don’t. I discovered this too late myself, but there’s still time to save yourself yet!

I haven’t heard of any of those three, so will definitely check them out, thanks!

If you don’t have complicated build requirements, meson works quite well.

I eventually got Glulxe to build with emscripten using Meson, but Meson really isn’t designed for emscripten when non-C files need to be passed to the compiler. It felt as hacky as CMake, if not more.

I’ll give ftjam a try next.

I tried a couple of other systems, before deciding to give CMake one last try. Previously I’ve tried using CMake with nested CMakeLists.txt files in each directory, but this time I just used one file. There was still a little bit of faffing around with the JS dependencies, but I’m happy with how it works, and Emscripten comes with some extra CMake functions for handling some of its options.

As part of this change I’m now building from an unmodified source folder of Git and Glulxe - this should make updates easier going forward.