An Introduction to Modern CMake
cliutils.gitlab.io
An Introduction to Modern CMake
1–10 of 43 posts
Re: An Introduction to Modern CMake
#2CMake 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 also provide a free Eclipse-based option which targets their chips, and there are usually flavors of GCC for the adventurous.
CMake does have a nice way to add support for a new IDE or compiler in a modular way; you write a "generator":
https://cmake.org/cmake/help/latest/manual/cmake-generators....
My pet peeve is, it seems like nobody does that. Instead, they try to re-write all of the logic which generates build files either using CMake's internal logic, or one-off scripts which get called from CMake.
If (for example) Espressif provided a CMake generator for their style of `xtensa-elf-gcc` Makefiles, everybody could use that to quickly add build support for ESP32s to their CMake systems. What they use now doesn't seem to be very easy to re-use. Ditto for companies like ST/TI/Microchip/etc; if they provided CMake generators for their Eclipse IDEs, people wouldn't have to keep re-inventing the wheel and making it square-shaped.
It makes me dread using embedded libraries that use CMake-based build systems, even though I really like CMake as a cross-platform build system.
Re: An Introduction to Modern CMake
#3Something 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 presentation or conference video - focus on different aspects of work with CMake, but you probably need most or all of them in focus in order to actually do what you need done. That's how you can see videos entitled "More Modern CMake" and "Oh No! More Modern CMake"...
* Setting up the CMake machinery to have your repository/project installed is the opposite of straightforward, and very easy to get confused about.
* There are a half-dozen different ways to have your project depend on on other code: External projects, package management CMake modules, relying on other projects being installed in a CMake-idiomatic way and then find_package working, and more. Regardless of which you think is the right one, you'll need to live with others doing something else.
So, do follow the link, but don't expect it be sufficient.
Re: An Introduction to Modern CMake
#4I'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…
Re: An Introduction to Modern CMake
#5Re: An Introduction to Modern CMake
#6I'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…
then what's the point of cmake? won't legacy gnu make suffice? nothing is perfect including Make, but it seems gnu Make can put all its doc into one html manual at least. KISS. https://www.gnu.org/software/make/manual/make.html
Re: An Introduction to Modern CMake
#7I'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…
The official docs are too sparse to be useful to me and the results of googling mostly give stale advice.
I also have being easing into CMake recently - I was initially impressed as getting a "hello world" example was simple and the CMakeLists.txt was clear. As the project has progressed - simple additions like unit tests, external dependencies, specific aspects for debug builds, handling basic cross platform differences, etc. have made the CMakeLists.txt almost unreadable and really quite brittle.
I'm not quite at the stage of abandoning it but I have wondered whether an old fashioned Makefile wouldn't be simpler. At least there is a logic, if convoluted, to make and the documentation is top class. CMake seems to lack a clear design and just seems like hack on hack but this could be my ignorance.
I've no real idea of what I'm dealing with when working with CMake - it's wears declarative clothing but actually it isn't at all. The ordering of CMakeLists.txt is significant and you have to be aware of whether what you add will be "executed" during cmake or gets executed with cmake --build.
Re: An Introduction to Modern CMake
#8Don't use cmake for new projects. You'll regret it. Try meson instead: https://mesonbuild.com/
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 CMake.
Re: An Introduction to Modern CMake
#9I'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…
then what's the point of cmake? won't legacy gnu make suffice? nothing is perfect including Make, but it seems gnu Make can put all its doc into one html manual at least. KISS. https://www.gnu.org/software/make/manual/make.html
Re: An Introduction to Modern CMake
#10Don'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…