CMake Tutorial for Absolute Beginners - From GCC to CMake including Make and Ninja

preview_player
Показать описание
If you write any C/C++ code for the Raspberry Pi Pico (or Pico 2) using the official SDK then you will need to use CMake. But, what is CMake? Does it replace Make or work with Make? In fact, what is Make? Here is my tutorial for absolute beginners.
---

00:00 Intro
01:19 gcc
02:17 gcc demo
02:41 More gcc
04:29 Another gcc demo
05:35 Make
07:36 Make demo
09:29 Makefile complexity
10:00 CMake
11:34 Out-of-source builds
13:24 CMake demo
16:40 The beauty of CMake
17:28 Ninja
19:06 CMake and Ninja demo
20:02 Summary
20:27 Outro

#garyexplains
Рекомендации по теме
Комментарии
Автор

The most perfect tutorial on cmake and make. It rightly takes half of a video to build up to the requirement of the tool.

vatsalpandya
Автор

Used it and others w/ 42 yrs as programmer, analysry manager, director, and now, retired from code for a living to code for fun. It always was fun - they paid me to have fun!!!.

muddyexport
Автор

Thank you for making a video that starts at the most basic and builds upward in complexity. Trying to understand CMake coming from the opposite direction (ie: from an output pane in VS Code that spits an error out at you why it can't build your binary file) is very difficult. THanks for including Ninja as well because I've been seeing mentions of Ninja and knew it was a "generator" but didn't know what that meant until now. 10 YouTube logos of out 10 for this video.

cabji
Автор

Very useful, thanks! I have been retired for years now, but made my living as a software developer for decades. I wrote almost entirely in C, and worked on projects that required a lot of effort to construct and maintain the makefile. In recent years I began returned to programming as a hobby, including tinkering with MCUs. When I discovered that CMake is now a thing, I was quite daunted. Oh no - another meta level of build system to learn. So I avoided it. But I guess it's time to bite the bullet and learn it, because I have pretty much hit the limit with arduino IDE. So once again, thanks for this intro to CMake.

djpenton
Автор

I know how to write C programs, but I've always had big training wheels. As I started to dig deeper, I've come across the term Cmake, but never had a clue what it was. Thank you for your clear introduction.

lorinczhuff
Автор

Long time C# developer but doing some c/c++ as a hobby. This is the best make/cmake introduction I have seen, thanks!

markrobinson
Автор

Thanks Gary, make was a bit of a mystery to me this really sorted it out.

bartdemeulmeester
Автор

All the great content are free and I have nothing to complain. But (sorry) this other than some AI stuff is what I have expected from Gary. Thank you for the effort. The explanation was crystal clear!

hiankun
Автор

Thanks. Could you do a similar beginners guide to setting up your first github/gitlab project on a home network NAS or local hard drive? Or maybe you've already covered this?

djsbriscoe
Автор

watched a few times. enjoyed the simpilicity and clarity in your tutorials.❤❤ It feels good learning with gary

OmidAtaollahi
Автор

👍
Fun fact: GNU make provides a (huge) set of default rules. If the executable is made of a single source file (not limited to C or C++) then you don't need a Makefile at all. Just run "make hellow". The executable base name must be that of the source file, it's the only requirement. More precisely, the executable name is derived from the source base name.

nashaut
Автор

Thanks, Gary. This is outstanding - this saves me days of explaining CMake for new hires. How about a similar look at the GNU autotools? There are still loads of projects using them.

RocktCityTim
Автор

Thank you Gary. Please continue explaining Cmake further.
BTW, the random example gives the same result every time. Even on my computer I get the same sequence [ 0.767554, 1.104780, 1.069596, 1.084488, 0.245279, 0.580639, 0.292428, 1.135251, 0.902894, 0.226394 ] . Not very random... 😁

HyyskanPolttaja
Автор

(Useful tip in last paragraph)

I've been using make since System V but have wondered about cmake. This was a great explanation, as the man pages are, well, long and don't encourage reading.

I'm not convinced, as make is quick to set up for small/medium projects (default rules).
What's always been tricky (for over 40 years) is knowing what the dependencies are in order to define the rules!

Clang/LLVM (and I think gcc) has the -M option that can list the dependencies in Makefile format, but not cmake. And it's not in the standard man page! Just run cc -M test.c (or whatever) and it'll list what goes in to making it. -MM is the same, but without header files.

frankleonhardt
Автор

Great video Gary, it is appreciated! If you make a followup video, could you explain a little about what those other cmake files are in the build directory? And of course, a bit more about the options in the CMakeLists.txt file. 👍

gregholloway
Автор

THIS IS THE VIDEDO !!!! THIS IS IT.

mohitsethi
Автор

I love this back to basics series. Gary is great again !

dabdoube
Автор

Thank you. This is good info. I can compile basic projects, and used make 30 y ago and have forgotten the bit I knew then. This will certainly help.

bertblankenstein
Автор

In addition to not having to type and tell gcc to compile all the files by using make/cmake, you also avoid recompiling items that were not updated/touched since the last time they were compiled. This saves a lot of computer time and was probably more important in the good old days.

bertblankenstein
Автор

I wish I had watched this first! My first look at cmake was to build opencv on widows--not for the faint of heart. This video gave me the overview I needed. Thanks so much!

windysynth