Hello! My name is Vladyslav Batyrenko, I’m a student living in Kyiv, Ukraine.
This is my first GSoC blog post about my participating in Ark project.
In this post I would like to tell you how I managed to set up my environment
for coding with CLion, utilizing it not only as an editor but also as a
debugging tool. You may think that’s a trivial task almost every IDE can handle -
and this is true, but until your project requires a non-trivial deployment
process before it is able to start. So if you want to know how to build,
deploy and run/debug your executable with pressing only
you may find this post useful.
This was a thorny way with doing a lot of workarounds…
CLion is an IDE from JetBrains, it has a very rich set of features. You can easily get it from its official site. Here I’ll use Ark project I’ll be working on as an example for setting up CLion.
git clone git://anongit.kde.org/ark
Ark uses CMake for building and it’s a fortune because so does CLion.
After opening the project in the IDE and trying to run it
(Run -> Run) or
(SHIFT+F10) you must get “Unable to find Ark’s KPart
component, please check your installation.” error. That’s it. We’ll want
make install for built project and to run installed executable.
For accomplishing this task CLion provides us with
External tool functionality.
After spending much time on researching, how exactly I can make CLion run installed executable I came up with the following solution… If someone has another ideas please feel free to share them, that’s only how I myself managed to workaround the situation.
Setting up the project in CLion
External tool allows us to run a custom bash script before/after build step.
Firstly, I though, I needed to somehow make CMake communicate with
my bash script in order to get my script to know where the build directory is.
CLion generates random path (for our perception) for its CMake binary dir…
I had, for instance,
So I’ve ended up with adding to Ark target’s CMakeList.txt file the following lines:
After each build command this will create the file called “cmake_binary_dir” with a path to CMAKE_BINARY_DIR.
Secondly, I had to set the environmental variables for building and running processes. On Ark page in KDE Community Wiki it is stated that we have to set these variables:
Alright, said - done. We have to go to both CLion CMake options
(File -> Settings (CTRL+ALT+S) -> Build, Execution, Deployment -> CMake)
and target’s build options
(Run -> Edit Configurations...) (ALT+SHIFT+F10 and then press 0),
where we’ll set them.
Be aware! CLion, unfortunately, doesn’t allow to use bash variables here,
so you won’t be able to write something like “/custom/folder/bin:$PATH”.
So check you variables from terminal with
echo $VARIABLE and paste needed
Correct me if it is/will be wrong, I’ll become happy.
Finally, we can add our bash script. Don’t leave target’s build options. At the bottom you’ll see the pane, which contains “Build” command running before launch. Here we can add our external tool, which will be a bash script.
(On the screenshot you may see a little difference, I just pressed edit
buttons in order to show you my existing External Tool, while you’ll
have to add your own.)
And there are the contents of the script:
P.S. Remember to replace the according strings with your install path.
Now we can start our happy debuggin! :)
Set your break points, then just press
ALT+SHIFT+F9, select Ark target
(later you can just use
SHIFT+F9) and enjoy! I hope everything will
work on your local machines.
If you have any problems, questions, marks, feel free to comment this post.