Work in progress
Godot documentation is being updated to reflect the latest changes in version
4.0. Some documentation pages may
still state outdated information. This banner will tell you if you're reading one of such pages.
The contents of this page are up to date. If you can still find outdated information, please open an issue.
CLion is a commercial JetBrains IDE for C++.
Importing the project¶
CLion can import a project's compilation database file, commonly named
compile_commands.json. To generate the compilation database file, open the terminal, change to the Godot root directory, and run:
Then, open the Godot root directory with CLion. CLion will import the compilation database, index the codebase, and provide autocompletion and other advanced code navigation and refactoring functionality.
Compiling and debugging the project¶
CLion does not support compiling and debugging Godot via SCons out of the box. This can be achieved by creating a custom build target and run configuration in CLion. Before creating a custom build target, you must compile Godot once on the command line, to generate the Godot executable. Open the terminal, change into the Godot root directory, and execute:
To add a custom build target that invokes SCons for compilation:
Open CLion and navigate to Preferences > Build, Execution, Deployment > Custom Build Targets
Click Add target and give the target a name, e.g.
Click ... next to the Build: selectbox, then click the + button in the External Tools dialog to add a new external tool.
Give the tool a name, e.g.
Build Godot debug, set Program to
scons, set Arguments to the compilation settings you want (see compiling Godot), and set the Working directory to
$ProjectFileDir$, which equals the Godot root directory. Click OK to create the tool.
CLion does not expand shell commands like
scons -j$(nproc). Use concrete values instead, e.g.
Back in the External Tools dialog, click the + again to add a second external tool for cleaning the Godot build via SCons. Give the tool a name, e.g.
Clean Godot debug, set Program to
scons, set Arguments to
-c(which will clean the build), and set the Working directory to
$ProjectFileDir$. Click OK to create the tool.
Close the External Tools dialog. In the Custom Build Target dialog for the custom
Godot debugbuild target, select the Build Godot debug tool from the Build select box, and select the Clean Godot debug tool from the Clean select box. Click OK to create the custom build target.
In the main IDE window, click Add Configuration.
In the Run/Debug Configuration dialog, click Add new..., then select Custom Build Application to create a new custom run/debug configuration.
Give the run/debug configuration a name, e.g.
Godot debug, select the
Godot debugcustom build target as the Target. Select the Godot executable in the
bin/folder as the Executable, and set the Program arguments to
--editor --path path-to-your-project/, where
path-to-your-project/should be a path pointing to an existing Godot project. If you omit the
--pathargument, you will only be able to debug the Godot Project Manager window. Click OK to create the run/debug configuration.
You can now build, run, debug, profile, and Valgrind check the Godot editor via the run configuration.