Skip to content

Commit bd06b74

Browse files
committed
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 <[email protected]>
1 parent f34f060 commit bd06b74

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

share/sysbuild/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ config WARN_DEPRECATED
4242
features are enabled.
4343

4444
rsource "images/Kconfig"
45+
46+
menu "Build options"
47+
48+
rsource "build/Kconfig"
49+
50+
endmenu

share/sysbuild/build/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config COMPILER_WARNINGS_AS_ERRORS
6+
bool "Treat warnings as errors"
7+
help
8+
Turn on "warning as error" toolchain flags for all images if set.

share/sysbuild/cmake/modules/sysbuild_extensions.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,14 @@ function(ExternalZephyrProject_Add)
372372
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES MAIN_APP True)
373373
endif()
374374

375+
set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/ALL_image_default.cmake")
376+
375377
if(DEFINED ZBUILD_APP_TYPE)
376-
set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake")
377-
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT ${image_default})
378+
list(APPEND image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake")
378379
endif()
379380

381+
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT "${image_default}")
382+
380383
if(DEFINED ZBUILD_BOARD)
381384
# Only set image specific board if provided.
382385
# The sysbuild BOARD is exported through sysbuild cache, and will be used
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2024 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# This sysbuild CMake file sets the sysbuild controlled settings as properties
6+
# on all images.
7+
8+
if(SB_CONFIG_COMPILER_WARNINGS_AS_ERRORS)
9+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_COMPILER_WARNINGS_AS_ERRORS y)
10+
endif()

0 commit comments

Comments
 (0)