From 9f71b8023bc1917174099cd2f1422bcf0ba8d333 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 14 Mar 2024 10:37:01 +0000 Subject: [PATCH] sysbuild: Add support for COMPILER_WARNINGS_AS_ERRORS Adds support for the Kconfig option to enable compiler warnings being treated as errors in all images that are build. This is a sticky-set option which means enabling it in sysbuild will enable it in all images, if it is then disabled in sysbuild it will not be disabled in any of the images as a result and would need to be manually unselected. Signed-off-by: Jamie McCrae --- share/sysbuild/Kconfig | 6 ++++++ share/sysbuild/build/Kconfig | 8 ++++++++ share/sysbuild/cmake/modules/sysbuild_extensions.cmake | 7 +++++-- .../image_configurations/ALL_image_default.cmake | 10 ++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 share/sysbuild/build/Kconfig create mode 100644 share/sysbuild/image_configurations/ALL_image_default.cmake diff --git a/share/sysbuild/Kconfig b/share/sysbuild/Kconfig index 9f1a1cf30a..d8a0cf25b8 100644 --- a/share/sysbuild/Kconfig +++ b/share/sysbuild/Kconfig @@ -42,3 +42,9 @@ config WARN_DEPRECATED features are enabled. rsource "images/Kconfig" + +menu "Build options" + +rsource "build/Kconfig" + +endmenu diff --git a/share/sysbuild/build/Kconfig b/share/sysbuild/build/Kconfig new file mode 100644 index 0000000000..dfa423cd3e --- /dev/null +++ b/share/sysbuild/build/Kconfig @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 + +config COMPILER_WARNINGS_AS_ERRORS + bool "Treat warnings as errors" + help + Turn on "warning as error" toolchain flags for all images if set. diff --git a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake index 05cde48a0e..40f73d26da 100644 --- a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake @@ -372,11 +372,14 @@ function(ExternalZephyrProject_Add) set_target_properties(${ZBUILD_APPLICATION} PROPERTIES MAIN_APP True) endif() + set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/ALL_image_default.cmake") + if(DEFINED ZBUILD_APP_TYPE) - set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake") - set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT ${image_default}) + list(APPEND image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake") endif() + set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT "${image_default}") + if(DEFINED ZBUILD_BOARD) # Only set image specific board if provided. # The sysbuild BOARD is exported through sysbuild cache, and will be used diff --git a/share/sysbuild/image_configurations/ALL_image_default.cmake b/share/sysbuild/image_configurations/ALL_image_default.cmake new file mode 100644 index 0000000000..d270704ad5 --- /dev/null +++ b/share/sysbuild/image_configurations/ALL_image_default.cmake @@ -0,0 +1,10 @@ +# Copyright (c) 2024 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 + +# This sysbuild CMake file sets the sysbuild controlled settings as properties +# on all images. + +if(SB_CONFIG_COMPILER_WARNINGS_AS_ERRORS) + set_config_bool(${ZCMAKE_APPLICATION} CONFIG_COMPILER_WARNINGS_AS_ERRORS y) +endif()