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

Поділитися
Вставка
  • Опубліковано 19 гру 2024

КОМЕНТАРІ • 151

  • @vatsalpandya5415
    @vatsalpandya5415 Місяць тому +17

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

  • @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.

  • @cabji
    @cabji 19 днів тому +4

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

  • @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.

  • @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!

  • @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`.

  • @frankleonhardt3337
    @frankleonhardt3337 Місяць тому +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.

  • @mohitsethi3509
    @mohitsethi3509 Місяць тому +1

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

  • @ElectronicFanArm
    @ElectronicFanArm 2 місяці тому +10

    Loved this thanks Gary for sharing ❤

  • @GameBacardi
    @GameBacardi 10 днів тому

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

  • @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.

  • @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!

  • @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.

  • @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.

  • @roysigurdkarlsbakk3842
    @roysigurdkarlsbakk3842 2 місяці тому +5

    Very nice - thanks!

  • @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!

  • @OmidAtaollahi
    @OmidAtaollahi 2 місяці тому +1

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

  • @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 UA-cam 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.

  • @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.

  • @dabdoube92
    @dabdoube92 2 місяці тому

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

  • @interweb3401
    @interweb3401 Місяць тому +1

    Perfect explanation for beginners.

  • @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.

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

  • @philb1466
    @philb1466 2 місяці тому +1

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

  • @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?

  • @kev2020-z9s
    @kev2020-z9s 2 місяці тому +1

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

  • @regix1964
    @regix1964 12 днів тому +1

    very useful refresher

  • @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"

  • @animalshorts4377
    @animalshorts4377 2 місяці тому +7

    Thank you!

  • @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.

  • @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)

  • @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

  • @Theorist11
    @Theorist11 2 місяці тому

    Thank you well explained
    💌

  • @ezrakoper
    @ezrakoper 2 місяці тому +1

    Thanks. Very useful

  • @sumitkamble_
    @sumitkamble_ Місяць тому

    clean and clear explanation

  • @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.

  • @GeorgeMurga
    @GeorgeMurga 16 днів тому

    This was great! Thank you so much.

  • @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.

  • @mohsenzare2511
    @mohsenzare2511 Місяць тому

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

  • @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.

  • @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.

  • @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.

  • @andrewgrant788
    @andrewgrant788 2 місяці тому +1

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

  • @grahamm7408
    @grahamm7408 2 місяці тому +1

    Awesome intro! Next stop, the Linux kernel 😅

  • @BobBeatski71
    @BobBeatski71 10 днів тому

    @5:32 those two lists look the same.

    • @GaryExplains
      @GaryExplains  9 днів тому +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 9 днів тому +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.

  • @nameless5724
    @nameless5724 2 місяці тому

    Thank You for sharing.

  • @tushar8133
    @tushar8133 2 місяці тому

    Excellent!

  • @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.

  • @mahmoud1737
    @mahmoud1737 Місяць тому

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

  • @manishgautam2424
    @manishgautam2424 2 місяці тому

    loves to see it

  • @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++?

  • @negart7744
    @negart7744 Місяць тому

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

  • @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.

  • @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 ?

  • @Xenthera
    @Xenthera 2 місяці тому

    Nice Rush video length

  • @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.

  • @abiuniverse
    @abiuniverse 2 місяці тому

    Does it also work with Fortran

  • @WiLDbEAsTGameSHere
    @WiLDbEAsTGameSHere 6 днів тому

    are you using git bash or anything else like unix

    • @GaryExplains
      @GaryExplains  6 днів тому +1

      Linux, as I say at 02:20

    • @WiLDbEAsTGameSHere
      @WiLDbEAsTGameSHere 6 днів тому +1

      @GaryExplains oh sorry for not getting it before

    • @GaryExplains
      @GaryExplains  6 днів тому +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 6 днів тому +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

  • @gurusunu1105
    @gurusunu1105 2 місяці тому

    Thanks 👍

  • @guilherme5094
    @guilherme5094 2 місяці тому

    👍👍Thanks sir!

  • @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.

  • @svenvandevelde1
    @svenvandevelde1 2 місяці тому

    Thank you

  • @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

  • @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.

  • @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.

  • @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.

  • @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.

  • @irlshrek
    @irlshrek 2 місяці тому +1

    I went Rust and never looked back

    • @robby3467
      @robby3467 2 місяці тому +2

      I tried Rust and I did look back.

  • @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.

  • @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.

  • @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!

  • @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.

  • @briman113
    @briman113 2 місяці тому +2

    🙏👍

  • @hakkysnak7021
    @hakkysnak7021 2 дні тому

    Great explanation. Thank you