Setting KConfig variables in CMakeLists.txt not working with sysbuild

Prior to moving to sysbuild, we were dynamically settings a CONFIG_ variable in our `CMakeLists.txt` based on the board passed to west. And this was working fine.

if(BOARD MATCHES "^ourboard")
  set(CONFIG_MEMFAULT_NCS_HW_VERSION "\"A9.1\"" CACHE INTERNAL "")
elseif(BOARD MATCHES "^nrf9151dk")
  set(CONFIG_MEMFAULT_NCS_HW_VERSION "\"nRF9151DK\"" CACHE INTERNAL "")
else()
  message(FATAL_ERROR "No hardware BOARD has been set for this build.")
endif()
 
After upgrading to nRFSDK 2.9.0 and using sysbuild, this no longer works. In fact, `BOARD` variable isn't even available in `CMakeLists.txt`. I tried replacing that part with `if (1)` but the new values never make it into the `.config` file (although I can see them in the CMakeCache.txt).
One way I found to make this work is to put this into `sysbuild.cmake` but this feels wrong because `CONFIG_MEMFAULT_NCS_HW_VERSION` is only needed in the app image and doesn't need to be available to mcuboot. 
What's the proper way to handle this? Am I missing something?
Thanks,
Konstantin
Related