bsp_configure_code_coverage

Instruments the BSP and all targets using it to produce code coverage reports.

Syntax

bsp_configure_code_coverage(
    ENABLED <0/1>

    ALIAS <BSP alias>
    EXCLUDE_FILES <excluded files>
    EXCLUDE_TARGETS <excluded targets>
)

Overview

The bsp_configure_code_coverage statement enables the --coverage

Parameters

ENABLED
Specifies whether the code should be instrumented for coverage. Change it to 0 to completely disable instrumentation, while keeping the lists of excluded files and targets for later.

ALIAS
Optional. If the project contains multiple BSPs, this parameter allows selecting a specific BSP. If specified, must match the ALIAS parameter of the find_bsp statement.

EXCLUDE_FILES
Optional. Specifies a list of files that will be excluded from coverage instrumentation. Paths are relative to the current source directory. ${BSP_ROOT} denotes files inside the BSP. You can use the Disable Code Coverage command in Solution Explorer on specific files to add files to this list programmatically.

EXCLUDE_TARGETS
Optional. Specifies a list of targets (raw CMake target names) that will be excluded from coverage instrumentation. You can use the Disable Code Coverage command in Solution Explorer on individual targets to add them to this list programmatically.

Remarks

VisualGDB will automatically enable code coverage instrumentation when enabling Live Coverage. See the Live Coverage tutorial for more details.

Examples

The following example enables code coverage for the default BSP (including the LiveCoverageDemo target), but excludes the ExcludedFile.cpp and the entire StaticLibrary library:

find_bsp(ID com.sysprogs.arm.stm32
        VERSION 2020.10
        MCU STM32F407VG)

add_bsp_based_executable(NAME LiveCoverageDemo
                         SOURCES LiveCoverageDemo.cpp ExcludedFile.cpp)

add_bsp_based_library(NAME StaticLibrary
                      SOURCES StaticLibrary.cpp)

bsp_configure_code_coverage(ENABLED 1
                            EXCLUDE_TARGETS StaticLibrary
                            EXCLUDE_FILES ExcludedFile)

See also

Auxiliary Statements, add_embedded_resource, embed_target_output, register_imported_project