From bba785d643ad05ae11d13c9e9be4cc93650d1a2b Mon Sep 17 00:00:00 2001
From: MerryMage <MerryMage@users.noreply.github.com>
Date: Sun, 21 Jan 2018 13:29:05 +0000
Subject: [PATCH 1/2] CMakeLists: Do not look for system Unicorn by default

Since we use a custom build of unicorn it doesn't make much sense to look for
the system version, unless the user explicitly wants to override this.
---
 CMakeLists.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5dee41abcf..4ecae84b3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,8 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON
 option(ENABLE_QT "Enable the Qt frontend" ON)
 CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" ON "ENABLE_SDL2;MSVC" OFF)
 
+option(YUZU_USE_BUNDLED_UNICORN "Build/Download bundled Unicorn" ON)
+
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
     message(STATUS "Copying pre-commit hook")
     file(COPY hooks/pre-commit
@@ -209,8 +211,7 @@ else()
 endif()
 
 # If unicorn isn't found, msvc -> download bundled unicorn; everyone else -> build external
-find_package(Unicorn QUIET)
-if (NOT UNICORN_FOUND)
+if (YUZU_USE_BUNDLED_UNICORN)
     if (MSVC)
         message(STATUS "unicorn not found, falling back to bundled")
         # Detect toolchain and platform
@@ -259,6 +260,8 @@ if (NOT UNICORN_FOUND)
         )
         unset(UNICORN_LIB_NAME)
     endif()
+else()
+    find_package(Unicorn REQUIRED)
 endif()
 
 if (UNICORN_FOUND)

From add8d40f3f0295f3af5f5f945fcf770ace3eaca3 Mon Sep 17 00:00:00 2001
From: MerryMage <MerryMage@users.noreply.github.com>
Date: Sun, 21 Jan 2018 13:57:14 +0000
Subject: [PATCH 2/2] CMakeLists: Fix unicorn build for macOS developers with
 x86_64-only systems

Some of us do not have any i386 libraries required to build x86-32 universal libraries.
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ecae84b3b..5e904a53fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -250,7 +250,7 @@ if (YUZU_USE_BUNDLED_UNICORN)
         find_package(PythonInterp 2.7 REQUIRED)
 
         add_custom_command(OUTPUT ${LIBUNICORN_LIBRARY}
-            COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" PYTHON="${PYTHON_EXECUTABLE}" /bin/sh make.sh
+            COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" PYTHON="${PYTHON_EXECUTABLE}" /bin/sh make.sh macos-universal-no
             WORKING_DIRECTORY ${UNICORN_PREFIX}
         )
         # ALL makes this custom target build every time