CLion CMake debugger can help you identify and fix errors or unwanted behavior in your CMake scripts.
CLion's implementation is based on the CMake script debugger from Sysprogs.
Debug a failed CMake generation
If CMake generation failed, click the debug hint in the CMake tool window:
CLion will launch a debug session and get you to the corresponding point in your code:
Launch a CMake debug session from the editor
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. See the next section for details.
Create and launch CMake Debug configurations
Click on the toolbar or press Alt+Insert. 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 Shift+F9:
CMake debug features
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: