CMake debug
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.
For CMake version 3.27 and later, CLion uses the Debug Adapter Protocol (DAP). You can also switch to the implementation based on the CMake script debugger from Sysprogs in Advanced settings.
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 after CMake execution under debug.
If CMake generation failed, click the debug hint in the CMake tool window:
tip
You can also ask the AI Assistant to explain the error.
CLion will launch a debug session and get you to the corresponding point in your code:
note
Before starting a debug session, wait for your project to load/reload and for indexing to finish.
Open the top-level CMakeLists.txt, click the gutter icon next to the first command, and select Debug:
When you launch a debug session this way, CLion creates a temporary configuration of the type CMake Debug. You can save it for further use and create more configurations of that type. For more information, refer to the next section.
In the main menu, go to Run | Edit Configurations.
Click
on the toolbar or press AltInsert. Select CMake Debug from the list of templates:
Set the name for your configuration and add the Before launch steps if required.
Select the newly created configuration in the switcher and click
or press ShiftF9.
The CMake debugger includes many of the general debug features available in CLion. For example, you can set breakpoints, step through your code, watch CMake variables, and explore values inlined in the editor:
![Debug session example Debug session example](https://resources.jetbrains.com/help/img/idea/2024.3/cl_cmake_debug_session_example.png)
Thanks for your feedback!