Get Involved/development/IDE configuration/CLion: Difference between revisions

From KDE Community Wiki
(Add link to the description of variables for debugging)
(Suggest to save cmake options to file, colorize)
Line 15: Line 15:
[[File:Clion build configuration.png|border|700px|build configuration]]
[[File:Clion build configuration.png|border|700px|build configuration]]


Under CMake options, we must set some important variables such as CMAKE_PREFIX_PATH. If the prefix was in "/home/username/kde", then the CMake options line would look like:
In this same window, under CMake options, we must set some important variables such as CMAKE_PREFIX_PATH. If the prefix was in "/home/username/kde", then the CMake options line would look like:


{{Input|1=<nowiki>
<syntaxhighlight lang="ini">
-DCMAKE_PREFIX_PATH=/home/username/kde/usr
-DCMAKE_PREFIX_PATH=/home/username/kde/usr
-DCMAKE_MODULE_PATH=/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
-DCMAKE_MODULE_PATH=/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
-DQT_PLUGIN_PATH=/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
-DQT_PLUGIN_PATH=/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
-DXDG_DATA_DIRS=/home/username/kde/usr/share
-DXDG_DATA_DIRS=/home/username/kde/usr/share
</nowiki>}}
</syntaxhighlight>


You probably would want to save that to file `~/kde/clion_cmake_options.txt` for future use.
Press OK.
Press OK.



Revision as of 16:11, 29 August 2023

CLion is a proprietary IDE for C++.

Install CLion

On Arch Linux install the clion.

Setup

Open a new project in CLion. Locate it to the folder with CMakeLists.txt. It will ask how do you want to open the project. Select CMake project.

open as cmake project

In CMake configuration, choose Debug build. In the Generator, set "Let Cmake decide". In the Build directory, insert the build directory path, for example, "/home/username/kde/build/dolphin".

build configuration

In this same window, under CMake options, we must set some important variables such as CMAKE_PREFIX_PATH. If the prefix was in "/home/username/kde", then the CMake options line would look like:

-DCMAKE_PREFIX_PATH=/home/username/kde/usr
-DCMAKE_MODULE_PATH=/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
-DQT_PLUGIN_PATH=/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
-DXDG_DATA_DIRS=/home/username/kde/usr/share

You probably would want to save that to file `~/kde/clion_cmake_options.txt` for future use. Press OK.

In the run/debug target (in the upper right corner of main window), select "dolphin".

select run debug configuration

Expand it and choose Edit.

go to run debug configuration edit

The Run/Debug Configurations window will appear. In the Environment variables field click edit button.

run debug configuration

Add variables, that you can find in build directory, for example, in "/home/username/kde/build/dolphin/prefix.sh".

run debug configuration add variables

Note: if you want to modify debugging output messages, you can add corresponding variables here. See Guidelines and HOWTOs/Debugging/Using Error Messages#Controlling_Messages.

In the Toolchains you can use bundled cmake and gdb. In Arch Linux their versions are very recent and not yet supported by CLion. They can be installed with clion-cmake and clion-gdb.

use bundled cmake and gdb

Tips and Tricks

Out of tree breakpoints

You may want the debugger to stop on a specific breakpoint, that is located out of project tree. For example, you run and debug dolphin project: select several files, with context menu you add them to archive. And you want the debugger to stop on some function of Ark's code.

For this, you just open the corresponding file, and put a breakpoint there. No even need to map sources, like you need in Qt Creator.