Prerequisites
1
Build the Toolchain
If you have not built the Toolchain, run:
2
Build Host Tools from Lagom
Run one of the following:Or manually:
Project Configuration
After opening theserenity repository in CLion as a new project, the “Open Project Wizard” window will open.
CMake will complain with any build type other than
Default. Make sure CMAKE_BUILD_TYPE is empty in the Build/x86_64/CMakeCache.txt file.CMake Settings
Configure the following fields in the Open Project Wizard: Build type:Default
CMake Options:
Build/x86_64
If you already have the project open, access these settings via:
File → Settings → Build, Execution, Deployment → CMake
Excluding Build Artifacts
Source files are copied to theBuild directory during compilation. Exclude them from CLion indexing to avoid confusion and prevent accidental edits to copied files.
1
Exclude Build Directory
- Navigate to the
Projecttool window - Right-click the
Buildfolder - Select
Mark Directory as → Excluded
2
Exclude Toolchain Directories (Optional)
Follow the same procedure for:
Toolchain/LocalToolchain/TarballsToolchain/Build
Include Headers for Code Insight
Mark source directories to enable proper code comprehension:- Right-click on each of these folders:
AK,Kernel,Userland - Select
Mark Directory as → Project Sources and Headers
Code Generation Settings
Import the SerenityOS code style to match the project’s coding standards:- Go to
Settings → Editor → Code Style → C/C++ - Click
Scheme → Cog icon → Import Scheme... - Import
CLionCodeStyleSettings.xmlfrom the Documentation directory
Quick Switching Between Kernel and Userland
CLion needs to know whether you’re working on Kernel or Userland code to correctly parse conditional compilation blocks:1
Remove Auto-Generated Targets
- Click the configuration dropdown (top right)
- Select
Edit Configurations - Press
Ctrl+Ato select all auto-generated targets - Press
Deleteto remove them


2
Add Kernel Configuration
- Press the
+button - Select
CMake Application - Name:
Kernel - Target:
Kernel(type to search)
3
Add Userland Configuration
- Press the
+button - Select
CMake Application - Name:
Userland - Target:
true
Kernel | Default / Userland | Default button.
WSL-Specific Configuration
Toolchain Setup
If the serenity directory is on the WSL filesystem:- Go to
File → Settings → Build, Execution, Deployment → Toolchains - Click the
+icon - Select
WSL - In
Toolset, select your WSL distribution
Terminal Configuration
You can set the embedded terminal to use your WSL distribution’s shell:This is only useful if you don’t use an X-window server for QEMU. You can install QEMU natively on Windows and allow WSL to use it. See BuildInstructionsWindows.md for details.
1
Locate the Terminal Emulator
- Open CMD with elevated privileges
- Navigate to
C:/Program Files/WindowsApps/ - Run
dirand look for your distribution (e.g.,CanonicalGroupLimited.Ubuntu20.04onWindows_...) - cd into that directory
- Copy the absolute path to the shell executable (e.g.,
ubuntu2004.exe)
2
Configure CLion Terminal
- Go to
File → Settings → Tools → Terminal - Paste the path to
Shell path - Click OK
3
Restart CLion
Close and restart CLion for changes to take effect
./Meta/serenity.sh commands directly from CLion’s terminal.
