bsp_compile_definitions

Specifies a list of preprocessor macros that will be added when compiling the BSP and all related targets.

Syntax

bsp_compile_definitions(
    BSP_ALIAS <alias>

    <Macro 1>
    <Macro 2>
    ...
    <Macro N>
)

Overview

The bsp_compile_definitions command adds the specified preprocessor macros to a specific BSP instance, and to all targets referencing it (see add_bsp_based_executable and add_bsp_based_library).

Parameters

BSP_ALIAS
Optional. If the project loads multiple BSPs, this parameter allows selecting a specific BSP instance.
Macros
Specifies one or more preprocessor macros, that will be used when building the affected code. Both MACRO and MACRO=VALUE variants are supported.

Remarks

You can configure the list of preprocessor macros applied to a specific BSP instance by locating the BSP node in Solution Explorer and using the Properties -> Compiler Settings -> Additional Preprocessor Macros setting.

Note that macros added via the bsp_compile_definitions command will affect all targets using the specified BSP, including the BSP itself. To add macros to a single target only, use the target_compile_definitions command instead.

Examples

The following example adds the USE_BUILTIN_DISPLAY and DISPLAY_WIDTH=320 macros to primary BSP, and the Application1 executable:

find_bsp(ID com.sysprogs.arm.stm32
         VERSION 2020.10
         MCU STM32F407VG)
bsp_compile_definitions(USE_BUILTIN_DISPLAY DISPLAY_WIDTH=320)
add_bsp_based_executable(NAME Application1
                         SOURCES Application1.cpp)

If the project contains multiple BSPs, use the BSP_ALIAS parameter to select a specific instance:

find_bsp(ID com.sysprogs.arm.stm32
         VERSION 2020.10
         MCU STM32F746NG
         ALIAS SecondaryBSP)
bsp_compile_definitions(BSP_ALIAS SecondaryBSP
                        USE_BUILTIN_DISPLAY
                        DISPLAY_WIDTH=320)
add_bsp_based_executable(NAME Application12
                         BSP_ALIAS SecondaryBSP
                         SOURCES Application2.cpp)

See also

BSP-Related Statements, bsp_compile_flags, bsp_include_directories, bsp_linker_flags, find_bsp