cmake: filter not supported C++ compilation flags

Compilation warnings appears for C++ files, that following
options are not valid:
-ffrestanding,
-Wno-format-zero-length
-Wno-main
-fgnu89-inline
-std-gnu99
Added checks to filter out unsupported flags.

Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
This commit is contained in:
Jaroslaw Stelter 2022-07-04 17:22:18 +02:00 committed by Fabio Baltieri
commit 69913adc80
4 changed files with 13 additions and 12 deletions

View file

@ -255,7 +255,8 @@ zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${AUTOCONF_H}
if(NOT CONFIG_PICOLIBC) if(NOT CONFIG_PICOLIBC)
# @Intent: Set compiler specific flag for bare metal freestanding option # @Intent: Set compiler specific flag for bare metal freestanding option
zephyr_compile_options($<TARGET_PROPERTY:compiler,freestanding>) zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,freestanding>>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:compiler,freestanding>>)
endif() endif()
# @Intent: Set compiler specific flag for tentative definitions, no-common # @Intent: Set compiler specific flag for tentative definitions, no-common

View file

@ -21,7 +21,7 @@ set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)
####################################################### #######################################################
# clang option standard warning base in Zephyr # clang option standard warning base in Zephyr
set_compiler_property(PROPERTY warning_base check_set_compiler_property(PROPERTY warning_base
-Wall -Wall
-Wformat -Wformat
-Wformat-security -Wformat-security

View file

@ -26,7 +26,7 @@ set_compiler_property(PROPERTY optimization_size -Os)
####################################################### #######################################################
# GCC Option standard warning base in Zephyr # GCC Option standard warning base in Zephyr
set_compiler_property(PROPERTY warning_base check_set_compiler_property(PROPERTY warning_base
-Wall -Wall
-Wformat -Wformat
-Wformat-security -Wformat-security
@ -160,7 +160,7 @@ endif()
check_set_compiler_property(APPEND PROPERTY hosted -fno-freestanding) check_set_compiler_property(APPEND PROPERTY hosted -fno-freestanding)
# gcc flag for a freestanding application # gcc flag for a freestanding application
set_compiler_property(PROPERTY freestanding -ffreestanding) check_set_compiler_property(PROPERTY freestanding -ffreestanding)
# Flag to enable debugging # Flag to enable debugging
set_compiler_property(PROPERTY debug -g) set_compiler_property(PROPERTY debug -g)

View file

@ -6,6 +6,6 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake)
# fact that linkage semantics differed between C99 and GNU at the # fact that linkage semantics differed between C99 and GNU at the
# time. Suppress the warning, it's the best we can do given that # time. Suppress the warning, it's the best we can do given that
# it's a legacy compiler. # it's a legacy compiler.
set_compiler_property(APPEND PROPERTY warning_base "-fgnu89-inline") check_set_compiler_property(APPEND PROPERTY warning_base "-fgnu89-inline")
set_compiler_property(PROPERTY warning_error_misra_sane) set_compiler_property(PROPERTY warning_error_misra_sane)