Skip to content

Commit 9da2d3d

Browse files
authored
Update CLion docs + add linux (#64)
* update tutorial for clion * add linux clion docs
1 parent 21ce018 commit 9da2d3d

12 files changed

+50
-19
lines changed

assets/clion_addconfiguration.png

11.6 KB
Loading

assets/clion_buildmod.png

3.65 KB
Loading

assets/clion_cmakerunfailed.png

-39 KB
Binary file not shown.

assets/clion_openprojectwizard.png

13 KB
Loading
14.2 KB
Loading

assets/clion_reloadcmake.png

18.6 KB
Loading

assets/clion_rundebugsetup.png

-53.6 KB
Binary file not shown.

assets/clion_rundebugwindow.png

-52.5 KB
Binary file not shown.

assets/clion_toolchainlinux.png

55.5 KB
Loading

assets/clion_toolchainllvm.png

44.9 KB
Loading

assets/clion_toolchainmsvc.png

58.8 KB
Loading

getting-started/ide-setup.md

+50-19
Original file line numberDiff line numberDiff line change
@@ -128,43 +128,74 @@ If there are errors similar to VS Code (such as `#include <Geode/modify/MenuLaye
128128

129129
# CLion
130130

131-
No additional plugins are needed - the only thing you need to do is to set the CMake options correctly. When you open your mod's directory in CLion for the first time, you'll be met with an Open Project Wizard:
131+
* [CLion on Windows](#clion-on-windows)
132+
* [CLion on Linux](#clion-on-linux)
133+
134+
## CLion on Windows
135+
136+
No additional plugins are needed - the only thing you need to do is to configure your toolchain correctly. When you open your mod's directory in CLion for the first time, you'll be met with an Open Project Wizard:
132137

133138
![Image showing the CLion Open Project Wizard](/assets/clion_openprojectwizard.png)
134139

135-
Here you need to make sure that:
140+
If this is the first time you're launching CLion, click the "Manage toolchains..." button, which will open a window where you can add a new toolchain.
141+
142+
Here's an example of how to set up Visual Studio toolchain:
143+
144+
![Image showing configured Visual Studio toolchain in CLion](/assets/clion_toolchainmsvc.png)
145+
146+
And here's an example of how to set up Clang toolchain:
136147

137-
1. Build type is set to `Release` or `RelWithDebInfo`; it cannot be Debug
138-
2. Toolchain is set to *Visual Studio*
139-
3. Generator is set to *Visual Studio 17 2022* or newer
140-
4. Build directory is set to *build*
148+
![Image showing configured Clang toolchain in CLion](/assets/clion_toolchainllvm.png)
149+
150+
After that, in the Open Project Wizard, you need to make sure that:
151+
152+
1. Build type is set to `Release` or `RelWithDebInfo` (we recommend `RelWithDebInfo`, since `Debug` might cause obscure crashes)
153+
2. Toolchain is set to *Visual Studio* or *Clang/LLVM*
154+
3. Generator is set to *Visual Studio 17 2022* or *Ninja* (if you have it installed)
141155

142156
In the end it should look like this:
143157

144158
![Image showing the CLion Open Project Wizard set up for Geode](/assets/clion_openprojectwizardsetup.png)
145159

146-
Now you can press OK and CMake will run for the first time. The setup **will fail** until you build the project for the first time. In order to do that, go to the top right corner of the window where you'll see a dropdown saying `Add Configuration`.
160+
Now you can press OK and CMake will run for the first time. Wait until it finishes, and you should see a dropdown in the top right corner of the window that says `NameOfTheMod` (or whatever you called your project).
161+
Click on it, and pick `NameOfTheMod_PACKAGE` instead, which will trigger post build steps and package/install the mod to Geometry Dash.
162+
163+
![Image showing the CLion Configuration dropdown](/assets/clion_addconfiguration.png)
164+
165+
Now click the hammer icon in the top right corner next to build the mod:
166+
167+
![Image showing the build button in CLion](/assets/clion_buildmod.png)
168+
169+
The build should end with a message saying `Build finished` and (assuming you ran `geode config setup` before) the mod should now be installed to Geometry Dash.
147170

148-
![Image showing the CLion Add Configuration dropdown](/assets/clion_addconfiguration.png)
171+
Don't forget to reload CMake after you add new files to the project.
172+
173+
![Image showing how to rerun CMake in CLion](/assets/clion_reloadcmake.png)
149174

150-
Click it and choose `Edit Configurations` and you'll be met with the Run/Debug Configurations window. Inside of it, click the plus button in the top left corner of the window and choose `CMake Application` from the popup:
175+
## CLion on Linux
151176

152-
![Image showing the CLion Run/Debug Configurations window](/assets/clion_rundebugwindow.png)
177+
Pretty much the same as on [Windows](#clion-on-windows) except for setting up the toolchain.
153178

154-
In the created configuration, click the `Target` dropdown and choose `All Targets`. You can also change the name to something else than "Unnamed".
179+
First step is to create an environment file with the following content:
155180

156-
![Image showing the CLion Run/Debug Configurations window with a configuration set up to compile the mod](/assets/clion_rundebugsetup.png)
181+
```bash
182+
export GEODE_SDK=$HOME/Documents/Geode
183+
export SPLAT_DIR=$HOME/.local/share/Geode/cross-tools/splat
184+
export CMAKE_TOOLCHAIN_FILE=$HOME/.local/share/Geode/cross-tools/clang-msvc-sdk/clang-msvc.cmake
185+
export HOST_ARCH=x86_64
186+
```
157187

158-
Once that's done, you can click Apply and then OK. If it hasn't already, wait for CMake to finish its run. It might look something like this, with a line at the end saying `[Failed to reload]`.
188+
If the toolchain and/or splat weren't installed via `geode sdk install-linux`, modify the paths accordingly.
159189

160-
![Image showing the failed CMake run output](/assets/clion_cmakerunfailed.png)
190+
Save it as `geode-env.sh` in your home directory (or wherever you want, just remember the path).
161191

162-
Now click the hammer icon in the top right corner next to build the mod for the first time - **make sure that the dropdowns next to it say `RelWithDebInfo` and `Build Mod`** (or however you called your build task in the step before):
192+
> :warning: If you're using a non default shell (like fish), you might need to edit the environment file to use the correct syntax. For example, fish uses `set -gx VAR value` instead of `export VAR=value`.
163193
164-
![Image showing the build button in CLion](/assets/clion_buildmod.png)
194+
Now, in the toolchain settings on the right side of the **Name** field, click the *Add environment* button and select the file you just created.
165195

166-
The build should end with a message saying `Build finished` and (assuming you ran `geode config setup` before) the mod should now be installed to Geometry Dash. In order to make all the IDE features work correctly, reload CMake now, this run should end successfully with a message saying `[Finished]` at the end:
196+
![Image showing how to configure crosscompiler toolchain in CLion](/assets/clion_toolchainlinux.png)
167197

168-
![Image showing how to rerun CMake in CLion](/assets/clion_reloadcmake.png)
198+
After that, you can follow the same steps as on Windows to build your mod.
169199

170-
Don't forget to reload CMake after you add new files to the project.
200+
For some specific mods/libraries (most people won't need this), you might also want to add the clang-cl toolchain. Everything is the same as with clang, except you have to use the `clang-cl-msvc.cmake` toolchain file instead. (Copy the environment file and change the `CMAKE_TOOLCHAIN_FILE` variable to point to the `clang-cl-msvc.cmake` file.)
201+
Also make sure you're using `clang-cl` as the compiler in the toolchain settings.

0 commit comments

Comments
 (0)