From a36d2b942bcbab6d8ca5afdcff21b291507f2932 Mon Sep 17 00:00:00 2001
From: lat9nq <22451773+lat9nq@users.noreply.github.com>
Date: Thu, 15 Jul 2021 05:14:01 -0400
Subject: [PATCH 1/2] cmake: Only use NO_CMAKE_SYSTEM_PATH when needed for Qt

As-is causes issues with building yuzu using MinGW GCC on Linux-based
machines. Only set the variable when needed. (I'm not quite sure how
this was working before.)
---
 CMakeLists.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 716256cd56..bf6ba58ba4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,6 +337,8 @@ if(ENABLE_QT)
         endif()
     endif()
 
+    set(YUZU_QT_NO_CMAKE_SYSTEM_PATH)
+
     # Workaround for an issue where conan tries to build Qt from scratch instead of download prebuilt binaries
     set(QT_PREFIX_HINT)
 
@@ -354,8 +356,10 @@ if(ENABLE_QT)
         endif()
 
         set(QT_PREFIX_HINT HINTS "${QT_PREFIX}")
+
+        set(YUZU_QT_NO_CMAKE_SYSTEM_PATH "NO_CMAKE_SYSTEM_PATH")
     endif()
-    find_package(Qt5 ${QT_VERSION} REQUIRED COMPONENTS Widgets ${QT_PREFIX_HINT} NO_CMAKE_SYSTEM_PATH)
+    find_package(Qt5 ${QT_VERSION} REQUIRED COMPONENTS Widgets ${QT_PREFIX_HINT} ${YUZU_QT_NO_CMAKE_SYSTEM_PATH})
     if (YUZU_USE_QT_WEB_ENGINE)
         find_package(Qt5 COMPONENTS WebEngineCore WebEngineWidgets)
     endif()

From 4c6cc675201c1a17d674b7910233a1d8eb474077 Mon Sep 17 00:00:00 2001
From: lat9nq <22451773+lat9nq@users.noreply.github.com>
Date: Thu, 15 Jul 2021 05:25:00 -0400
Subject: [PATCH 2/2] cmake: Only search for Qt when we need to

When YUZU_USE_BUNDLED_QT was specified on a system with a compliant Qt
version installed, CMake configuration would cause an error due to
mixing YUZU_USE_BUNDLED_QT with the system Qt.

Solution is to only search for Qt when YUZU_USE_BUNDLED_QT is disabled.
---
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf6ba58ba4..de93ca2c2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -254,7 +254,9 @@ if(ENABLE_QT)
 
     # Check for system Qt on Linux, fallback to bundled Qt
     if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-        find_package(Qt5 ${QT_VERSION} COMPONENTS Widgets)
+        if (NOT YUZU_USE_BUNDLED_QT)
+            find_package(Qt5 ${QT_VERSION} COMPONENTS Widgets)
+        endif()
         if (NOT Qt5_FOUND OR YUZU_USE_BUNDLED_QT)
             # Check for dependencies, then enable bundled Qt download