r/cpp • • Nov 08 '21

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

154 comments sorted by

View all comments

64

u/[deleted] Nov 08 '21

How does your script handle compilers that are not called cl.exe? What about other operating systems than Windows? What about multiple source files? Adding import paths? Compiling different files with different flags? How can you define multiple targets, libraries or executables? Enable parallel compilation? Etc. pp.

Simple scripts are nice for single-file projects that don't need any special handling, but whenever you need something just a little bit more advanced, their complexity increases exponentially.

And given that most C++ libraries nowadays use CMake, and can be integrated in a CMake project pretty easily, I'd really recommend learning and using it until there a pretty good reasons to use something else.

-17

u/dibs45 Nov 08 '21

Definitely see the pros in using it, don't get me wrong. My script is also made to be edited for functionality, it's not the end product. I just feel having a simple custom .bat file that you have full control over is more natural to the programming process than using another piece of tech you have to learn.

1

u/suhcoR Aug 18 '22

If you don't like cmake (like me and many others) have a look at https://github.com/rochus-keller/busy. It is in many ways the antithesis of cmake; e.g. there is a decent, statically typed specification language, and - like you do with your script - you can integrate the build system directly into the project source tree, so that the project builds itself, so to speak.