Subtitles section Play video
Hi, and welcome to a screencast on CMake support in CLion. Now, CMake is
central to CLion's operations
so when you make a new project, or when you open an existing project, you're
going to be working
with CMake build scripts. Now when you
import something from sources, you can import a set of files that has nothing
to do with CMake per se and, in this case,
CLion will simply generate the CMakeLists file for you
but here we're going to make a new project. I'll make this one "Hello CMake"
and we'll take a look at how CMake support is actually
implemented
so here is our generated project and you'll notice that
all the definitions related to this project are in a file called
CMakeLists
so that's the project file that CMake will be using to build the application
and CLion itself is using to figure out what's what
in the project itself; so as soon as you make any changes
CLion is going to attempt to reload those changes, so for example let me
comment out this line here. As soon as I do that
CLion is telling me that the CMake project needs to be reloaded and there
are two options here: one is to press the link to reload the changes
or I can enable auto-reloading which means that
anytime I change the CMakeLists file, CLion
is going to reload the project. Now, CLion, as I mentioned, it takes all the
information about the project from the CMakeLists file, so it figures out
what files make up the application;
it takes the target name,
it takes variable values, compiler options and so on.
And so operations in CLion quite often involve changes to the CMakeLists
file so, for example, if I were to
add a new class [let's call it Example] you'll see that
there is an option here too added to the targets. And as soon
as I press OK here, if we go back into CMakeLists, you can see that both the
header
and the CPP have been added to this CMakeLists file
Now, of course, in addition to manipulating CMakeLists filed by
having new classes for example you can simply and it'd manually
so for instance I can
an instruction to find a package in let's take a look at how this works so
that suppose
i right find package notice I get code completion here I can simply press
return at this point but I have provided a parameter
so what happens is céline tries to fire up see make
and look for potential problems with the sea make lists file
and indeed had reports and there it tells me that fine package is called
within
incorrect number of arguments so if I were to provide a bogus
argument like asdf for example then once again
see make doesn't reload and now we get a warning that there is no find a SPF 30
me
so that's finally put something sensible in here and in a similar fashion
céline provides code completion for the file name so let me simply comment out
the fires here
and that suppose I want to add example to the source file
soon as I start typing notice I get code completion for example dot CPP an
example that age so I can simply
press return here and since we collected to order reload the changes
those changes get automatically updated without any
involvement from me personally so we looked at the scene make
aris in the appropriate when there let's take a look at once again
in the tests are being up see make so there are no problems right now but
let's talk about some
of the buttons that are available here suffer stubble the scenic settings
now the four-week even jump in to see make let's talk about the two chain n
hear things are fairly simple because he lie in tax the bundles
a version ups he makes so you don't have to install one
unless there is a specific question that you want in which case you can take the
you specified
and simply provide a path for that version will
go with the one that's provided for us by céline and noticed that there is
a said of indicators here telling you whether or not
the settings you've got a correct so that's the to change in terms of C make
but let's get back into the sea make setting so here's our setting for
automatically reloading the project on any kind of changes
in addition it's possible to provide see make options
so here for example I can type dashed d and then simply rightfully cause bar to
provide a property
we are also electing to pass system environment variables and there is a
hyperlink air to
show you what those environment variables actually are and in it she you
can specify
additional properties but once again typing the name here
and some value in here so in addition to that you can specify the build-up in so
for example specifying how many course you want
your application to be compiled on and you can also specify the build
output path and this can be either absolute or relative
for example I can specified a folder called bill that would be relative
to my project would so let's press okay here and we've incorporated some setting
so now see makers going to
make you serve the San notice we get a small warning here that that setting for
that we specified isn't actually being used for anything
now in addition to this setting there is another setting here call change project
to attend to explain how it works let me give you an example where
all of our project files are inside some folder deeper
in our project structure so what I'm going to do is I'm going to make
in your territory let's call it example and let's suppose
that although our files are in fact in that territory so I'll put them
here now imagine what would happen
if we open the project right now so let me close
céline close the project humble open it once again but this time
I'm going to open it from that territory where I put it
so I'm taking the project from the example folder and
as I press hello well as you can imagine they end up having
that exact folder has my rude however
what would happen if I wanted to work with the previous poll to the one that I
had previously shown
in this case what I can go in to see make and I can choose an option to
change the project root
now what I can do is I can move upper-level
and choosing the higher-level folder as the rude can press OK here
and that is the structure in the project view has changed we now have the example
for your being a subfolder other higher hello see make folder
so in addition to the problems we know we also have the
capture window and this is where you can edit the sea make cash so once again you
can
go into a particular property you can specify a setting like
changing something from onto of and don't forget to press the Save button to
incorporate the settings
finally let's talk about bill targets so essentially in RC make lists far we have
a single
excutive ok I'll tell a/c make so if you go into the configurations for TSI line
has inferred from the sea make this file
you will see that there is in fact a Hello see make target here
but there is also a build all target
which incorporates all the targets inside you see make lists while
and these are some other ways in which céline supports working with C make
tough to find
more about céline go to egypt brings the comp slashed céline
thanks for watching