# CMake debug

> **TL;DR**
> CMake executable: bundled, version 3.24.2 or later
>
>
>
> OS: macOS / Linux / Windows
>
>
>
> WSL / Remote / Docker toolchains: not supported

CLion CMake debugger can help you identify and fix errors or unwanted behavior in your [CMake scripts](cmakelists-txt-file.html).

For CMake version 3.27 and later, CLion uses the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) (DAP). You can also switch to the implementation based on the [CMake script debugger from Sysprogs](https://sysprogs.com/w/introducing-cmake-script-debugger/) in [Advanced settings](advanced-settings.html#advanced_cmake).

> **Note:**
> The debugger only works for the CMake configuration step. It does not debug your actual project build, and the project model is not [reloaded](reloading-project.html) after CMake execution under debug.

Procedure: Debug a failed CMake generation

1. If CMake generation failed, click the debug hint in the CMake tool window:

![Debug hint in CMake tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_debug_tw_hint.png)

> **Tip:**
> You can also ask the AI Assistant to [explain the error](https://www.jetbrains.com/help/ai-assistant/explain-code-with-ai.html#explain-cmake-errors).

2. CLion will launch a debug session and get you to the corresponding point in your code:

![Debug session started from the CMake tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_debug_failed_fromhint.png)

Procedure: Launch a CMake debug session from the editor

> **Note:**
> Before starting a debug session, wait for your project to load/reload and for project analysis to finish.

* Open the top-level `CMakeLists.txt`, click the gutter icon next to the first command, and select Debug:

![Starting a CMake debug session from gutter](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_boost_debug_gutter.png)

When you launch a debug session this way, CLion creates a temporary configuration of the type CMake Debug. You can [save](run-debug-configuration.html#save-as-permanent) it for further use and create more configurations of that type. For more information, refer to the next section.

Procedure: Create and launch CMake Debug configurations

1. In the main menu, go to `Run | Edit Configurations`.

2. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) on the toolbar or press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌥ Insert` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)). Select CMake Debug from the list of templates:

![Adding a CMake Debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_debug_config_add.png)

3. Set the name for your configuration and add the [Before launch](running-cmake-targets-before-launch.html) steps if required.

4. Select the newly created configuration in the switcher and click ![The Debug button](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.startDebugger.svg) or press `Shift+F9` (Windows), `⌃ D` (macOS), `⇧ F9` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ D` (macOS System Shortcuts), `Shift+F9` (XWin), `Shift+F9` (GNOME), `Shift+F9` (KDE), `Shift+F9` (Emacs), `Shift+F9` (Sublime Text), `⌃ D` (Sublime Text (macOS)), `⌘ R` (Xcode), `Alt+F5` (Visual Studio), `⌥ F5` (Visual Studio (macOS)), `Alt+F5` (ReSharper), `⌥ F5` (ReSharper (macOS)), `F5` (QtCreator), `⌘ Y` (QtCreator (macOS)), `Ctrl+F5` (NetBeans), `Alt+Shift+D` (Eclipse), `⌘ F11` (Eclipse (macOS)).

## CMake debug features

The CMake debugger includes many of the general debug features available in CLion. For example, you can set [breakpoints](using-breakpoints.html), [step through](stepping-through-the-program.html) your code, [watch](examining-suspended-program.html#watches) CMake variables, and explore values [inlined](examining-suspended-program.html#inline-view) in the editor:

![Debug session example](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_debug_session_example.png)

## See also

### Tutorials

[Quick CMake tutorial](quick-cmake-tutorial.html)

### How tos

[CMake profiles](cmake-profile.html) [Toolchains](how-to-create-toolchain-in-clion.html)

### Debugging

[Examine suspended program](examining-suspended-program.html) [Run CMake targets before launch](running-cmake-targets-before-launch.html)

