Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
CLion¶
CLion 是一个商业化的 JetBrains C++ IDE。
导入项目¶
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:
scons compiledb=yes
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.
项目的编译与调试¶
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:
scons dev_build=yes
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.
Godot debug
.

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 toscons
, 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 不会扩展类似
scons -j$(nproc)
这样的 shell 命令。请使用具体的值,例如scons -j8
。

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 toscons
, set Arguments to-c
(which will clean the build), and set the Working directory to$ProjectFileDir$
. Click OK to create the tool.