cmake: use zephyr_get() and zephyr_file() for APPLICATION_CONFIG_DIR
Fixes: #73065 Update APPLICATION_CONFIG_DIR is Zephyr CMake and sysbuild to follow the common principle in Zephyr for relative paths. This means that relative paths are taken from the application source directory when specified on command line, and require local scoped defined APPLICATION_CONFIG_DIR to be given as absolute, for example by using CMAKE_CURRENT_LIST_DIR. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
4f82f40c00
commit
f7d2cc2d43
2 changed files with 16 additions and 28 deletions
|
@ -30,17 +30,10 @@ include(extensions)
|
|||
# Merge in variables from other sources (e.g. sysbuild)
|
||||
zephyr_get(FILE_SUFFIX SYSBUILD GLOBAL)
|
||||
|
||||
zephyr_get(APPLICATION_CONFIG_DIR)
|
||||
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()
|
||||
zephyr_get(APPLICATION_CONFIG_DIR SYSBUILD GLOBAL)
|
||||
zephyr_file(APPLICATION_ROOT APPLICATION_CONFIG_DIR)
|
||||
set_ifndef(APPLICATION_CONFIG_DIR ${APPLICATION_SOURCE_DIR})
|
||||
string(CONFIGURE ${APPLICATION_CONFIG_DIR} APPLICATION_CONFIG_DIR)
|
||||
|
||||
zephyr_get(CONF_FILE SYSBUILD LOCAL)
|
||||
if(NOT DEFINED CONF_FILE)
|
||||
|
@ -63,7 +56,7 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
set(APPLICATION_CONFIG_DIR ${APPLICATION_CONFIG_DIR} CACHE INTERNAL "The application configuration folder" FORCE)
|
||||
set(APPLICATION_CONFIG_DIR ${APPLICATION_CONFIG_DIR} CACHE PATH "The application configuration folder" FORCE)
|
||||
set(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.\
|
||||
|
|
|
@ -13,28 +13,23 @@ set(EXTRA_KCONFIG_TARGET_COMMAND_FOR_sysbuild_guiconfig
|
|||
set(KCONFIG_TARGETS sysbuild_menuconfig sysbuild_guiconfig)
|
||||
list(TRANSFORM EXTRA_KCONFIG_TARGETS PREPEND "sysbuild_")
|
||||
|
||||
if(DEFINED APPLICATION_CONFIG_DIR AND NOT DEFINED CACHE{APPLICATION_CONFIG_DIR})
|
||||
set(APPLICATION_CONFIG_DIR "${APPLICATION_CONFIG_DIR}" CACHE INTERNAL "Application config dir")
|
||||
elseif(DEFINED CACHE{APPLICATION_CONFIG_DIR} AND
|
||||
NOT (APPLICATION_CONFIG_DIR STREQUAL "$CACHE{APPLICATION_CONFIG_DIR}"))
|
||||
message(WARNING
|
||||
"Sysbuild scoped APPLICATION_CONFIG_DIR and cached APPLICATION_CONFIG_DIR differs.\n"
|
||||
"Setting value used internally by Sysbuild (sysbuild scoped):\n"
|
||||
" - ${APPLICATION_CONFIG_DIR}\n"
|
||||
"Setting value used by images (cached):\n"
|
||||
" - $CACHE{APPLICATION_CONFIG_DIR}\n"
|
||||
zephyr_get(APPLICATION_CONFIG_DIR)
|
||||
if(DEFINED APPLICATION_CONFIG_DIR)
|
||||
zephyr_file(APPLICATION_ROOT APPLICATION_CONFIG_DIR BASE_DIR ${APP_DIR})
|
||||
|
||||
# Sysbuild must add a locally defined APPLICATION_CONFIG_DIR in sysbuild/CMakeLists.txt
|
||||
# to the cache in order for the setting to propagate to images.
|
||||
set(APPLICATION_CONFIG_DIR ${APPLICATION_CONFIG_DIR} CACHE PATH
|
||||
"Sysbuild adjusted APPLICATION_CONFIG_DIR" FORCE
|
||||
)
|
||||
endif()
|
||||
|
||||
# If there is a dedicated SB_APPLICATION_CONFIG_DIR, then create a local
|
||||
# scoped APPLICATION_CONFIG_DIR hiding any cache variant.
|
||||
# The cache setting is the setting passed to sysbuild image cache files
|
||||
zephyr_get(SB_APPLICATION_CONFIG_DIR)
|
||||
if(DEFINED SB_APPLICATION_CONFIG_DIR)
|
||||
zephyr_file(APPLICATION_ROOT SB_APPLICATION_CONFIG_DIR BASE_DIR ${APP_DIR})
|
||||
set(APPLICATION_CONFIG_DIR ${SB_APPLICATION_CONFIG_DIR})
|
||||
elseif(NOT DEFINED APPLICATION_CONFIG_DIR)
|
||||
get_filename_component(APP_DIR ${APP_DIR} ABSOLUTE)
|
||||
set(APPLICATION_CONFIG_DIR ${APP_DIR})
|
||||
endif()
|
||||
set_ifndef(APPLICATION_CONFIG_DIR ${APP_DIR})
|
||||
string(CONFIGURE ${APPLICATION_CONFIG_DIR} APPLICATION_CONFIG_DIR)
|
||||
|
||||
if(DEFINED SB_CONF_FILE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue