Get Involved/development/IDE configuration/CLion: Difference between revisions
m (Link to the CLion homepage) |
(Use headers, use formatting) |
||
Line 9: | Line 9: | ||
If using Arch Linux, you can install the AUR package [https://aur.archlinux.org/packages/clion clion]. | If using Arch Linux, you can install the AUR package [https://aur.archlinux.org/packages/clion clion]. | ||
== | == Setup a KDE project in CLion == | ||
In this article we will use ''dolphin'' as an example project. Prerequisite is that you have successfully built a project following kdesrc-build setup procedure. This article assumes your username is {{ic|username}}, and the kdesrc-build setup path is {{ic|/home/username/kde/}}. Replace them to the your values in the specified commands. | |||
=== Importing project === | |||
In the "Welcome to Clion" window press "Open" button. In the "Open File or Project", chose a root folder of ''dolphin'' project ({{ic|~/kde/src/dolphin}}) or select the {{ic|CMakeLists.txt}} file in that directory. It will ask how do you want to open it. Press "Open as Project" for file, or "Open as CMake project" for directory. | |||
[[File:Clion open as cmake project.png|frameless|300px|open as cmake project]] | |||
=== CMake profile === | |||
After previous step, the new window will open to setup cmake profile. You can reach these settings later by going to '''Settings | Build, Execution, Deployment | CMake'''. Choose ''Debug'' build. In the ''Generator'', set "Let Cmake decide". In the ''Build directory'', specify the build directory path, for this example it will be {{ic|/home/username/kde/build/dolphin}}. | |||
[[File:Clion build configuration.png|frameless|700px|build configuration]] | [[File:Clion build configuration.png|frameless|700px|build configuration]] | ||
Line 125: | Line 37: | ||
Press OK. | Press OK. | ||
=== Run/Debug Configuration === | |||
In the run/debug target (in the upper right corner of main window), select "dolphin". | In the run/debug target (in the upper right corner of main window), select "dolphin". | ||
Line 144: | Line 58: | ||
Note: if you want to modify debugging output messages, you can add corresponding variables there. See [[Guidelines and HOWTOs/Debugging/Using Error Messages#Controlling_Messages]]. | Note: if you want to modify debugging output messages, you can add corresponding variables there. See [[Guidelines and HOWTOs/Debugging/Using Error Messages#Controlling_Messages]]. | ||
==== Variants to setup environment variables ==== | |||
[[File:Clion run environment variables.png|frameless|400px|run debug variables configuration]] | [[File:Clion run environment variables.png|frameless|400px|run debug variables configuration]] | ||
=== Reusing existing prefix.sh === | ===== Reusing existing prefix.sh ===== | ||
For convenience, copy the <code>/home/username/kde/build/dolphin/prefix.sh</code> to <code>/home/username/kde/clion_run_environment.sh</code>. [https://www.jetbrains.com/help/clion/2023.2/run-debug-configuration.html#envvars-progargs Use] the following syntax for setting variables in that script: <code>export VAR=value</code>. | For convenience, copy the <code>/home/username/kde/build/dolphin/prefix.sh</code> to <code>/home/username/kde/clion_run_environment.sh</code>. [https://www.jetbrains.com/help/clion/2023.2/run-debug-configuration.html#envvars-progargs Use] the following syntax for setting variables in that script: <code>export VAR=value</code>. | ||
Line 152: | Line 67: | ||
In the Environment Variables dialog, in the Load Variables from file field, paste the path <code>/home/username/kde/clion_run_environment.sh</code>. | In the Environment Variables dialog, in the Load Variables from file field, paste the path <code>/home/username/kde/clion_run_environment.sh</code>. | ||
=== Setting variables manually === | ===== Setting variables manually ===== | ||
Translate the content of the file <code>~/kde/build/dolphin/prefix.sh</code> to the variables list that you can paste to CLion. E.g. if <code>~/kde/build/dolphin/prefix.sh</code> is like: | Translate the content of the file <code>~/kde/build/dolphin/prefix.sh</code> to the variables list that you can paste to CLion. E.g. if <code>~/kde/build/dolphin/prefix.sh</code> is like: | ||
Line 205: | Line 120: | ||
Press OK button. | Press OK button. | ||
== Additional notes == | |||
{{Construction|Notes need reworking}} | |||
Note that I tell kdesrc-build to use the CMake generator "Unix Makefiles" by commenting out the line <code>cmake-generator</code> from the kdesrc-buildrc configuration file. I also need to configure kdesrc-build to use the CMake build configuration "Debug" in order to be able to use the debugger in the IDE, and I use more than 4 CPU threads. For more details see the wiki page for the IDE [[Get_Involved/development/IDE_configuration/Qt_Creator|QtCreator]]. | |||
<pre> | |||
cmake-options -DCMAKE_BUILD_TYPE=Debug | |||
... | |||
num-cores 14 | |||
... | |||
#cmake-generator Kate - Ninja | |||
</pre> | |||
Build a KDE project e.g. | |||
<pre> | |||
kdesrc-build kcalc --debug | |||
</pre> | |||
Look at the output, write down the part similar to: | |||
{{bc|1= | |||
Running cmake targeting Unix Makefiles... | |||
cd /home/username/kde/build/kcalc | |||
run_logged_command(): Module kcalc, Command: cmake -B . -S /home/username/kde/src/kcalc -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr -DCMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64 | |||
Setting environment variable {{color|green|XDG_DATA_DIRS}} to {{color|lime|/home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop}} | |||
Setting environment variable {{color|green|PATH}} to {{color|lime|/home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin}} | |||
Setting environment variable {{color|green|CMAKE_MODULE_PATH}} to {{color|lime|/home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake}} | |||
Setting environment variable {{color|green|PKG_CONFIG_PATH}} to {{color|lime|/home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig}} | |||
Setting environment variable {{color|green|LD_LIBRARY_PATH}} to {{color|lime|/home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib}} | |||
Setting environment variable CMAKE_PREFIX_PATH to {{color|lime|/home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr}} | |||
Setting environment variable {{color|green|QT_PLUGIN_PATH}} to {{color|lime|/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins}} | |||
}} | |||
In the "Welcome to CLion" wizard > "Open" > "/home/username/kde/src/kcalc/CMakeLists.txt" > OK. The dialog "Open Project CMakeLists.txt is a project file. Would you like to open the project?" is shown, select "Open as Project". Enable check box "Trust projects in ~/kde/src" > "Trust Project" button. In the "Open Project Wizard" dialog select "OK". | |||
Look at the the part that you have written down from the output of <code>kdesrc-build kcalc --debug</code>. | |||
In Settings > Build, Execution, Deployment select the "Debug" CMake "Profile". "Generator:" "Let CMake decide", "Build directory:" "/home/username/kde/build/kcalc". | |||
CMake options: | |||
<pre> | |||
-G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr -DCMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64 | |||
</pre> | |||
Convert using a text editor and text replace: | |||
<pre> | |||
Setting environment variable XDG_DATA_DIRS to /home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop | |||
Setting environment variable PATH to /home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin | |||
Setting environment variable CMAKE_MODULE_PATH to /home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake | |||
Setting environment variable PKG_CONFIG_PATH to /home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig | |||
Setting environment variable LD_LIBRARY_PATH to /home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib | |||
Setting environment variable CMAKE_PREFIX_PATH to /home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr | |||
Setting environment variable QT_PLUGIN_PATH to /home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins | |||
</pre> | |||
by replacing " Setting environment variable " with "", and by replacing " to " with "=" to: | |||
<pre> | |||
XDG_DATA_DIRS=/home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop | |||
PATH=/home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin | |||
CMAKE_MODULE_PATH=/home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake | |||
PKG_CONFIG_PATH=/home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig | |||
LD_LIBRARY_PATH=/home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib | |||
CMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr | |||
QT_PLUGIN_PATH=/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins | |||
</pre> | |||
Select the text block above and in "Environment:" click on the button with the tooltip "Paste". Press "OK" button. | |||
<pre> | |||
rm -rf ~/kde/build/kcalc | |||
</pre> | |||
In the bottom left select the button with the tooltip CMake, this will open the CMake tool window. Press the Clear All button, press the "Reload CMake Project" button. Make sure that the output is correct. | |||
From the CLion main menu > Build > Rebuild "kcalc". | |||
From the CLion main menu > Run > Edit Configurations... > kcalc > Environment variables: > use the button with the tooltip "Paste" to paste the same text block as above in the "Settings > Build, Execution, Deployment" >"Environment:". | |||
Now you can run kcalc correctly, from the CLion main menu > Run > Run 'kcalc' Shift + F10. | |||
Now you can debug kcalc correctly, from the CLion main menu > Run > Debug 'kcalc' Shift + F9. | |||
If CLion starts the process kcalc (for running or for debugging), you can make sure that the process was started correctly. In Clion > in the bottom left button "Debug Alt + 5" > tab "GDB" > run the command <code>info proc</code>. It says: | |||
<pre> | |||
(gdb) info proc | |||
process 89954 | |||
cmdline = '/home/username/kde/build/kcalc/bin/kcalc' | |||
cwd = '/home/username/kde/build/kcalc/bin' | |||
exe = '/home/username/kde/build/kcalc/bin/kcalc' | |||
</pre> | |||
In a terminal: | |||
<pre> | |||
xargs -0 printf %s\\n < /proc/89954/environ | |||
</pre> | |||
The value of the environment variables should be the same as in part that you have written down from the output of <code>kdesrc-build kcalc --debug</code>. |
Revision as of 05:43, 10 September 2023
CLion is a proprietary IDE for C++ from JetBrains.
A screen recording version is available https://www.youtube.com/watch?v=_V5AqMj2fWc
Install CLion
Follow the Install CLion documentation.
If using Arch Linux, you can install the AUR package clion.
Setup a KDE project in CLion
In this article we will use dolphin as an example project. Prerequisite is that you have successfully built a project following kdesrc-build setup procedure. This article assumes your username is username
, and the kdesrc-build setup path is /home/username/kde/
. Replace them to the your values in the specified commands.
Importing project
In the "Welcome to Clion" window press "Open" button. In the "Open File or Project", chose a root folder of dolphin project (~/kde/src/dolphin
) or select the CMakeLists.txt
file in that directory. It will ask how do you want to open it. Press "Open as Project" for file, or "Open as CMake project" for directory.
CMake profile
After previous step, the new window will open to setup cmake profile. You can reach these settings later by going to Settings | Build, Execution, Deployment | CMake. Choose Debug build. In the Generator, set "Let Cmake decide". In the Build directory, specify the build directory path, for this example it will be /home/username/kde/build/dolphin
.
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.
Run/Debug Configuration
In the run/debug target (in the upper right corner of main window), select "dolphin".
Expand it and choose Edit.
The Run/Debug Configurations window will appear.
In the Environment variables field click edit button.
You can add variables in there manually or reuse exports from prefix.sh
script from build directory.
Note: if you want to modify debugging output messages, you can add corresponding variables there. See Guidelines and HOWTOs/Debugging/Using Error Messages#Controlling_Messages.
Variants to setup environment variables
Reusing existing prefix.sh
For convenience, copy the /home/username/kde/build/dolphin/prefix.sh
to /home/username/kde/clion_run_environment.sh
. Use the following syntax for setting variables in that script: export VAR=value
.
In the Environment Variables dialog, in the Load Variables from file field, paste the path /home/username/kde/clion_run_environment.sh
.
Setting variables manually
Translate the content of the file ~/kde/build/dolphin/prefix.sh
to the variables list that you can paste to CLion. E.g. if ~/kde/build/dolphin/prefix.sh
is like:
export PATH=/home/username/kde/usr/bin:$PATH
# LD_LIBRARY_PATH only needed if you are building without rpath
# export LD_LIBRARY_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=/home/username/kde/usr/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
export XDG_CONFIG_DIRS=/home/username/kde/usr/etc/xdg:${XDG_CONFIG_DIRS:-/etc/xdg}
export QT_PLUGIN_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/qml:$QML2_IMPORT_PATH
export QT_QUICK_CONTROLS_STYLE_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/qml/QtQuick/Controls.2/:$QT_QUICK_CONTROLS_STYLE_PATH
Then the same thing in the form of variables list for CLion looks like this block of text:
PATH=/home/username/kde/usr/bin:$PATH$
XDG_DATA_DIRS=/home/username/kde/usr/share:$XDG_DATA_DIRS$:/usr/local/share/:/usr/share/}
XDG_CONFIG_DIRS=/home/username/kde/usr/etc/xdg:$XDG_CONFIG_DIRS$:/etc/xdg
QT_PLUGIN_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/plugins:$QT_PLUGIN_PATH$
QML2_IMPORT_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/qml:$QML2_IMPORT_PATH$
QT_QUICK_CONTROLS_STYLE_PATH=/home/username/kde/usr/lib/x86_64-linux-gnu/qml/QtQuick/Controls.2/:$QT_QUICK_CONTROLS_STYLE_PATH$
You probably want to save the above block of text, in order to reuse it when loading other KDE git repositories in CLion. E.g. to file ~/kde/clion_run_environment.txt
.
Then in the Environment Variables dialog, paste the contents of the ~/kde/clion_run_environment.txt
.
Additional settings
In the Settings | Build, Execution, Deployment | 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.
Tips and Tricks
Set defaults for new projects
For convenience, you can specify default settings for new opened projects. This allows you to not set it manually for each new project you open in CLion.
Go to File | New Projects Setup | Settings for New Projects. The Build, Execution, Deployment | CMake page will be opened. Open the Debug profile.
In the Generator field choose 'Let CMake decide'.
In the Build directory field type: $PROJECT_DIR$/../../build/$PROJECT_NAME$
.
Press OK button.
Additional notes
Under Construction |
---|
This is a new page, currently under construction! |
Note that I tell kdesrc-build to use the CMake generator "Unix Makefiles" by commenting out the line cmake-generator
from the kdesrc-buildrc configuration file. I also need to configure kdesrc-build to use the CMake build configuration "Debug" in order to be able to use the debugger in the IDE, and I use more than 4 CPU threads. For more details see the wiki page for the IDE QtCreator.
cmake-options -DCMAKE_BUILD_TYPE=Debug ... num-cores 14 ... #cmake-generator Kate - Ninja
Build a KDE project e.g.
kdesrc-build kcalc --debug
Look at the output, write down the part similar to:
Running cmake targeting Unix Makefiles... cd /home/username/kde/build/kcalc run_logged_command(): Module kcalc, Command: cmake -B . -S /home/username/kde/src/kcalc -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr -DCMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64 Setting environment variable XDG_DATA_DIRS to /home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop Setting environment variable PATH to /home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin Setting environment variable CMAKE_MODULE_PATH to /home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake Setting environment variable PKG_CONFIG_PATH to /home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig Setting environment variable LD_LIBRARY_PATH to /home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib Setting environment variable CMAKE_PREFIX_PATH to /home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr Setting environment variable QT_PLUGIN_PATH to /home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
In the "Welcome to CLion" wizard > "Open" > "/home/username/kde/src/kcalc/CMakeLists.txt" > OK. The dialog "Open Project CMakeLists.txt is a project file. Would you like to open the project?" is shown, select "Open as Project". Enable check box "Trust projects in ~/kde/src" > "Trust Project" button. In the "Open Project Wizard" dialog select "OK".
Look at the the part that you have written down from the output of kdesrc-build kcalc --debug
.
In Settings > Build, Execution, Deployment select the "Debug" CMake "Profile". "Generator:" "Let CMake decide", "Build directory:" "/home/username/kde/build/kcalc".
CMake options:
-G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr -DCMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64
Convert using a text editor and text replace:
Setting environment variable XDG_DATA_DIRS to /home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop Setting environment variable PATH to /home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin Setting environment variable CMAKE_MODULE_PATH to /home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake Setting environment variable PKG_CONFIG_PATH to /home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig Setting environment variable LD_LIBRARY_PATH to /home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib Setting environment variable CMAKE_PREFIX_PATH to /home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr Setting environment variable QT_PLUGIN_PATH to /home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
by replacing " Setting environment variable " with "", and by replacing " to " with "=" to:
XDG_DATA_DIRS=/home/username/kde/usr/share:/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop PATH=/home/username/kde/usr/bin:/home/username/Qt/6.6.0/gcc_64/bin:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin CMAKE_MODULE_PATH=/home/username/Qt/6.6.0/gcc_64/lib/cmake:/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake PKG_CONFIG_PATH=/home/username/kde/usr/lib/pkgconfig:/home/username/Qt/6.6.0/gcc_64/lib/pkgconfig LD_LIBRARY_PATH=/home/username/kde/usr/lib:/home/username/Qt/6.6.0/gcc_64/lib CMAKE_PREFIX_PATH=/home/username/Qt/6.6.0/gcc_64:/home/username/kde/usr QT_PLUGIN_PATH=/home/username/kde/usr/lib64/plugins:/home/username/kde/usr/lib/plugins
Select the text block above and in "Environment:" click on the button with the tooltip "Paste". Press "OK" button.
rm -rf ~/kde/build/kcalc
In the bottom left select the button with the tooltip CMake, this will open the CMake tool window. Press the Clear All button, press the "Reload CMake Project" button. Make sure that the output is correct. From the CLion main menu > Build > Rebuild "kcalc".
From the CLion main menu > Run > Edit Configurations... > kcalc > Environment variables: > use the button with the tooltip "Paste" to paste the same text block as above in the "Settings > Build, Execution, Deployment" >"Environment:".
Now you can run kcalc correctly, from the CLion main menu > Run > Run 'kcalc' Shift + F10.
Now you can debug kcalc correctly, from the CLion main menu > Run > Debug 'kcalc' Shift + F9.
If CLion starts the process kcalc (for running or for debugging), you can make sure that the process was started correctly. In Clion > in the bottom left button "Debug Alt + 5" > tab "GDB" > run the command info proc
. It says:
(gdb) info proc process 89954 cmdline = '/home/username/kde/build/kcalc/bin/kcalc' cwd = '/home/username/kde/build/kcalc/bin' exe = '/home/username/kde/build/kcalc/bin/kcalc'
In a terminal:
xargs -0 printf %s\\n < /proc/89954/environ
The value of the environment variables should be the same as in part that you have written down from the output of kdesrc-build kcalc --debug
.