From 5ff19890e9d2a07d1c0246f3807cdefcb36aca7d Mon Sep 17 00:00:00 2001
From: lat9nq <22451773+lat9nq@users.noreply.github.com>
Date: Thu, 1 Dec 2022 00:49:58 -0500
Subject: [PATCH 1/2] CMake: Fix FFmpeg find module

Uses find_package_handle_standard_args to handle the find_package call
from the root CMakeLists. Removes all the unnecessary logic after the
find_package and just sets it to REQUIRED.
---
 CMakeLists.txt                          | 17 +----------------
 externals/find-modules/FindFFmpeg.cmake |  8 ++++++++
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05bffe68e..b2fbe8806 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -458,22 +458,7 @@ if (UNIX AND NOT APPLE)
 endif()
 if (NOT YUZU_USE_BUNDLED_FFMPEG)
     # Use system installed FFmpeg
-    find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS})
-
-    if (FFmpeg_FOUND)
-        # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries.
-        # Prevents shipping too many libraries with the AppImage.
-        set(FFmpeg_LIBRARIES "")
-        set(FFmpeg_INCLUDE_DIR "")
-
-        foreach(COMPONENT ${FFmpeg_COMPONENTS})
-            set(FFmpeg_LIBRARIES ${FFmpeg_LIBRARIES} ${FFmpeg_LIBRARY_${COMPONENT}} CACHE PATH "Paths to FFmpeg libraries" FORCE)
-            set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE)
-        endforeach()
-    else()
-        message(WARNING "FFmpeg not found or too old, falling back to externals")
-        set(YUZU_USE_BUNDLED_FFMPEG ON)
-    endif()
+    find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS})
 endif()
 
 # Prefer the -pthread flag on Linux.
diff --git a/externals/find-modules/FindFFmpeg.cmake b/externals/find-modules/FindFFmpeg.cmake
index add5b2c01..eedf28aea 100644
--- a/externals/find-modules/FindFFmpeg.cmake
+++ b/externals/find-modules/FindFFmpeg.cmake
@@ -185,3 +185,11 @@ foreach(c ${_FFmpeg_ALL_COMPONENTS})
 endforeach()
 unset(_FFmpeg_ALL_COMPONENTS)
 unset(_FFmpeg_REQUIRED_VARS)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FFmpeg
+  REQUIRED_VARS
+    FFmpeg_LIBRARIES
+    FFmpeg_INCLUDE_DIR
+  HANDLE_COMPONENTS
+)

From e67b829cc7eddaaae5b2c4221680e1b4c157259d Mon Sep 17 00:00:00 2001
From: lat9nq <22451773+lat9nq@users.noreply.github.com>
Date: Thu, 1 Dec 2022 01:09:05 -0500
Subject: [PATCH 2/2] ci/clang: Enable bundled FFmpeg

Explicitly use the bundled FFmpeg version, since we were auto-choosing
it before.
---
 .ci/scripts/clang/docker.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.ci/scripts/clang/docker.sh b/.ci/scripts/clang/docker.sh
index 792ef4aa8..7d3ae4a1a 100755
--- a/.ci/scripts/clang/docker.sh
+++ b/.ci/scripts/clang/docker.sh
@@ -19,6 +19,7 @@ cmake .. \
       -DENABLE_QT_TRANSLATION=ON \
       -DUSE_DISCORD_PRESENCE=ON \
       -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
+      -DYUZU_USE_BUNDLED_FFMPEG=ON \
       -GNinja
 
 ninja