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

Поделиться
HTML-код
  • Опубликовано: 23 дек 2024

Комментарии • 151

  • @vatsalpandya5415
    @vatsalpandya5415 Месяц назад +18

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

  • @cabji
    @cabji 24 дня назад +5

    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 RUclips logos of out 10 for this video.

  • @muddyexport5639
    @muddyexport5639 2 месяца назад +7

    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!!!.

  • @lorinczhuff2022
    @lorinczhuff2022 2 месяца назад +6

    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.

  • @djpenton779
    @djpenton779 2 месяца назад +4

    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.

    • @toby9999
      @toby9999 2 месяца назад

      I have been using C and C++ since the 90s and have never touched a make file. It's just such an archaic concept when we have automation tools. Can you imagine constructing a make file for a project with 10,000 files? Thing is, CMake is also pretty bad. I've literally spent days trying to get CMake working.

    • @GaryExplains
      @GaryExplains  2 месяца назад +1

      @toby9999 Interesting comment. How did you build projects with 10,000 files without a build system?

    • @djpenton779
      @djpenton779 2 месяца назад

      @@GaryExplains My last job as a software guy was for a company in Calgary, Alberta. This was an ill-fated (an ill-conceived) effort to produce a message-passing based operating system, and ALL of the application layers on top of it, to implement large scale SCADA systems. I came to the company late in the game, and became something of a Cassandra because it quickly became obvious to me that the basic structure of the software was completely unworkable. (Imagine a software team of 20 people trying to implement linux, X11, the Chrome browser, and all the glue as one monolithic system. Nope....) IIRC, the software - from the lowest hardware level up - was built using make, and a dauntingly complicated makefile. Coding and maintaining this alone was a major effort. At that time in my career I had never heard of CMake, and don't actually know whether it existed. This build strategy was in microcosm representative of the project's design flaws, but was not its biggest flaw.

  • @markrobinson2648
    @markrobinson2648 2 месяца назад +3

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

  • @bartdemeulmeester4662
    @bartdemeulmeester4662 2 месяца назад +8

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

  • @ElectronicFanArm
    @ElectronicFanArm 2 месяца назад +10

    Loved this thanks Gary for sharing ❤

  • @hiankun
    @hiankun 2 месяца назад +2

    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!

  • @djsbriscoe
    @djsbriscoe 2 месяца назад +20

    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?

  • @OmidAtaollahi
    @OmidAtaollahi 2 месяца назад +1

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

  • @nashaut7635
    @nashaut7635 2 месяца назад +20

    👍
    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.

    • @rajmajumdar5253
      @rajmajumdar5253 2 месяца назад +3

      Wait what really?

    • @nashaut7635
      @nashaut7635 2 месяца назад

      @@rajmajumdar5253 Yup. Just try it. Note that default flags will be used unless you pass them to make or via the environment. Example: `make CFLAGS=-Os -Wall hellow`.

  • @HyyskanPolttaja
    @HyyskanPolttaja 2 месяца назад +6

    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... 😁

    • @GaryExplains
      @GaryExplains  2 месяца назад +4

      As with all Pseudo-Random Number Generators (PRNGs), they just use a mathematical algorithms to generate numbers. Without providing a seed (which this program doesn't do) then they will always generate the same sequences.

    • @zorabixun
      @zorabixun 2 месяца назад +1

      Gary, that is strange, why is that implemented if resulting the same effect 🙉 .. when i started computing on ZX81 it was very good random numbers generator, we were doing tests with colours, or symbols,
      Later on, i was using Atari 520 ST, and it was lighting fast with numbers never repeated ..
      I'm missing these computers, so romantic times, exciting and i was soooo happy to exchange software listings with friends to see results, testing days, and days, sorting programs, etc 🌞
      On ATARI 520-ST compilers GFA-Basic ultra fast, objective, Pascal, Mark Williams C compiler with a system like Linux .. Thanks 🎉

    • @GaryExplains
      @GaryExplains  2 месяца назад +2

      The program isn't the important thing here, but the build system. As I mentioned to the OP, a seed needs to be provided to every PRNG. On many systems (but not all) the seed is automatically set on the first call to get a random number, the seed is often based on the current time and therefore different every time the program runs.

    • @rmfeld
      @rmfeld 2 месяца назад +2

      @@zorabixun It can sometimes be helpful to generate a random but repeatable sequence of numbers to have the same conditions on every run. Therefore delivering the seed to the random number generator is an extra and depending on your application optional step.

  • @RocktCityTim
    @RocktCityTim 2 месяца назад +4

    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.

  • @frankleonhardt3337
    @frankleonhardt3337 2 месяца назад +2

    (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.

    • @talideon
      @talideon Месяц назад

      cmake is best compared to GNU Auto tools, mind.

  • @gregholloway2656
    @gregholloway2656 2 месяца назад +9

    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. 👍

  • @roysigurdkarlsbakk3842
    @roysigurdkarlsbakk3842 2 месяца назад +5

    Very nice - thanks!

  • @animalshorts4377
    @animalshorts4377 2 месяца назад +7

    Thank you!

  • @mohitsethi3509
    @mohitsethi3509 Месяц назад +1

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

  • @dabdoube92
    @dabdoube92 2 месяца назад

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

  • @bertblankenstein3738
    @bertblankenstein3738 2 месяца назад

    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.

  • @bertblankenstein3738
    @bertblankenstein3738 2 месяца назад +1

    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.

  • @windysynth
    @windysynth Месяц назад

    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!

  • @jonathandawson3091
    @jonathandawson3091 2 месяца назад +1

    Despite having used cmake many times, I learnt a few things. For example I did not even know CMake is for Crossplatform Make. Also the examples for more complicated Makefile were top notch where the interested person could look up or just understand looking at it (e.g. %.o: %.c).
    Absolutely amazing video, always so pleasant to watch Gary's videos.

    • @robby3467
      @robby3467 2 месяца назад +2

      That's mostly how we use it... to create project files for MS Visual Studio when importing an open source library. But it sucks. It does an awful job of it, and that's only with a lot of luck. Mostly it just fails with errors. And as I commented somewhere else, it always fills the source tree with absolute paths. Terrible idea. The documentation is also shocking.

    • @jonathandawson3091
      @jonathandawson3091 2 месяца назад

      @@robby3467 Yeah. CMakeLists.txt name is also weird. I still don't know what PRIVATE does. Things like add dependencies are given after add_executable which is weird.
      I think it grew out of some person who just hacked something quickly to suit his needs.
      I don't think it's the best, but unfortunately it has become standard. Maybe the best way to dethrone it is to go one step up and now make a CMakeLists.txt generator with a saner syntax.

  • @GameBacardi
    @GameBacardi 14 дней назад

    At least this is not one of those confusing tutorials in RUclips when you first time tried to search help of CMake :D

  • @drfrancintosh
    @drfrancintosh 2 месяца назад +1

    wonderful video! I really need an introduction to CMAKE… I do think you glossed over the biggest feature of make and make files… And that is it understands when a file has been touched or modified and only compiles the things it needs to in order to generate the output… It does this by comparing the timestamps on the file modification time… Great video I've been long time subscriber your explainers are the best keep doing what you're doing! And continue to success!

  • @philb1466
    @philb1466 2 месяца назад +1

    As an absolute beginner this video was very useful and informative! Thank you!

  • @RoboticsDIY
    @RoboticsDIY 2 месяца назад

    Thank you, this video is very much appreciated.
    I have some programming background - I learnt Borland Pascal in school and in first course at university... have done a tiny bit of PHP and JavaScript, some small projects on Arduino. But since I moved to work in UK... I have in a way wasted 10 years doing manual labour jobs.
    I want to move back to electronics and programming, I'm slowly working on starting my RUclips channel. I have wanted to learn C/C++ and need it for electronics projects, and especially now with Raspberry, I have to learn how to compile programs from source on Linux.
    So I have heard about GCC, have some rough idea about it all, but this video is a conspectus of how to say - missing peaces to link it all together.

  • @regix1964
    @regix1964 16 дней назад +1

    very useful refresher

  • @interweb3401
    @interweb3401 Месяц назад +1

    Perfect explanation for beginners.

  • @kev2020-z9s
    @kev2020-z9s 2 месяца назад +1

    Thank you for your excellent explanation keep up the great work.

  • @jecelassumpcaojr890
    @jecelassumpcaojr890 2 месяца назад

    A key difference between a build system like make and a shell script is what you illustrated at the end by deleting a few lines from "random.h": make compares the dates of any files it knows how to generate with the dates of the files that depends on and only runs the rules if the generated file is older. A shell script would run all the rules every time. Some viewers might have missed that when you edited "random.h" make ran the rules to generate "random.o" and "main" but not the rule to generate "main.o" since that was newer than "main.c"

  • @sumitkamble_
    @sumitkamble_ Месяц назад

    clean and clear explanation

  • @negart7744
    @negart7744 Месяц назад

    @4:25 thanks for the video ❤
    why don't we have math.o same as other two. Why is it -lm? What makes math lib and random lib different?

    • @GaryExplains
      @GaryExplains  Месяц назад

      Random lib is made by us, math lib is provided by the system.

  • @ezrakoper
    @ezrakoper 2 месяца назад +1

    Thanks. Very useful

  • @Theorist11
    @Theorist11 2 месяца назад

    Thank you well explained
    💌

  • @byronwatkins2565
    @byronwatkins2565 2 месяца назад +2

    How do we organize larger projects? Most projects have trees of directories filled with files and a single config/make sequence to compile them all.

    • @toby9999
      @toby9999 2 месяца назад

      One of the projects I work on has 6000 folders and 90,000 files. There's no way I'd be using a toy-like utility like CMake for that, and we don't.

    • @Colaholiker
      @Colaholiker 2 месяца назад

      The way i do it is to setup directories for everything that makes sense to go together, and then each directory gets its own CMakeLists.txt to build a library out of these files, and the main CMakeLists.txt includes all the directories ti get those files to be active and links the libraries I have created. (I do embedded work, we can't have dynamic/shared libraries, all needs to be statically linked)

  • @manishgautam2424
    @manishgautam2424 2 месяца назад

    loves to see it

  • @NotMarkKnopfler
    @NotMarkKnopfler 2 месяца назад +3

    This is very useful. Is CMAKE installed on Linux by default or do we need to download it? 👍

    • @Colaholiker
      @Colaholiker 2 месяца назад +2

      That likely depends on the distribution you are using. But if it isn't installed yet and you use anything that traces back to Debian, a sudo apt install cmake will fix that for you. I would think that pretty much any modern distribution at least has it available in their repository.

  • @dragonfly-7
    @dragonfly-7 2 месяца назад

    Hey Gary, thanks for your great contribution ! One question: In the video you did mention several times Visual Studio but you did not explicitly mention "Visual Studio Code" or vscode. What about this environment ?

  • @alexwright6038
    @alexwright6038 2 месяца назад

    Thank you, a good starting point for a beginner. I learnt to use Borland Turbo Pascal, that was my language of choice. I mainly work with hardware, I need to get more used to software tools. Do you gave an example of using VS code to program a pi pico in C/c++?

  • @nameless5724
    @nameless5724 2 месяца назад

    Thank You for sharing.

  • @mohsenzare2511
    @mohsenzare2511 2 месяца назад

    Nice video! consider also go to more advance stuff about cmake! like variables or if statement and ...

  • @andrew121410
    @andrew121410 2 месяца назад

    Thank you, I was always confused about the difference between GCC & Make & CMake but this explains everything. I do hope one day C & C++ will get a default package manager like with Java you have maven and gradle so easy to use both.

    • @GaryExplains
      @GaryExplains  2 месяца назад +1

      Glad it was helpful!

    • @toby9999
      @toby9999 2 месяца назад

      I use MS Visual Studio on Windows 99.9999% of the time. It does all of that stuff for you and way more. It even integrates Clang / LLVM for those who don't like MSVC. If you rename a file or add a file, it'll automatically handle that, etc.

  • @tushar8133
    @tushar8133 2 месяца назад

    Excellent!

  • @An.Individual
    @An.Individual 2 месяца назад +2

    How do you get around the fact that we didn't create random.h in the 2nd demo?

    • @GaryExplains
      @GaryExplains  2 месяца назад

      I don't understand. What do you mean?

    • @An.Individual
      @An.Individual 2 месяца назад +2

      @@GaryExplains 2:44 2nd line is
      #include "random.h"
      so the compiler will try to open a file called random.h which we didn't create ?

    • @GaryExplains
      @GaryExplains  2 месяца назад +2

      I did create it, I just didn't show it. It is the same random.h file I show later in the video.

  • @GeorgeMurga
    @GeorgeMurga 21 день назад

    This was great! Thank you so much.

  • @behrampatel4872
    @behrampatel4872 2 месяца назад

    This is such an approachable tutorial. Thank you for Making this ;)
    Edit 01 - This is probably the best C-make for beginners tutorial out there. Full stop. End Edit 01
    I had one question. Just like random.h which needs to be compiled , the Math.h is also a header file. So why did we need to link against that instead of also compiling that header ?
    Thanks,

    • @GaryExplains
      @GaryExplains  2 месяца назад +1

      The functions defined on math.h are not part of the standard C library, so you need to link again libm explicitly. So I am not linking against the header but to the library that has the functions defined in the header.

    • @behrampatel4872
      @behrampatel4872 2 месяца назад

      @@GaryExplains got it. Thanks for the clarification.
      Just FYI i'm here because I want to integrate a plugin for Unreal Engine . Specifically to integrate a recent version of OpenCV.
      All documentation & videos on the topic are years old so it's become difficult.
      So this kind of knowledge (building from source, DLL etc ) is very essential.
      Thanks and god speed.

  • @grimvian
    @grimvian Месяц назад

    Interesting but with my clumsy fingers and weird dyslectic issues I'm using an IDE with all the settings I need. I never understood why many prefer to write instead of clicking on a button.
    I'm also using pragma once.

  • @gurusunu1105
    @gurusunu1105 2 месяца назад

    Thanks 👍

  • @andrewgrant788
    @andrewgrant788 2 месяца назад +1

    Ninja is the way to go with CMake. It works on Windows and MacOS as well as Linux.

  • @karolkotula9279
    @karolkotula9279 Месяц назад

    Thanks Gary for great tutorial :)
    Small contribution from myself:
    if you want to use cmake for your Visual Studio compiler, then:
    1. cmake in your build_vs subdirectory, with command:
    cmake -G "Visual Studio 17 2022" ..
    2. build created solution with msbuild:
    MSBuild.exe hellow.sln -p:Configuration=Release

  • @BobBeatski71
    @BobBeatski71 14 дней назад

    @5:32 those two lists look the same.

    • @GaryExplains
      @GaryExplains  14 дней назад +1

      They are the same. Most random number generators are pseudo random which means they generate the exact same sequence until the "seed" is changed. A common seed is the current time as it is always changing.

    • @BobBeatski71
      @BobBeatski71 14 дней назад +1

      @@GaryExplains Ah ha. I understand. Also wanted to say I found the video very helpful as I'm trying out Fortran openMP techniques (with and without debug) and the project is CMAKE based.

  • @henrikoldcorn
    @henrikoldcorn 2 месяца назад

    This video seems to be approaching optimum for explaining these tools! Good length, depth and clarity, like a glass dild…
    Seriously though, it’s great.

  • @mahmoud1737
    @mahmoud1737 Месяц назад

    what about zig and opinion on as a c compiler drop in replacement

  • @cdkslakkend5742
    @cdkslakkend5742 2 месяца назад

    You see, this is what makes Linux interesting as opposed to the other OS's and their tools. At least, you can then go to another level and start looking at other types of source files that make up smaller linux programs and learn how the build process proceeds so that installing from source has a more meaningful impact in terms of comprehension.

    • @GaryExplains
      @GaryExplains  2 месяца назад

      I get your point and I agree, but technically it isn't Linux that makes this possible, but open source in general. For example, you can look at and compile and install htop on macOS or FreeBSD.

  • @grahamm7408
    @grahamm7408 2 месяца назад +1

    Awesome intro! Next stop, the Linux kernel 😅

  • @guilherme5094
    @guilherme5094 2 месяца назад

    👍👍Thanks sir!

  • @abiuniverse
    @abiuniverse 2 месяца назад

    Does it also work with Fortran

  • @svenvandevelde1
    @svenvandevelde1 2 месяца назад

    Thank you

  • @harrypehkonen
    @harrypehkonen 2 месяца назад

    This morning, I bumped into CMake and started looking into learning enough about it to be able to use it, but then I was distracted by the build system for Zig.

  • @WiLDbEAsTGameSHere
    @WiLDbEAsTGameSHere 11 дней назад

    are you using git bash or anything else like unix

    • @GaryExplains
      @GaryExplains  11 дней назад +1

      Linux, as I say at 02:20

    • @WiLDbEAsTGameSHere
      @WiLDbEAsTGameSHere 11 дней назад +1

      @GaryExplains oh sorry for not getting it before

    • @GaryExplains
      @GaryExplains  11 дней назад +1

      Hey, no problem! It sounds like CMake, GCC, and all that are new to you - that's totally fine. Let me know if you have any questions about the video at all. 👍

    • @WiLDbEAsTGameSHere
      @WiLDbEAsTGameSHere 11 дней назад +1

      @@GaryExplains the video itself was sufficient for me , i learned everything i needed to start a new project thanks to you man , appreciate your efforts

  • @negart7744
    @negart7744 Месяц назад

    Thanks for tge video. I wanna use cmake for cmocka.

  • @simonbooth4888
    @simonbooth4888 2 месяца назад

    No external library linking explanation which is the most confusing bit when using third patry add-ons. i.e. need a follow up

    • @GaryExplains
      @GaryExplains  2 месяца назад

      External library like libm?

    • @simonbooth4888
      @simonbooth4888 2 месяца назад +1

      @@GaryExplains External libraries like display drivers on a pico

    • @talideon
      @talideon Месяц назад

      ​@@simonbooth4888That's a matter of how those third party libraries are installed as part of the project. If the complier doesn't need -I and -L to find the headers and library binaries, it's no different from linking to libm. If they provide pkg-config files, there's find_package(PkgConfig), which gives you the pkg_check_modules(...) command to discover the paths and compile flags. If cmake knows about the library in question, it has other ways (I'm typing on a phone, so can't recall the commands off the top of my head). If it's a vendored library, then your root CMakeLists.txt should pull in the vendored library as another target. Dealing with vendored libraries is really something that would be covered as part of a video on project organisation, though.

    • @talideon
      @talideon Месяц назад

      If you want a more in depth explanation, "Modern CMake with C++" is a good choice.

  • @fuzzyheadedfreak
    @fuzzyheadedfreak Месяц назад

    Why numbers not random?

    • @GaryExplains
      @GaryExplains  Месяц назад

      It is a pseudo random number generator. All pseudo random number generators create the same sequence until the "seed" is changed.

    • @fuzzyheadedfreak
      @fuzzyheadedfreak Месяц назад

      @@GaryExplains Groovy, thanks.

  • @4k1ra-f9y
    @4k1ra-f9y 2 месяца назад

    I'm so confused how cmake work on raspberry pi pico

    • @h_pranav_nayak
      @h_pranav_nayak 2 месяца назад

      It doesn't "work" on the pico
      You cross compile code on your PC and then flash the binaries on the pico

    • @4k1ra-f9y
      @4k1ra-f9y 2 месяца назад

      @@h_pranav_nayak its working when I trying flash the led, but I'm so confused how to setup cmakelist.txt for my environment, actually i want someone teaching how cmakelist.txt work on raspberry pi pico, how to setup the directory, i have many of problem how to setup the lib on cmakelist...I ready done to add lib on cmakelist code, but when try to running, the error showing "lib not found", and i try search use "locate lib" it shows the existence of the library

  • @mikechappell4156
    @mikechappell4156 2 месяца назад

    What was random.h? You included it, but never showed it.

    • @GaryExplains
      @GaryExplains  2 месяца назад

      I do show it, but later in the video when I demonstrate what the build system does when you change a files it is just a declaration for the random function. 1 line of code.

    • @mikechappell4156
      @mikechappell4156 2 месяца назад

      @@GaryExplains Thanks. I saw when I finished the video. I just initially got the compile error for the missing file, but it was easy enough to dummy something in until you exposed it.

  • @Xenthera
    @Xenthera 2 месяца назад

    Nice Rush video length

  • @michelealessandrini3421
    @michelealessandrini3421 2 месяца назад

    Can you possibly cram more ads in your videos?

    • @GaryExplains
      @GaryExplains  2 месяца назад

      Eh? I don't cram in the ads, Google does that and it is automatic. Yes, I enable ads, but after that it is all Google, not me.

    • @michelealessandrini3421
      @michelealessandrini3421 2 месяца назад

      @@GaryExplains I had to see a dozen ads in a 20 min video, stopping every couple of minutes, ok that you deserve a revenue for your work, but over a certain limit I'm no longer motivated in following a youtuber.

    • @GaryExplains
      @GaryExplains  2 месяца назад

      I understand. But as I said it is Google that picks how many ads are shown and where. Not me. Remember that Google gets a much larger fraction of the advert revenue than the video creator. Your beef is with Google, not me.

  • @BangkokBubonaglia
    @BangkokBubonaglia 2 месяца назад +1

    Thanks for this series Gary. A request. Please do a video on how to control all the make flags using cmake. For instance, I hate that cmake always hides the real gcc compile commands. I absolutely loathe that. I want to see the 1000 character long actual gcc commands as they are executed. How do I force cmake NOT to hide that?. It builds this complex structure of hierarchical Makefiles, and I never know how any code is actually being built. The options to cmake are where all the utility lies. As someone who grew up on make, it is incredibly frustrating not to be able to see what is happening when I compile a project.

    • @Colaholiker
      @Colaholiker 2 месяца назад +1

      There is an option to control CMake's verbosity (and of course the verbosity of the output it produces. I don't remember what it is, as I only tried it once and didn't really see the benefit over a mostly silent build that only shows warnings and errors (or in my usual project setup only errors since I treat warnings as errors and set my compiler to nag a lot). I found it easily when I googled for it. So if you prefer to see tons of text scroll by, CMake has got you covered. 😉 I am not saying that either of the two is better, I think this is mostly a matter of personal preference.

  • @mohitsethi-w7k
    @mohitsethi-w7k Месяц назад

    FOLKS THIS IS THE VIDEO, DONT GO SEARCHING ANYMORE.

  • @tushar8133
    @tushar8133 2 месяца назад

    fatal error: 'random.h' file not found
    I have main.c and random.c in the directory
    Ether I run this command - gcc -c main.c
    Or this command - gcc -o main main.c random.c -lm
    Both are giving same error.

    • @GaryExplains
      @GaryExplains  2 месяца назад

      You need random.h as well. I show it at one point in the video. It is just a header for that random function.

  • @JamesTJoseph
    @JamesTJoseph 2 месяца назад

    The best book to learn CMake is “Professional CMake by Craig Scott”.

    • @robby3467
      @robby3467 2 месяца назад

      "Professional" and "CMake" should never go together is one sentence :)

    • @JamesTJoseph
      @JamesTJoseph 2 месяца назад

      @@robby3467 apparently it is the best book with free new editions 😌

    • @talideon
      @talideon Месяц назад

      ​@@robby3467Better than Autotools hell though, however bad the CMake language itself is. I'd use Meson for builds if I could, if only because it's less crufty.

  • @fdfgsa
    @fdfgsa 2 месяца назад +1

    CMake is one of the reasons I now use Rust

    • @robby3467
      @robby3467 2 месяца назад

      CMake sucks, right? We found it always filled the source tree with absolute paths. There should be a way to create relative paths but could never find anything that worked.

  • @irlshrek
    @irlshrek 2 месяца назад +1

    I went Rust and never looked back

    • @robby3467
      @robby3467 2 месяца назад +2

      I tried Rust and I did look back.

  • @toby9999
    @toby9999 2 месяца назад +7

    Sorry to be so blunt, but CMake is an absolute piece of garbage (in my opinion). I've spent too many hours, if not days, tearing my hair out or turning it grey, trying to beat CMake into submission. Worst piece of build tooling I've had the misfortune of meeting in over 25 years of software development. It never works out of the box. It's a piece of crap. Even watching this video... I feel the stress. Sorry, but I just had to vent. Is this really the best the open source community can do? It's still an archaic process. This is 2024.
    That said, you provided a nice overview.

    • @andrewgrant788
      @andrewgrant788 2 месяца назад

      Don’t agree at all. CMake is an excellent build tool compared to alternatives like GNU autotools. The CMake team works with the major C++ compiler teams and Microsoft’s cross platform tools in Visual Studio rely on CMake. They also have a package manager vcpkg which integrates with CMake. That said, in my view the best IDE for working with CMake is CLion from JetBrains. If you wish to avoid hair loss it is the best option, the integrated CMake debugger is excellent.

    • @var67
      @var67 2 месяца назад +1

      What's the alternative, do you use Meson? Can you give a specific example where Meson, or another system, works better for you than Cmake? (I have no experience with Meson and not much with Cmake.)

    • @arkeynserhayn8370
      @arkeynserhayn8370 2 месяца назад

      Can you please provide reasons of why you think this way?
      For one i see people complain about it's scripting sytanx, and even while its true, it's not a huge deal for me; what else do you think is wrong with cmake?

    • @talideon
      @talideon Месяц назад

      You haven't been subjected to the hell that is GNU Autotools, then?

  • @weiSane
    @weiSane 2 месяца назад +3

    Cmake is such a pathetic messy build tool. No wonder a lot of beginners get overwhelmed when trying to learn C++ and they just go for much more newer better fleshed out languages with far much better build tools.
    We have to be thankful though because the languages that came after learned from mistakes made by the earlier ones.

  • @jussiheino
    @jussiheino 2 месяца назад

    I will unsubscribe if you don't change the "demo"-intermission jingle! I would be deaf if wearing headphones. Super loud on my laptop speakers. Otherwise, good cover of basics! liked!

  • @briman113
    @briman113 2 месяца назад +2

    🙏👍

  • @hakkysnak7021
    @hakkysnak7021 7 дней назад

    Great explanation. Thank you