by git-pull · 9y ago · 0 comments
IDE Support: KDevelop and CLion both support CMake as a flag ship project file.
Why? A CMakeLists.txt has all you need: the project's debug/release build commands, include's for completions, and library files.
Growing ubiquity: More and more open source projects are build around CMake
CoreCLR, Swift, lua, SFML, opencv, cafe, zlib, libevent, blender, protobuf
Some fast facts about these tools:
- CMake is complicated. Sure, there are macros. But it's not a bad thing. CMake's complexity is proportional to what it takes to do the job: finding header files and libraries across platforms, detecting compiler features, and so on.
- This isn't the kind of a job that can be solved by a simple, beautiful 50 line file.
For instance: Stuff like finding SDL2 header files across platforms is hard because OS leave them in /usr/include, /usr/local/include, then within that, some keep them under SDL or SDL2 within that. Ergo, custom modules need to be built to handle the differences that have organically manifested in distros over the years.
- In order to have software binaries built for as many platforms as possible, a build system needs to be able to test that certain functions exist.
For instance, tmux: https://github.com/tmux/tmux/blob/45ee118/configure.ac#L427. The only way for tmux to know if it should "polyfill" getopt is to run a small snippet of code.
If your system has it, it stores HAVE_GETOPT. If not, it has to get fill in getopt at https://github.com/tmux/tmux/blob/45ee118/compat/getopt.c via https://github.com/tmux/tmux/blob/45ee118/compat.h#L352
- Understand the point of these kind of tools is solve a problem: Getting your source to build across a range of platforms, not just Ubuntu!
- Not to mention, CMake has compatibility for various generator outputs. For instance, it can output Visual Studio projects, XCode projects, and even more popular, Ninja (https://ninja-build.org/)
- CMake gives leaves helpful debug output when so you can get help when you're troubleshooting (cmake --system-information sysinfo.txt)
As a big CMake fan, I don't think CMake's success has anything to do with their super ugly custom language. What CMake does could be a lot more ergonomic, especially from a typical user's standpoint.
Real pain is that a lot of CMake features are badly documented and most of available information is outdated, but this is usual problem at least for open source C++ projects so it's doesn't cause a lot of frustration and no one try to fix it.
Another point I'd like to add here: CMake basically takes to you what autoconf/automake can do (+ 5/10 years of improvement on UX/UI), but it:
a) doesn't use absurd amounts of slow shell code trying to detect features that no (non-EOL) OS has been missing for the last 20 years.
b) is actually reasonably readable. (Ok, m4 is sort of readable, but it a bit weird in places.)
c) is actually better documented (IME) than autoconf/automake. What people usually do for autoconf/automake is just copy/paste another project/snippet. .. hence leading to the 20+ years problem. (I'll definitely agree that the docs aren't great, but that's at least a problem that can practically be fixed unlike the copy/paste problem of autoconf/-make.)
[1] http://mxe.cc/