Skip to content
Permalink
Browse files

cmake: Toolchain abstraction: Introduce macros for MISRA SANE flags

The macros are named toolchain_cc_warning_error_misra_sane and
toolchain_cc_cpp_warning_error_misra_sane

These macros provide toolchain specific flag(s) relating to the MISRA
SANE configuration option.
The macros will place the flag(s) in a variable provided by caller,
which can then add to zephyr compile options.

The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.

No functional change expected.

Signed-off-by: Danny Oerndrup <daor@demant.com>
  • Loading branch information...
daor-oti authored and aescolar committed May 16, 2019
1 parent 8eaa906 commit 8e5a95e4df936445fdb4b6c38663956e72f4b6ea
Showing with 34 additions and 3 deletions.
  1. +5 −2 CMakeLists.txt
  2. +15 −1 cmake/compiler/clang/target_warnings.cmake
  3. +14 −0 cmake/compiler/gcc/target_warnings.cmake
@@ -190,8 +190,11 @@ if(NOT CONFIG_RTTI)
endif()

if(CONFIG_MISRA_SANE)
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:-Werror=vla>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>)
# @Intent: Obtain toolchain compiler flags relating to MISRA.
toolchain_cc_warning_error_misra_sane(CC_MISRA_SANE_FLAG)
toolchain_cc_cpp_warning_error_misra_sane(CPP_MISRA_SANE_FLAG)
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:${CC_MISRA_SANE_FLAG}>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${CPP_MISRA_SANE_FLAG}>)
endif()

# @Intent: Set compiler specific flags for standard C includes
@@ -93,4 +93,18 @@ macro(toolchain_cc_warning_extended)
-Wno-tautological-compare
)

endmacro()
endmacro()

#
# The following macros leaves it up to the root CMakeLists.txt to choose
# the variables in which to put the requested flags, and whether or not
# to call the macros
#

macro(toolchain_cc_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()

macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()
@@ -80,3 +80,17 @@ macro(toolchain_cc_warning_extended)
)

endmacro()

#
# The following macros leaves it up to the root CMakeLists.txt to choose
# the variables in which to put the requested flags, and whether or not
# to call the macros
#

macro(toolchain_cc_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()

macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()

0 comments on commit 8e5a95e

Please sign in to comment.
You can’t perform that action at this time.