4 ms·
Cmake is confusing as all get out. Make follows the Unix philosophy of just doing one thing - call other programs. It comes with almost all tool chains you’d ca
by 0x20cowboy 4y ago
Cmake is confusing as all get out. Make follows the Unix philosophy of just doing one thing - call other programs. It comes with almost all tool chains you’d care about. You can pick up the basics of a makefile in an afternoon… I still don’t know where cmake functions come from, how you would know about them or how to write your own. Let alone which version is the right one.
It’s like jsonnet to me - if you need config files that make config files something has gone horribly wrong.
Then again, I stopped bothering trying to learn Cmake. If I see Cmake I don’t bother with the project so there’s that - and also not a fan of c++ so I am probably the wrong audience anyway.
- self_awareness 4y agoWhat is confusing about CMake? cmake_minimum_required(VERSION 3.5) add_executable(exe file.cpp) Do you think that's more complicated than the basics of a Makefile? [1] [1]: https://anadoxin.org/blog/is-it-worth-using-make.html/ https://anadoxin.org/blog/is-it-worth-using-make.html/
- amag 4y agoThere are very few projects for which the above CMakeLists.txt would be enough. Once your project reaches a certain size you will inevitably end up in a part of CMake that is confusing.
- self_awareness 4y agoWell, first argument is that it actually IS enough for lots of small tools, and second argument is that if it's not enough and must be extended, it still requires much less complication than an equivalent Makefile.
- ori_b 4y agoThe comparable makefile: exe: file.cpp Default rules take care of the rest. And if you argue that the barebones example is insufficient for a real project: absolutely true. The same applies to your cmake example.
- self_awareness 4y agoWhat do you mean it's comparable? Does it support multiple compilers? CFLAGS? Out of source builds? "compile_commands.json" generation? Automatic header dependency monitoring? Also I've actually checked that Makefile, and it errored out (macOS): make: Nothing to be done for `exe'.
- ori_b 4y agoHere's what you get for free: https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html#Catalogue-of-Rules https://www.gnu.org/software/make/manual/html_node/Catalogue... As you can see, it takes flags and compiler from the environment.
- self_awareness 4y agoIt seems that in order to use the default rules, the target name needs to have the same name as the source file, e.g. file: file.cpp so specifying the "exe" filename as the output seems to be already a custom rule, so it doesn't seem to work without manually calling the selected compiler. Another issue is that indeed, CC+CFLAGS is supported by default (implicit) rules, but as soon as the user tries to build a custom rule (which is 99% of the time), the support is lost unless explicitly adding it. Third issue is that it seems that implicit rules can be different by different implementations of make, i.e. BSD make can have different rules than GNU make. Even if we consider only one implementation, then default rules can be different to each platform. The docs state that the user should consider the output of the `make -p` command in order to see the rules, which gives me an impression that different implicit rules can exist on different Linux distros, depending on how `make` was compiled (not sure what is the de facto state). I mean, it doesn't sound simple.
- ori_b 4y agoYep. In practice, make gets bigger. cmake also ends up looking like this: https://github.com/opencv/opencv/tree/4.x/cmake https://github.com/opencv/opencv/tree/4.x/cmake Trivial examples look nice enough in either system, big ones look bad in make and utterly fucked in cmake. Some of this is that people keep trying to write things in cmake scripts that should be external programs in a workable language.
- pjmlp 4y agoOnly if you are talking about bare bones POSIX compliant makefiles, which most definitly aren't, hello autotools.
- account42 4y ago> I still don’t know where cmake functions come from, how you would know about them or how to write your own. There is a lot to criticize about CMake, but this is just RTFM level silly.