Skip to content

Commit

Permalink
sysbuild: Add support for COMPILER_WARNINGS_AS_ERRORS
Browse files Browse the repository at this point in the history
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 <jamie.mccrae@nordicsemi.no>
  • Loading branch information
nordicjm committed Mar 15, 2024
1 parent f34f060 commit bd06b74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions share/sysbuild/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ config WARN_DEPRECATED
features are enabled.

rsource "images/Kconfig"

menu "Build options"

rsource "build/Kconfig"

endmenu
8 changes: 8 additions & 0 deletions share/sysbuild/build/Kconfig
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 5 additions & 2 deletions share/sysbuild/cmake/modules/sysbuild_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions share/sysbuild/image_configurations/ALL_image_default.cmake
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit bd06b74

Please sign in to comment.