diff --git a/cmake/modules/configuration_files.cmake b/cmake/modules/configuration_files.cmake index 2bd843a0d8d..84af8c5b635 100644 --- a/cmake/modules/configuration_files.cmake +++ b/cmake/modules/configuration_files.cmake @@ -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.\ diff --git a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake index 6d55e8c8997..f3079d4ce57 100644 --- a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake @@ -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)