4 ms·
CMake was a big improvement over make and autoconf years ago, but now it’s time to admit that it was a step to a wrong direction, dead end, cannot be fixed. CM
by lightgreen 6y ago
CMake was a big improvement over make and autoconf years ago, but now it’s time to admit that it was a step to a wrong direction, dead end, cannot be fixed. CMake model is wrong. CMake just need to retire.
- pmezard 6y agoWhat is the good model?
- lightgreen 6y agoBazel’s: * each build file is independent (unlike CMake where the project is one big script with global scope and side effects) * build script evaluation is hermetic (cannot read time for example) and strictly reproducible * target is rebuilt not by timestamp changes (which is unreliable for several reasons), but instead all dependencies must be declared, and target is rebuilt when the hash of dependencies change
- barumi 6y ago> each build file is independent (unlike CMake where the project is one big script with global scope and side effects) I don't understand your point. CMake projects specify build targets per module, and it's up to the developer to choose what he thinks should be a module. What value do you see in specifying build targets per file?
- lightgreen 6y agoI'm not saying about specifying build target per file. I say when cmake file includes another cmake file, all variables are inherited, and in certain cases cmake file can define variable in outer cmake file scope. Thus build files are dependent on each other. Inclusion order is important, and when project refactoring/restructuring, it's a common error, that resulting project is incorrect because for example, some file relied on the fact that when it is included, certain variables or macros are already set by someone else. This makes large project maintenance quite inconvenient. Especially because CMake does not guarantee that error will be revealed unless it is full clean rebuild.
- barumi 6y ago> I say when cmake file includes another cmake file, all variables are inherited, and in certain cases cmake file can define variable in outer cmake file scope. This is not true at all. You only "inherit" variables that you intentionally want to pass to downstream projects. You need to explicitly and intentionally declare your variables with PARENT_SCOPE to access variables from other files. That's an explicit decision from the developer.
- lightgreen 6y ago> You only "inherit" variables that you intentionally want to pass to downstream projects Yep, most project variables, except for some locals. > You need to explicitly and intentionally declare your variables with PARENT_SCOPE to access variables from other files. No you don't. PARENT_SCOPE is needed to write variables into parent scope, but not read. > That's an explicit decision from the developer. Even so. Yes, when working very carefully, when you are a single developer writing on a small projects, and enforce code style, it is possible to keep the mess manageable. When at least 100 people work on the project, if a project is several years old, if half of the team changed, CMake project is always a mess. (Source: I worked in two very different large companies which were using CMake; both of them eventually migrated away from CMake). Someone might blame developers for making that mess. I'd prefer blaming CMake, as I see the same developer keep projects in good shape when using Bazel (or another build system with similar model).
- barumi 6y ago> No you don't. PARENT_SCOPE is needed to write variables into parent scope, but not read. You're talking about an entirely different thing then. Subprojects do inherit scope, but that is only relevant if you intentionally, and for some reason, want to reuse variables that were inherited. This is often used to propagate config settings from the project root to all submodules, but you only do this if that's something you explicitly want to. > Even so. Yes, when working very carefully, when you are a single developer writing on a small projects, and enforce code style, it is possible to keep the mess manageable. It really isn't. If you're dealing with a problem where random team members break stuff without oversight or awareness of what they're doing, and if this happens so often that you start to deflect blame at tooling, then you're not dealing with a build system problem. You're dealing with poor software engineering practices that not only goes way deeper than the build system but also cannot be fixed by replacing it. > When at least 100 people work on the project, if a project is several years old, if half of the team changed, CMake project is always a mess. It really isn't. What's always a mess under those circumstances is unmaintained code developed without any care or oversight, which just builds crust by accretion. The choice of build system has no influence on that outcome, not does the problem stay circumscribed to the build system. As the saying goes, bad workers always blame their tools. Well, we can extend that saying to badly managed teams.
- endgame 6y ago> CMake was a big improvement over make and autoconf years ago I would not even grant this, and I spent a lot of time wrangling both CMake and autotools many years ago.
- andi999 6y agoWhat is the model of CMake. Probably I could use it better if I knew (I couldnt figure it out).
- lightgreen 6y agoBasically it is one big script (with globals and side effects) which generates makefiles. (Even if it does not generate makefiles, the project model is makefiles: targets, file names, timestamps.)
- andi999 6y agoSo the globals and side effects are the problem or the generating makefiles part?
- lightgreen 6y agoBoth are the problems. Because of side effects, when single cmake file modified, the whole project need to be regenerated. Also, because of side effects, project files become too frigile, for example, changing the order of two includes may result in incorrect project definition. And makefile generation part is problematic: using timestamps to check if something need to be rebuilt is unreliable (may result in not rebuilding something when project is actually changed).
- andi999 6y agoIsnt the makefile generation the only reason one uses cmake?
- lightgreen 6y agoIt is also used to generate project files for various ides. Also, (but I’m not sure), cmake have some built in make which does the build like mske would do but without generating makefiles and invoking real make.