An Introduction to Modern CMake
11–20 of 43 posts
Re: An Introduction to Modern CMake
#12Don't use cmake for new projects. You'll regret it. Try meson instead: https://mesonbuild.com/
Unfortunately even if you're starting a new project chances are that your dependencies are using cmake and they expect their dependencies to use cmake... in the end of the day you spend a lot of time fixing the upstream projects build files. More than that CMake at this point is the ""standard"" and there are many others with a similar share of the market and selling points, it makes it harder to pick one that is not…
(Which is a whole other thing with this "modern CMake" by the way: only half of them that come with CMake are "upgraded" to modern and if you don't want to require the absolute latest version, you end up having to check what the FindX script did or redefine stuff manually)
Re: An Introduction to Modern CMake
#13Don't use cmake for new projects. You'll regret it. Try meson instead: https://mesonbuild.com/
(It's been a while since I did semi-serious C++, maybe nowadays we're playing a bit more loose with deps and polyglot setups)
Re: An Introduction to Modern CMake
#14I mean, if you learn classic make, one of the very first things you learn is "this is a target; it's just a file; the stuff on the right are dependencies; the commands below will be run whenever the dependencies are newer than the target". Now, there are implications to learn, but that is the model, and it's obvious: make runs programs to create files when the stuff needed to create the file changes.
Now, how do I do that in cmake? It's almost not even here! It's all about C++ files and libraries and how to define variables and write functions and include other cmake files. But what is it going to do with that stuff? It's all just magic. Type it like this and it'll work. Cmake understands your compiler better than you do.
What docs there are on creating a custom target are buried in two paragraphs inside a subsection named "Running a command at build time". And it barely tells you how to do this at all (this being a topic I've actually struggled with in the past). In particular it fails to mention that a target is is not the same thing as a file in cmake, and that this has implications that are likely to be surprising to make experts.
Re: An Introduction to Modern CMake
#15"The --trace option will print every line of CMake that is run. Since this is very verbose, CMake 3.7 added --trace-source="filename", which will print out every executed line of just the file you are interested in when it runs. If you select the name of the file you are interested in debugging (usually by selecting the parent directory when debugging a CMakeLists.txt, since all of those have the same name), you can just see the lines that run in that file. Very useful!"
Re: An Introduction to Modern CMake
#16We started using it about 6 months ago for a cross platform CUDA project, and have found it to be a big improvement over how we previously managed similar CUDA projects (e.g. manually). I'm especially a fan of it's ability to download external CMake project dependencies. As others have mentioned, some of the documentation is a little unclear for particular edge cases though so it takes some familiarisation.
Re: An Introduction to Modern CMake
#17Don't use cmake for new projects. You'll regret it. Try meson instead: https://mesonbuild.com/
Re: An Introduction to Modern CMake
#18Nice to see a CMake guide here, but I don't see any discussion of generators at a cursory glance, even in the "IDEs" section. CMake is used a lot in embedded development with large or cross-platform projects, like an RTOS or the famous ESP-IDF. Unfortunately, the embedded development space is a messy hodge-podge of IDEs. There are shiny commercial ones like Keil which support most kinds of devices, but most vendors a…
Why wouldn't you do it with CMakes internal logic? Isn't that the point, especially since it is cross-platform.
Re: An Introduction to Modern CMake
#19Nice to see a CMake guide here, but I don't see any discussion of generators at a cursory glance, even in the "IDEs" section. CMake is used a lot in embedded development with large or cross-platform projects, like an RTOS or the famous ESP-IDF. Unfortunately, the embedded development space is a messy hodge-podge of IDEs. There are shiny commercial ones like Keil which support most kinds of devices, but most vendors a…
Not sure you want to tie yourself to a buggy inconsistent IDE and force that upon all developers. Why wouldn't you do it with CMakes internal logic? Isn't that the point, especially since it is cross-platform.
Generators are there so that you don't get tied to any one IDE; you select a different generator when you want to use a different IDE or compiler, but your CMake logic can largely stay the same besides that.
If I were a cynic, I would say that the vendors probably don't mind it being difficult to interoperate with their competitors' products, so there's little incentive to support things like that.
Re: An Introduction to Modern CMake
#20I'm a person who has been easing into CMake use over the past few years. Something I've noticed is that there is no such thing as a single good introduction : * CMake itself is changing. While the "revolution" of modern CMake is upon us already from version 3.0 (or a little earlier), a bunch of thing change with versions 3.12, 3.13 etc. See: https://youtu.be/y7ndUhdQuU8 * Different treatments - a mini-website, PDF pr…
Nobody really wants to focus too much on build configurations when working on things, they should 'just work'.
And CMake, although I am using for a long time already, is not the offering this 'just works' experience I am afraid. It is so easy to introduce side-effects, and figuring out the intended way to include a project can be a big pain when documentation is sparse. Sometimes I wished I had a CMake debugger. And with modern CMake I feel like this got worse to some degree.