NCS: Select pm_static.yml dependent on Config

I have two project configurations one for debug and one for release. Dependent on configuration I want to select pm_static_board.yml or use default flash layout.

For this I created Kconfig file and added new config:

source "Kconfig.zephyr"

config BUILD_CONFIGURATION_PRODUCT_DEBUG
	bool "Select MCU Flash Layout for Debug / Release"

In CMakeLists.tx added the following:

if(NOT CONFIG_BUILD_CONFIGURATION_PRODUCT_DEBUG)
  set(PM_STATIC_YML_FILE
    ${CMAKE_CURRENT_SOURCE_DIR}/boards/pm_static_${BOARD}.yml
    )
endif()

And in corresponding prj.conf I set or reset CONFIG_BUILD_CONFIGURATION_PRODUCT_DEBUG.

However seems that pm_static is added independent on config. If I comment out changes in CMakeLists.txt then pm_static is not added.

Related