2021-12-16 15:22:46 +01:00
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2021, Nordic Semiconductor ASA
|
|
|
|
|
|
|
|
|
|
# Zephyr build system configuration files.
|
|
|
|
|
#
|
|
|
|
|
# Locate the Kconfig and DT config files that are to be used.
|
|
|
|
|
# Also, locate the appropriate application config directory.
|
|
|
|
|
#
|
|
|
|
|
# Outcome:
|
|
|
|
|
# The following variables will be defined when this CMake module completes:
|
|
|
|
|
#
|
|
|
|
|
# - CONF_FILE: List of Kconfig fragments
|
2023-05-17 12:46:24 +02:00
|
|
|
|
# - EXTRA_CONF_FILE: List of additional Kconfig fragments
|
2021-12-16 15:22:46 +01:00
|
|
|
|
# - DTC_OVERLAY_FILE: List of devicetree overlay files
|
2023-07-08 12:28:37 +02:00
|
|
|
|
# - EXTRA_DTC_OVERLAY_FILE List of additional devicetree overlay files
|
|
|
|
|
# - DTS_EXTRA_CPPFLAGS List of additional devicetree preprocessor defines
|
2021-12-16 15:22:46 +01:00
|
|
|
|
# - APPLICATION_CONFIG_DIR: Root folder for application configuration
|
|
|
|
|
#
|
|
|
|
|
# If any of the above variables are already set when this CMake module is
|
|
|
|
|
# loaded, then no changes to the variable will happen.
|
|
|
|
|
#
|
|
|
|
|
# Variables set by this module and not mentioned above are considered internal
|
|
|
|
|
# use only and may be removed, renamed, or re-purposed without prior notice.
|
|
|
|
|
|
2021-12-16 17:13:54 +01:00
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
|
|
include(extensions)
|
|
|
|
|
|
2022-10-10 11:39:00 +02:00
|
|
|
|
zephyr_get(APPLICATION_CONFIG_DIR)
|
2021-12-16 15:22:46 +01:00
|
|
|
|
if(DEFINED APPLICATION_CONFIG_DIR)
|
|
|
|
|
string(CONFIGURE ${APPLICATION_CONFIG_DIR} APPLICATION_CONFIG_DIR)
|
|
|
|
|
if(NOT IS_ABSOLUTE ${APPLICATION_CONFIG_DIR})
|
|
|
|
|
get_filename_component(APPLICATION_CONFIG_DIR ${APPLICATION_CONFIG_DIR} ABSOLUTE)
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
# Application config dir is not set, so we default to the application
|
|
|
|
|
# source directory as configuration directory.
|
|
|
|
|
set(APPLICATION_CONFIG_DIR ${APPLICATION_SOURCE_DIR})
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-08-18 16:02:50 +02:00
|
|
|
|
zephyr_get(CONF_FILE SYSBUILD LOCAL)
|
2021-12-16 15:22:46 +01:00
|
|
|
|
if(DEFINED CONF_FILE)
|
|
|
|
|
# This ensures that CACHE{CONF_FILE} will be set correctly to current scope
|
|
|
|
|
# variable CONF_FILE. An already current scope variable will stay the same.
|
|
|
|
|
set(CONF_FILE ${CONF_FILE})
|
|
|
|
|
|
|
|
|
|
# CONF_FILE has either been specified on the cmake CLI or is already
|
|
|
|
|
# in the CMakeCache.txt. This has precedence over the environment
|
|
|
|
|
# variable CONF_FILE and the default prj.conf
|
|
|
|
|
|
|
|
|
|
# In order to support a `prj_<name>.conf pattern for auto inclusion of board
|
|
|
|
|
# overlays, then we must first ensure only a single conf file is provided.
|
2022-01-21 19:58:17 +01:00
|
|
|
|
string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED)
|
|
|
|
|
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
|
2021-12-16 15:22:46 +01:00
|
|
|
|
list(LENGTH CONF_FILE_AS_LIST CONF_FILE_LENGTH)
|
|
|
|
|
if(${CONF_FILE_LENGTH} EQUAL 1)
|
|
|
|
|
# Need the file name to look for match.
|
|
|
|
|
# Need path in order to check if it is absolute.
|
|
|
|
|
get_filename_component(CONF_FILE_NAME ${CONF_FILE} NAME)
|
|
|
|
|
if(${CONF_FILE_NAME} MATCHES "prj_(.*).conf")
|
|
|
|
|
set(CONF_FILE_BUILD_TYPE ${CMAKE_MATCH_1})
|
|
|
|
|
set(CONF_FILE_INCLUDE_FRAGMENTS true)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
elseif(CACHED_CONF_FILE)
|
|
|
|
|
# Cached conf file is present.
|
|
|
|
|
# That value has precedence over anything else than a new
|
|
|
|
|
# `cmake -DCONF_FILE=<file>` invocation.
|
|
|
|
|
set(CONF_FILE ${CACHED_CONF_FILE})
|
|
|
|
|
elseif(EXISTS ${APPLICATION_CONFIG_DIR}/prj_${BOARD}.conf)
|
|
|
|
|
set(CONF_FILE ${APPLICATION_CONFIG_DIR}/prj_${BOARD}.conf)
|
2023-03-20 14:32:33 +01:00
|
|
|
|
find_package(Deprecated COMPONENTS PRJ_BOARD)
|
2021-12-16 15:22:46 +01:00
|
|
|
|
elseif(EXISTS ${APPLICATION_CONFIG_DIR}/prj.conf)
|
|
|
|
|
set(CONF_FILE ${APPLICATION_CONFIG_DIR}/prj.conf)
|
|
|
|
|
set(CONF_FILE_INCLUDE_FRAGMENTS true)
|
2023-03-16 12:01:45 +01:00
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "No prj.conf file was found in the ${APPLICATION_CONFIG_DIR} folder, "
|
|
|
|
|
"please read the Zephyr documentation on application development.")
|
2021-12-16 15:22:46 +01:00
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(CONF_FILE_INCLUDE_FRAGMENTS)
|
|
|
|
|
zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/boards KCONF CONF_FILE BUILD ${CONF_FILE_BUILD_TYPE})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(APPLICATION_CONFIG_DIR ${APPLICATION_CONFIG_DIR} CACHE INTERNAL "The application configuration folder")
|
|
|
|
|
set(CACHED_CONF_FILE ${CONF_FILE} CACHE STRING "If desired, you can build the application using\
|
|
|
|
|
the configuration settings specified in an alternate .conf file using this parameter. \
|
|
|
|
|
These settings will override the settings in the application’s .config file or its default .conf file.\
|
2022-03-16 22:07:43 +01:00
|
|
|
|
Multiple files may be listed, e.g. CONF_FILE=\"prj1.conf;prj2.conf\" \
|
2021-12-16 15:22:46 +01:00
|
|
|
|
The CACHED_CONF_FILE is internal Zephyr variable used between CMake runs. \
|
|
|
|
|
To change CONF_FILE, use the CONF_FILE variable.")
|
|
|
|
|
unset(CONF_FILE CACHE)
|
|
|
|
|
|
|
|
|
|
zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/boards DTS APP_BOARD_DTS)
|
|
|
|
|
|
|
|
|
|
# The CONF_FILE variable is now set to its final value.
|
|
|
|
|
zephyr_boilerplate_watch(CONF_FILE)
|
|
|
|
|
|
2022-08-18 16:02:50 +02:00
|
|
|
|
zephyr_get(DTC_OVERLAY_FILE SYSBUILD LOCAL)
|
2021-12-16 15:22:46 +01:00
|
|
|
|
if(DTC_OVERLAY_FILE)
|
|
|
|
|
# DTC_OVERLAY_FILE has either been specified on the cmake CLI or is already
|
|
|
|
|
# in the CMakeCache.txt.
|
|
|
|
|
elseif(APP_BOARD_DTS)
|
|
|
|
|
set(DTC_OVERLAY_FILE ${APP_BOARD_DTS})
|
|
|
|
|
elseif(EXISTS ${APPLICATION_CONFIG_DIR}/${BOARD}.overlay)
|
|
|
|
|
set(DTC_OVERLAY_FILE ${APPLICATION_CONFIG_DIR}/${BOARD}.overlay)
|
|
|
|
|
elseif(EXISTS ${APPLICATION_CONFIG_DIR}/app.overlay)
|
|
|
|
|
set(DTC_OVERLAY_FILE ${APPLICATION_CONFIG_DIR}/app.overlay)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(DTC_OVERLAY_FILE ${DTC_OVERLAY_FILE} CACHE STRING "If desired, you can \
|
|
|
|
|
build the application using the DT configuration settings specified in an \
|
|
|
|
|
alternate .overlay file using this parameter. These settings will override the \
|
|
|
|
|
settings in the board's .dts file. Multiple files may be listed, e.g. \
|
|
|
|
|
DTC_OVERLAY_FILE=\"dts1.overlay dts2.overlay\"")
|
|
|
|
|
|
|
|
|
|
# The DTC_OVERLAY_FILE variable is now set to its final value.
|
|
|
|
|
zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
|
sysbuild: Add SB_OVERLAY_CONFIG
This fixes a minor issue in sysbuild, where `-DOVERLAY_CONFIG=...` would
be applied not only to the main application, but also sysbuild itself.
This was incorrect, because sysbuild imports a different Kconfig tree
than normal Zephyr builds, so the same Kconfig fragment file would not
necessarily be valid for both.
This adds a new variable SB_OVERLAY_CONFIG to resolve this ambiguity.
It functions along the lines of SB_CONF_FILE, with both being sysbuild-
specific versions of existing variables.
To ensure that OVERLAY_CONFIG is still passed on to the main application
verbatim, its value is now loaded in `configuration_files.cmake`, rather
than `kconfig.cmake`. This is because the former file is not imported by
sysbuild, and it is where the related variables, such as CONF_FILE and
DTC_OVERLAY_FILE, are loaded as well.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-05-04 13:21:13 +02:00
|
|
|
|
|
2023-05-08 14:01:34 +02:00
|
|
|
|
zephyr_get(EXTRA_CONF_FILE SYSBUILD LOCAL VAR EXTRA_CONF_FILE OVERLAY_CONFIG MERGE REVERSE)
|
|
|
|
|
zephyr_get(EXTRA_DTC_OVERLAY_FILE SYSBUILD LOCAL MERGE REVERSE)
|
2023-07-08 12:28:37 +02:00
|
|
|
|
zephyr_get(DTS_EXTRA_CPPFLAGS SYSBUILD LOCAL MERGE REVERSE)
|