Skip to main content

IAR Embedded Workbench for Arm 10.10.x

Debugging a CMake project using preconfigured debug settings

In this section:

When you launch a debug session, C-SPY can read parameters and settings from a JSON file, a launch configuration file—see Saving and loading debugger launch settings. A launch configuration file can be used also when you debug a CMake project that has been added to the IDE.

When the IDE configures an imported CMake project for the first time, it looks for the cache variable IAR_DEBUG_FILE and a cache variable that starts with IAR_DEBUG_CONFIG_. If they are found, the file specified in IAR_DEBUG_FILE will be loaded by the debugger and the debugger is set as active.

If a IAR_DEBUG_CONFIG_configname variable is found for the given debug configuration, it specifies which launch to use for the configuration. If no IAR_DEBUG_CONFIG_configname variable is found, the first launch in the configuration file is used.

For example, set these cache variables in CMake:

set(IAR_DEBUG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/launch.json" CACHE PATH "")
set(IAR_DEBUG_CONFIG_Release "launch_2" CACHE STRING "")

As a result, the IDE will load the file launch.json located in the same directory as the CMakeLists.txt file. Moreover, for the configuration Release, it will set the active launch to launch_2 if it exists.