How to CMake Good - 1a - A "Hello, world" executable

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody and welcome to how to see make good part 1a that's right we've advanced from 0 to 1 because we're actually gonna do something that resembles real work this time and to do that I've created an empty directory and I've opened it up in vs code so there's no files here but we're gonna make a simple C make project with just a single HelloWorld executable make a new file I'll call it C make lists dot txt I will start with the C make minimum required declare my version to be 3.12 which is the latest at the making of this video I'm going to declare a project call it my project let's say it's version is no say it's a version is one dot o dot o and add executable program I'll call it I'll call it C make good and a main dot CPP now I'll open a terminal window I'll make a field directory I'll go into the build directory and I'll say C make dot there it goes and it gives me an error because I've added this executable here on line 4 that references main dot CPP but that file is not in here now when you specify a path to a file in add executable or add library or Target sources that is going to be relative to the directory where the target was created so for addicts cubile we're making that target in the root of the project so main dot CPP is going to look for it relative to the root of the project so let's add a main dot CPP I'll include iostream make a main function and hello world just like that I'll go back to my terminal I'll run CMake again now to run C McHugh can pass the path to the source directory or you could pass the path to an already configured binary directory and that's what I prefer because it's just a one less character and I'm very lazy and you can see it configured without any trouble I'm going to actually delete the configuration just so we can see it run all the way through again so first C make detects our compiler for C that detects our C++ compiler which seem it calls CX x because plus plus can create some parsing errors in some cases so it calls it C X X as using clang plus plus four CX X and playing for see it says configuring done generating done then it says the build files have been written to this path which is the build directory I've created over here and they can see my files it's created a make file so I can type make or a very general way you can run a C Mac build without having the note to know what kind of build system is underneath just C make - - build and then the directory where it lives like that and it ran the build it it launched make first of all to run the build but we didn't have to know that it was using make so this is good if you're configuring a project but you may or may not know what generator it's using just say C make - - build and then the path to the build directory and you don't have to run this command from the build directory you can run it from anywhere - say - - build and then the path to where the C make cache is and it will run the build for you so we can see it's created executable called seemed a good built target seemed a good and over here we can see there's the executable in the build directory I'm going to run that and we should see our hello world and that was the basics the very very bare-bones basics of using see make to create a simple hello world program there's a lot of subtleties that have happened here that will hopefully be getting into in later installments part 1 ABC and so on will all be very basic but I hope to get into a lot more greater detail about what's going on when you do this in part 2 3 and on but until then check the video description for any addendums errata or important links and I'll see you in the next one
Info
Channel: vector-of-bool
Views: 55,471
Rating: 4.929348 out of 5
Keywords: cmake, programming, tutorial
Id: V1YP7eJHDJE
Channel Id: undefined
Length: 5min 4sec (304 seconds)
Published: Sun Aug 12 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.