SDL_image: cmake: aom vendoring fixes

From ebe770031a1247e3f5f1918cef264b7f756b2d33 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 25 Jan 2024 20:10:06 +0100
Subject: [PATCH] cmake: aom vendoring fixes

---
 CMakeLists.txt | 19 +++++++++++++++----
 external/aom   |  2 +-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7070e0ad..31a0c5f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -413,7 +413,10 @@ if(SDL3IMAGE_DAV1D)
     if(SDL3IMAGE_DAV1D_VENDORED)
         message(STATUS "${PROJECT_NAME}: Using vendored dav1d")
         set(BUILD_SHARED_LIBS ${SDL3IMAGE_DAV1D_SHARED})
-        add_subdirectory(external/dav1d)
+        add_subdirectory(external/dav1d EXCLUDE_FROM_ALL)
+        if(DAV1D_ASM AND (CHECK_CPU_ARCHITECTURE_X64 OR CHECK_CPU_ARCHITECTURE_X86))
+            enable_language(ASM_NASM)
+        endif()
         set(DAV1D_LIBRARY dav1d)
         if(SDL3IMAGE_DAV1D_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS)
             list(APPEND INSTALL_EXTRA_TARGETS dav1d)
@@ -427,13 +430,18 @@ if(SDL3IMAGE_AOM)
     if(SDL3IMAGE_AOM_VENDORED)
         message(STATUS "${PROJECT_NAME}: Using vendored aom")
         set(BUILD_SHARED_LIBS ${SDL3IMAGE_AOM_SHARED})
-        add_subdirectory(external/aom)
+        set(ENABLE_DOCS OFF CACHE BOOL "")
+        set(ENABLE_EXAMPLES OFF CACHE BOOL "")
+        set(ENABLE_TESTDATA OFF CACHE BOOL "")
+        set(ENABLE_TESTS OFF CACHE BOOL "")
+        set(ENABLE_TOOLS OFF CACHE BOOL "")
+        add_subdirectory(external/aom EXCLUDE_FROM_ALL)
         set(AOM_LIBRARY aom)
         if(SDL3IMAGE_AOM_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS)
             list(APPEND INSTALL_EXTRA_TARGETS aom)
         endif()
     else()
-        message(FATAL_ERROR "Internal error (dav1d is only required when requesting vendored dependencies)")
+        message(FATAL_ERROR "Internal error (aom is only required when requesting vendored dependencies)")
     endif()
 endif()
 
@@ -449,8 +457,11 @@ if(SDL3IMAGE_AVIF)
         set(AVIF_LOCAL_DAV1D OFF CACHE BOOL "Build dav1d by libavif" FORCE)
         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(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)
         add_subdirectory(external/libavif EXCLUDE_FROM_ALL)
         if(SDL3IMAGE_AVIF_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS)
             list(APPEND INSTALL_EXTRA_TARGETS avif)
@@ -461,7 +472,7 @@ if(SDL3IMAGE_AVIF)
             list(APPEND PC_LIBS -l$<TARGET_FILE_BASE_NAME:avif>)
         endif()
         if(NOT MSVC)
-          check_linker_flag(C "-Wl,--no-undefined" LINKER_SUPPORTS_WL_NO_UNDEFINED)
+          sdl_check_linker_flag("-Wl,--no-undefined" LINKER_SUPPORTS_WL_NO_UNDEFINED)
           if(LINKER_SUPPORTS_WL_NO_UNDEFINED)
             target_link_options(avif PRIVATE "-Wl,--no-undefined")
           endif()
diff --git a/external/aom b/external/aom
index 7ade9617..01d1b146 160000
--- a/external/aom
+++ b/external/aom
@@ -1 +1 @@
-Subproject commit 7ade96172b95adc91a5d85bf80c90989cd543ee8
+Subproject commit 01d1b1469555c0163a10e9cb192aabb5a218a4a9