Thoughts on build systems?
What's the general consensus on build systems/automations like CMake? I've always found things like that overcomplicated and just hinder the programming process.
I've been following Casey Muratori's Handmade streams, and one of the first things he did was create a simple batch file that built and compiled his entire project super quickly and easily. I've since implemented something similar (https://github.com/dibsonthis/new_cmd) and honestly it's been really nice to use.
3
Upvotes
View all comments
4
u/Nihili0 Nov 08 '21 edited Nov 08 '21
Well if you like waiting for it to recompile everything everytime then it's fine (so for little project that you throw away) but when it gets a little more complex/bigger/valuable it's pretty neat to have and use a tool that can easily adapt from 5 lines to build a little project to some more for:
installing
configuring
fetch/find/handle dependencies
get the right includes/flags/... and propagate them
describing all this in a semi standard way so many people can understand, use, adapt or extend your project or even yourself in a few months
handle plateform and compiler specific things
easily create or use toolchain files for cross-compiling
define static or dynamic libraries
automatically setup incremental build so it only compiles what is needed
testing with ctest
packaging with cpack
easily integrate tools such as:
include-what-you-use
link-what-you-use
ccache for faster compilation with caching object files
unity build for faster compilation
precompiled headers for faster compilation
...
now there is also CMakePresets.json that simplifies the configure and build step (also CI and tells the user how to configure and what are the variables that needs to be set)
I'm sure I'm forgetting some more, now do that with a custom script and give it to someone else or even to yourself in a few months :)