cmake: update common Zephyr build settings to use zephyr_get()

Fixes: #40389

This commit aligns the use of the following Zephyr build variables:
- CONF_FILE
- DTC_OVERLAY_FILE
- OVERLAY_CONFIG
- WEST_DIR
- ZEPHYR_BOARD_ALIASES
- ZEPHYR_EXTRA_MODULES
- ZEPHYR_MODULES

so that they can be set in same manner and with same order of
preference.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-08-19 16:27:39 +02:00 committed by Carles Cufí
parent 6d1f6c2d4e
commit 44a05e4439
5 changed files with 9 additions and 17 deletions

View file

@ -128,10 +128,7 @@ if(RUNNERS)
create_runners_yaml(${RUNNERS})
endif()
if(DEFINED ENV{WEST_DIR} AND NOT WEST_DIR)
set(WEST_DIR $ENV{WEST_DIR})
endif(DEFINED ENV{WEST_DIR} AND NOT WEST_DIR)
zephyr_get(WEST_DIR)
if(WEST_DIR)
set(WEST "PYTHONPATH=${WEST_DIR}/src" "${PYTHON_EXECUTABLE};${WEST_DIR}/src/west/app/main.py;--zephyr-base=${ZEPHYR_BASE} ")
endif()

View file

@ -64,8 +64,9 @@ if(NOT (REVISION_SEPARATOR_INDEX EQUAL -1))
string(SUBSTRING ${BOARD} 0 ${REVISION_SEPARATOR_INDEX} BOARD)
endif()
if(DEFINED ENV{ZEPHYR_BOARD_ALIASES})
include($ENV{ZEPHYR_BOARD_ALIASES})
zephyr_get(ZEPHYR_BOARD_ALIASES)
if(DEFINED ZEPHYR_BOARD_ALIASES)
include(${ZEPHYR_BOARD_ALIASES})
if(${BOARD}_BOARD_ALIAS)
set(BOARD_ALIAS ${BOARD} CACHE STRING "Board alias, provided by user")
set(BOARD ${${BOARD}_BOARD_ALIAS})

View file

@ -35,6 +35,7 @@ else()
set(APPLICATION_CONFIG_DIR ${APPLICATION_SOURCE_DIR})
endif()
zephyr_get(CONF_FILE)
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.
@ -62,9 +63,6 @@ elseif(CACHED_CONF_FILE)
# That value has precedence over anything else than a new
# `cmake -DCONF_FILE=<file>` invocation.
set(CONF_FILE ${CACHED_CONF_FILE})
elseif(DEFINED ENV{CONF_FILE})
set(CONF_FILE $ENV{CONF_FILE})
elseif(EXISTS ${APPLICATION_CONFIG_DIR}/prj_${BOARD}.conf)
set(CONF_FILE ${APPLICATION_CONFIG_DIR}/prj_${BOARD}.conf)
@ -91,6 +89,7 @@ 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)
zephyr_get(DTC_OVERLAY_FILE)
if(DTC_OVERLAY_FILE)
# DTC_OVERLAY_FILE has either been specified on the cmake CLI or is already
# in the CMakeCache.txt.

View file

@ -72,6 +72,7 @@ if(CONF_FILE)
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE}")
endif()
zephyr_get(OVERLAY_CONFIG)
if(OVERLAY_CONFIG)
string(REPLACE " " ";" OVERLAY_CONFIG_AS_LIST "${OVERLAY_CONFIG}")
endif()

View file

@ -31,18 +31,12 @@ include(python)
# Settings used by Zephyr module but where systems may define an alternative value.
set_ifndef(KCONFIG_BINARY_DIR ${CMAKE_BINARY_DIR}/Kconfig)
if(ZEPHYR_EXTRA_MODULES)
# ZEPHYR_EXTRA_MODULES has either been specified on the cmake CLI or is
# already in the CMakeCache.txt. This has precedence over the environment
# variable ZEPHYR_EXTRA_MODULES
elseif(DEFINED ENV{ZEPHYR_EXTRA_MODULES})
set(ZEPHYR_EXTRA_MODULES $ENV{ZEPHYR_EXTRA_MODULES})
endif()
zephyr_get(ZEPHYR_MODULES)
if(ZEPHYR_MODULES)
set(ZEPHYR_MODULES_ARG "--modules" ${ZEPHYR_MODULES})
endif()
zephyr_get(ZEPHYR_EXTRA_MODULES)
if(ZEPHYR_EXTRA_MODULES)
set(ZEPHYR_EXTRA_MODULES_ARG "--extra-modules" ${ZEPHYR_EXTRA_MODULES})
endif()