bsp_compile_flags

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

Syntax

bsp_compile_flags(
    BSP_ALIAS <alias>

    <Flag 1>
    <Flag 2>
    ...
    <Flag N>
)

Overview

The bsp_compile_flags command adds the specified compiler flags 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.
Flags
Specifies one or more compiler flags (CFLAGS) that will be added when compiling the BSP, and all related targets. Use the $<$<COMPILE_LANGUAGE:C|CXX|ASM>:flags> syntax to specify the flags for C/C++/Assembly files only.

Remarks

You can configure the list of extra compiler flags added to a specific BSP instance by locating the BSP node in Solution Explorer and using the Properties -> Compiler Settings -> Additional CFLAGS setting.

WARNING: Do not use bsp_compile_flags to pass -fexceptions, -frtti, -ffunction-sections, or -std options to the compiler. Use the NO_GC_SECTIONS, ENABLE_EXCEPTIONS, ENABLE_RTTI and C_STANDARD parameters of the find_bsp command instead.

Examples

The following example will treat all warnings as errors when compiling the BSP itself, and also all targets referencing that BSP:

find_bsp(ID com.sysprogs.arm.stm32
         VERSION 2020.10
         MCU STM32F407VG)
bsp_compile_flags(-Werror)
add_bsp_based_executable(NAME Application1
                         SOURCES Application1.cpp)

The example below adds the -ftemplate-depth=10 argument to all C++ (but not Plain C) files in the BSP and related targets:

bsp_compile_flags($<$<COMPILE_LANGUAGE:CXX>:-ftemplate-depth=10>)

If the project contains multiple BSPs, use the BSP_ALIAS parameter to select a specific instance. See bsp_include_directories for a specific example.

See also

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