SDL_image: cmake: enable aom-av1 encoding + disable aom-av1 decoding + set CMAKE_SYSTEM_PROCESSOR

From 0fb22b9922608e98f20c78132066559d21d71362 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 26 Jan 2024 00:28:26 +0100
Subject: [PATCH] cmake: enable aom-av1 encoding + disable aom-av1 decoding +
 set CMAKE_SYSTEM_PROCESSOR

---
 CMakeLists.txt | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47bc2625..c37bcf6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -434,6 +434,18 @@ if(SDL3IMAGE_AOM)
         set(ENABLE_TESTDATA OFF CACHE BOOL "")
         set(ENABLE_TESTS OFF CACHE BOOL "")
         set(ENABLE_TOOLS OFF CACHE BOOL "")
+        set(CONFIG_AV1_DECODER 0 CACHE BOOL "" FORCE)
+        set(CONFIG_AV1_ENCODER 1 CACHE BOOL "" FORCE)
+        # aom detects cpu using CMAKE_SYSTEM_NAME
+        if(SDL_CPU_X86)
+          set(CMAKE_SYSTEM_PROCESSOR "x86")
+        elseif(SDL_CPU_X64)
+          set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+        elseif(SDL_CPU_ARM32)
+          set(CMAKE_SYSTEM_PROCESSOR "arm")
+        elseif(SDL_CPU_ARM64)
+          set(CMAKE_SYSTEM_PROCESSOR "aarch64")
+        endif()
         add_subdirectory(external/aom EXCLUDE_FROM_ALL)
         set(AOM_LIBRARY aom)
         if(SDL3IMAGE_AOM_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS)
@@ -457,7 +469,7 @@ if(SDL3IMAGE_AVIF)
         set(AVIF_CODEC_AOM ON CACHE BOOL "Use aom codec for decoding" FORCE)
         set(AVIF_LOCAL_AOM OFF CACHE BOOL "Build aom by libavif" FORCE)
         set(AVIF_CODEC_AOM_ENCODE ON CACHE BOOL "Enable aom encoder" FORCE)
-        set(AVIF_CODEC_AOM_DECODE OFF CACHE BOOL "Disable aom decoder" FORCE)
+        set(AVIF_CODEC_AOM_DECODE OFF CACHE BOOL "Enable aom decoder" FORCE)
         set(LIBAVIF_WITH_SHARPYUV_SDLIMAGE ${SDL3IMAGE_WEBP} CACHE BOOL "Build libavif with sharpyuv support (re-use sharpyuv built by libwebp)" FORCE)
         set(BUILD_SHARED_LIBS ${SDL3IMAGE_AVIF_SHARED})
         set(AOM_LIBRARIES "aom" CACHE STRING "aom libraries" FORCE)