CLion

CLion is a commercial JetBrains IDE for C++.

导入项目

CLion需要一个``CMakeLists.txt``文件作为项目文件,这对Godot来说是个问题,因为它使用SCons构建系统而不是CMake。然而,有一个``CMakeLists.txt``配置:ref:`Android Studio <doc_configuring_an_ide_android_studio>`也可以被CLion使用。

  • 在CLion的欢迎窗口中选择导入现有工程的选项。如果您已经打开了另一个项目,从顶部菜单中选择**文件 > 打开**。

  • Navigate to <Godot root directory>/platform/android/java/nativeSrcsConfigs (the CMakeLists.txt file is located there) and select it (but not the CMakeLists.txt file itself), then click OK.

../../../_images/clion_1_open.png

文件夹包含``CMakeLists.txt``文件。

  • 如果出现这个弹出窗口,选择**This Window**打开项目:

../../../_images/clion_2_this_window.png
  • 从顶部菜单中选择**工具 > CMake > 更改项目根**,并选择Godot根文件夹。

../../../_images/clion_3_change_project_root.png
  • 你现在应该可以看到所有的项目文件。一旦项目完成了索引,自动完成应该就可以了。

如果遇到问题,也可在 Godot社区论坛 中寻求帮助。

Debugging the project

Since CLion does not support SCons, you won't be able to compile, launch, and debug Godot from CLion in one step. You will first need to compile godot yourself and run the binary without CLion. You will then be able to debug Godot by using the Attach to process feature.

  • Run the compilation in debug mode by entering scons.

  • Run the binary you have created (in the bin directory). If you want to debug a specific project, run the binary with the following arguments : --editor --path path/to/your/godot/project. To run the project instead of editing it, remove the --editor argument.

  • In CLion, go to Run > Attach to Process...

../../../_images/clion_4_select_attach_to_process.png
  • Find and Select godot in the list (or type the binary name/Process ID)

../../../_images/clion_5_select_godot_process.png

You can now use the debugging tools from CLion.

注解

If you run the binary without any arguments, you will only debug the project manager window. Don't forget to add the --path path/to/your/godot/project argument to debug a project.