cmake: improve ASM compiler config for arm64 macOS

On arm64 macOS, cmake configuration for aom 3.7.0 hangs indefinitely.
This is due to commit a250c26cade, where `CMAKE_ASM_COMPILER` is
unconditionally set to `as` on arm64 macOS regardless of the user's
settings; later during the `enable_language(ASM)` invocation, the
assembler `/usr/bin/as` is invoked with the argument `-Wl,--help`, but
the argument is ignored:

    $ /usr/bin/as -Wl,--help
    clang: warning: -Wl,--help: 'linker' input unused [-Wunused-command-line-argument]

And, it hangs indefinitely because it expects input from standard input
by default.

A minimal reproducer for this (on x86_64 or arm64 macOS) is to have the
following in `CMakeLists.txt`:

    include(CheckLanguage)
    set(CMAKE_ASM_COMPILER as)
    enable_language(ASM)

And run `cmake -S . -B build --trace`.

We can fix that by setting `CMAKE_ASM_COMPILER` to `CMAKE_C_COMPILER` by
default. This is also consistent with CMake's default behaviour. (Try
commenting the `set(CMAKE_ASM_COMPILER)` line above to check; see also:
[^1].) In addition, if `CMAKE_ASM_COMPILER` is already defined (by, for
example, passing `-DCMAKE_ASM_COMPILER=as` to `cmake`), respect that
configuration.

[^1]: https://github.com/Kitware/CMake/blob/v3.27.0/Modules/CMakeDetermineASMCompiler.cmake

Change-Id: I48c0a0e7d22aeaa310a35155d93706210662a547
Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
(cherry picked from commit ce2e55d0d7efd49706929a36606c60bf53733bfb)
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index aaef2c3..ab9d2bb 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -186,7 +186,9 @@
   string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
 elseif(AOM_TARGET_CPU MATCHES "arm")
   if(AOM_TARGET_SYSTEM STREQUAL "Darwin")
-    set(CMAKE_ASM_COMPILER as)
+    if(NOT CMAKE_ASM_COMPILER)
+      set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
+    endif()
     set(AOM_AS_FLAGS -arch ${AOM_TARGET_CPU} -isysroot ${CMAKE_OSX_SYSROOT})
   elseif(AOM_TARGET_SYSTEM STREQUAL "Windows")
     if(NOT CMAKE_ASM_COMPILER)