From 69913adc8001c97366724b108c4bc44ada4163fc Mon Sep 17 00:00:00 2001 From: Jaroslaw Stelter Date: Mon, 4 Jul 2022 17:22:18 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 3 ++- cmake/compiler/clang/compiler_flags.cmake | 16 ++++++++-------- cmake/compiler/gcc/compiler_flags.cmake | 4 ++-- cmake/compiler/xcc/compiler_flags.cmake | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8921a256293..84fa7aa595b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,7 +255,8 @@ zephyr_compile_options("SHELL: $ ${AUTOCONF_H} if(NOT CONFIG_PICOLIBC) # @Intent: Set compiler specific flag for bare metal freestanding option - zephyr_compile_options($) + zephyr_compile_options($<$:$>) + zephyr_compile_options($<$:$>) endif() # @Intent: Set compiler specific flag for tentative definitions, no-common diff --git a/cmake/compiler/clang/compiler_flags.cmake b/cmake/compiler/clang/compiler_flags.cmake index e6e97145526..f4d5a653017 100644 --- a/cmake/compiler/clang/compiler_flags.cmake +++ b/cmake/compiler/clang/compiler_flags.cmake @@ -21,14 +21,14 @@ set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics) ####################################################### # clang option standard warning base in Zephyr -set_compiler_property(PROPERTY warning_base - -Wall - -Wformat - -Wformat-security - -Wno-format-zero-length - -Wno-main - -Wno-unused-but-set-variable - -Wno-typedef-redefinition +check_set_compiler_property(PROPERTY warning_base + -Wall + -Wformat + -Wformat-security + -Wno-format-zero-length + -Wno-main + -Wno-unused-but-set-variable + -Wno-typedef-redefinition ) check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 0d4d6942360..d62931f2e28 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -26,7 +26,7 @@ set_compiler_property(PROPERTY optimization_size -Os) ####################################################### # GCC Option standard warning base in Zephyr -set_compiler_property(PROPERTY warning_base +check_set_compiler_property(PROPERTY warning_base -Wall -Wformat -Wformat-security @@ -160,7 +160,7 @@ endif() check_set_compiler_property(APPEND PROPERTY hosted -fno-freestanding) # gcc flag for a freestanding application -set_compiler_property(PROPERTY freestanding -ffreestanding) +check_set_compiler_property(PROPERTY freestanding -ffreestanding) # Flag to enable debugging set_compiler_property(PROPERTY debug -g) diff --git a/cmake/compiler/xcc/compiler_flags.cmake b/cmake/compiler/xcc/compiler_flags.cmake index f6e14aacc63..49aafd6f64e 100644 --- a/cmake/compiler/xcc/compiler_flags.cmake +++ b/cmake/compiler/xcc/compiler_flags.cmake @@ -6,6 +6,6 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake) # fact that linkage semantics differed between C99 and GNU at the # time. Suppress the warning, it's the best we can do given that # 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)