5 ms·
What's more simple than "add_executable(foo bar.cpp)"? It's concise, cross-platform and hides all the boilerplate for you. Sure, everything in CMake is not sup
by Orphis 8y ago
What's more simple than "add_executable(foo bar.cpp)"?
It's concise, cross-platform and hides all the boilerplate for you.
Sure, everything in CMake is not super intuitive, but I've led workshops were people got the hang of it pretty quickly for simple to advanced cases (including multiple targets and some scripting). Keep it simple, most of the time, you don't need the advanced features at all!
Can't say the same for Make, apparently, people need to write about it still today! And most of the Makefiles are just plain wrong and won't make any reproducible and reliable builds. That's a big no in my book for a build system!
- ghthor 8y agoIts here I look to KISS to guide me. A Makefile is simple and you can expect it to be on most systems, so it's a good place to start stringing things together. It helps you start building a CLI UI with relative ease, once you know you should mark all ephemeral targets as .PHONY. As a project grows and gains users or requires more system support, the growth of Make usage to declare interdependence should always be discussed. At some point the team will need to start using a different tool, perhaps isolating Makefile usage to bootstrapping the bigger tool. The reason I reach for Make is I know it, and it's rather intuitive for someone to glance at my Makefiles and get an overview of where to look next.
- Orphis 8y agoIt is rather intuitive for someone knowing Make. Even then, which version of Make are you talking about? GNUmake? WHICH VERSION again? 3.82? 4.0? Some features in 4.0 aren't backward compatible of course, so you have to be precise about what you are exactly targeting. If you are using anything advanced, then it will become unreadable for beginners too. Try to explain delayed and immediate variable interpolation to beginners, that their "VAR = foo" doesn't always work the way they think it does. On the other hand, yes, the CMake sample above is self explanatory, works on all platforms (more than Make itself), all compilers without having you to write low level compiler invocations, supports IDE for easier debugging (sure, you can also tell your users they have to learn how to use GDB by hand, just... good luck). It will automatically rebuild the right files when their dependencies or command line changes, you don't have to code that by hand for each compiler (and probably have many subtle bugs in your implementation too). Make has a place for simple things, not for build systems, we have way better ways to do them now, even if you refuse to use them.
- ghthor 8y agoI'd like to understand where in my comment I stated that I "refused" to use better tools. I even stated that it's important for the team to discuss tooling as a project gains users. Learning new tools is something I enjoy doing, but as my career continues my focus is changed. I haven't once walked into a project where I've felt the need to re-tool the build system because it wasn't living up to the task. And for your information, my company has a monorepo and we build using pants, which I'm starting to grow quite fond of. I may have some bias towards learning new tools, likely why I like go so much. All the tools(now that we have modules and MVS), none of the hassle.
- theamk 8y agoI don’t think I ever saw (GNU)make version problems. Most Makefiles I have seen in the wild were using pretty basic features. On the other hand, trying to get Kitware’s stuff to compile was a real horror. I ended up adding Docker to the project just to get the right CMake version. And debugging the buildsystem was hell. I hope I never have to touch CMake again in my life.
- stonogo 8y ago> What's more simple than CMake 3.6.0 or higher is required. You are running version 3.5.1
- Orphis 8y ago"GNUmake is required, but you are running FreeBSD". Not saying it's not available there, not all platforms have all software available right away or up to date. Even then, upgrading CMake is the easiest thing ever: "pip install cmake". Or fetch it from the Github releases page quickly, it's always available as static binaries for all major platforms.
- theamk 8y agoIf it was only that simple.. there are packages out there which require specific older version of cmake. So sometimes you have to downgrade, too.
- theamk 8y agoYou forgot -Wall. Also, does this enable C++11? And don’t forget to set that NDEBUG macro. All the things above is still a 2 line Makefile. And it is intuitive, too - you jusy copy your command-line g++ invocation and paste into Makefile.
- Orphis 8y agoThat has nothing to do with the compilation of your program. This is a specific option to use in a specific configuration and specific compilers. So if you want a configuration with some flags like that, then you can have a separate file for it. Each compiler is different after all, some will need different options.
- jopsen 8y agoSomething like: include "rules.mk" foo: bar.cpp But if the syntax for cmake was more sane, I would like it a lot more... Why does cmake use a DSL, and let me define targets as first class objects..