cmake: zephyr_file() now accepts BOARD and BOARD_REVISION as argument

With the introduction of #32556 changing the BOARD now prints a warning.

Zephyr provides `zephyr_file()` to look up overlays and Kconfig
fragments for a specified board, and it used to be possible and safe to
do:
```
function(my_func)
  set(BOARD <local_scope_board>)
  zephyr_file(CONF_FILES ...)
endfunction(my_func)
```

As the BOARD inside `my_func` is locally scoped, this is safe to do.
But with introduction of #32556 a warning is now printed when running
CMake.

Therefore `zephyr_file` has been extended to allow for optional BOARD
and BOARD_REVISION arguments.
If BOARD is not given as argument the current BOARD in the build system
will be used.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake
index 655600b..60bb69d 100644
--- a/cmake/extensions.cmake
+++ b/cmake/extensions.cmake
@@ -1874,6 +1874,13 @@
 #                    The conf file search will return existing configuration
 #                    files for the current board.
 #                    CONF_FILES takes the following additional arguments:
+#                    BOARD <board>:             Find configuration files for specified board.
+#                    BOARD_REVISION <revision>: Find configuration files for specified board
+#                                               revision. Requires BOARD to be specified.
+#
+#                                               If no board is given the current BOARD and
+#                                               BOARD_REVISION will be used.
+#
 #                    DTS <list>:   List to populate with DTS overlay files
 #                    KCONF <list>: List to populate with Kconfig fragment files
 #                    BUILD <type>: Build type to include for search.
@@ -1892,7 +1899,7 @@
   if(${ARGV0} STREQUAL APPLICATION_ROOT)
     set(single_args APPLICATION_ROOT)
   elseif(${ARGV0} STREQUAL CONF_FILES)
-    set(single_args CONF_FILES DTS KCONF BUILD)
+    set(single_args CONF_FILES BOARD BOARD_REVISION DTS KCONF BUILD)
   endif()
 
   cmake_parse_arguments(FILE "" "${single_args}" "" ${ARGN})
@@ -1937,10 +1944,26 @@
   endif()
 
   if(FILE_CONF_FILES)
-    set(FILENAMES ${BOARD})
+    if(DEFINED FILE_BOARD_REVISION AND NOT FILE_BOARD)
+        message(FATAL_ERROR
+          "zephyr_file(${ARGV0} <path> BOARD_REVISION ${FILE_BOARD_REVISION} ...)"
+          " given without BOARD argument, please specify BOARD"
+        )
+    endif()
 
-    if(DEFINED BOARD_REVISION)
-      list(APPEND FILENAMES "${BOARD}_${BOARD_REVISION_STRING}")
+    if(NOT DEFINED FILE_BOARD)
+      # Defaulting to system wide settings when BOARD is not given as argument
+      set(FILE_BOARD ${BOARD})
+      if(DEFINED BOARD_REVISION)
+        set(FILE_BOARD_REVISION ${BOARD_REVISION})
+      endif()
+    endif()
+
+    set(FILENAMES ${FILE_BOARD})
+
+    if(DEFINED FILE_BOARD_REVISION)
+      string(REPLACE "." "_" revision_string ${FILE_BOARD_REVISION})
+      list(APPEND FILENAMES "${FILE_BOARD}_${revision_string}")
     endif()
 
     if(FILE_DTS)