summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt92
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp2
2 files changed, 48 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f1a4d0152..2ec9467e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,6 @@ option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
12option(ENABLE_QT "Enable the Qt frontend" ON) 12option(ENABLE_QT "Enable the Qt frontend" ON)
13option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" OFF) 13option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
14 14
15option(YUZU_USE_BUNDLED_UNICORN "Download bundled Unicorn binaries" OFF)
16
17if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) 15if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
18 message(STATUS "Copying pre-commit hook") 16 message(STATUS "Copying pre-commit hook")
19 file(COPY hooks/pre-commit 17 file(COPY hooks/pre-commit
@@ -29,7 +27,7 @@ function(check_submodules_present)
29 foreach(module ${gitmodules}) 27 foreach(module ${gitmodules})
30 string(REGEX REPLACE "path *= *" "" module ${module}) 28 string(REGEX REPLACE "path *= *" "" module ${module})
31 if (NOT EXISTS "${CMAKE_SOURCE_DIR}/${module}/.git") 29 if (NOT EXISTS "${CMAKE_SOURCE_DIR}/${module}/.git")
32 message(SEND_ERROR "Git submodule ${module} not found." 30 message(FATAL_ERROR "Git submodule ${module} not found. "
33 "Please run: git submodule update --init --recursive") 31 "Please run: git submodule update --init --recursive")
34 endif() 32 endif()
35 endforeach() 33 endforeach()
@@ -204,59 +202,63 @@ else()
204 set(SDL2_FOUND NO) 202 set(SDL2_FOUND NO)
205endif() 203endif()
206 204
207if (YUZU_USE_BUNDLED_UNICORN) 205# If unicorn isn't found, msvc -> download bundled unicorn; everyone else -> build external
208 # Detect toolchain and platform 206find_package(Unicorn QUIET)
209 if (MSVC14 AND ARCHITECTURE_x86_64) 207if (NOT UNICORN_FOUND)
210 set(UNICORN_VER "unicorn-yuzu") 208 if (MSVC)
211 else() 209 message(STATUS "unicorn not found, falling back to bundled")
212 message(FATAL_ERROR "No bundled Unicorn binaries for your toolchain. Disable YUZU_USE_BUNDLED_UNICORN and provide your own.") 210 # Detect toolchain and platform
213 endif() 211 if (MSVC14 AND ARCHITECTURE_x86_64)
212 set(UNICORN_VER "unicorn-yuzu")
213 else()
214 message(FATAL_ERROR "No bundled Unicorn binaries for your toolchain. Disable YUZU_USE_BUNDLED_UNICORN and provide your own.")
215 endif()
214 216
215 if (DEFINED UNICORN_VER) 217 if (DEFINED UNICORN_VER)
216 download_bundled_external("unicorn/" ${UNICORN_VER} UNICORN_PREFIX) 218 download_bundled_external("unicorn/" ${UNICORN_VER} UNICORN_PREFIX)
217 endif() 219 endif()
218 220
219 if (DEFINED UNICORN_VER) 221 if (DEFINED UNICORN_VER)
220 download_bundled_external("unicorn/" ${UNICORN_VER} UNICORN_PREFIX) 222 download_bundled_external("unicorn/" ${UNICORN_VER} UNICORN_PREFIX)
221 endif() 223 endif()
222 224
223 set(UNICORN_FOUND YES) 225 set(UNICORN_FOUND YES)
224 set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers") 226 set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers" FORCE)
225 set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/lib/x64/unicorn_dynload.lib" CACHE PATH "Path to Unicorn library") 227 set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/lib/x64/unicorn_dynload.lib" CACHE PATH "Path to Unicorn library" FORCE)
226 set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/lib/x64/" CACHE PATH "Path to unicorn.dll") 228 set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/lib/x64/" CACHE PATH "Path to unicorn.dll" FORCE)
227elseif (YUZU_BUILD_UNICORN)
228 if (MSVC)
229 message(FATAL_ERROR "Cannot build unicorn on msvc. Use YUZU_USE_BUNDLED_UNICORN instead")
230 elseif (MINGW)
231 set(UNICORN_LIB_NAME "unicorn.a")
232 else() 229 else()
233 set(UNICORN_LIB_NAME "libunicorn.a") 230 message(STATUS "unicorn not found, falling back to externals")
234 endif() 231 if (MINGW)
232 set(UNICORN_LIB_NAME "unicorn.a")
233 else()
234 set(UNICORN_LIB_NAME "libunicorn.a")
235 endif()
235 236
236 set(UNICORN_FOUND YES) 237 set(UNICORN_FOUND YES)
237 set(UNICORN_PREFIX ${CMAKE_SOURCE_DIR}/externals/unicorn) 238 set(UNICORN_PREFIX ${CMAKE_SOURCE_DIR}/externals/unicorn)
238 set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/${UNICORN_LIB_NAME}" CACHE PATH "Path to Unicorn library") 239 set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/${UNICORN_LIB_NAME}" CACHE PATH "Path to Unicorn library" FORCE)
239 set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers") 240 set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers" FORCE)
240 set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/" CACHE PATH "Path to unicorn dynamic library") 241 set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/" CACHE PATH "Path to unicorn dynamic library" FORCE)
241 242
242 add_custom_command(OUTPUT ${LIBUNICORN_LIBRARY} 243 add_custom_command(OUTPUT ${LIBUNICORN_LIBRARY}
243 COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" /bin/sh make.sh 244 COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" /bin/sh make.sh
244 WORKING_DIRECTORY ${UNICORN_PREFIX} 245 WORKING_DIRECTORY ${UNICORN_PREFIX}
245 ) 246 )
246 # ALL makes this custom target build every time 247 # ALL makes this custom target build every time
247 # but it won't actually build if LIBUNICORN_LIBRARY exists 248 # but it won't actually build if LIBUNICORN_LIBRARY is up to date
248 add_custom_target(unicorn-build ALL 249 add_custom_target(unicorn-build ALL
249 DEPENDS ${LIBUNICORN_LIBRARY} 250 DEPENDS ${LIBUNICORN_LIBRARY}
250 ) 251 )
251 unset(UNICORN_LIB_NAME) 252 unset(UNICORN_LIB_NAME)
252else() 253 endif()
253 find_package(Unicorn REQUIRED)
254endif() 254endif()
255 255
256if (UNICORN_FOUND) 256if (UNICORN_FOUND)
257 add_library(unicorn INTERFACE) 257 add_library(unicorn INTERFACE)
258 target_link_libraries(unicorn INTERFACE "${LIBUNICORN_LIBRARY}") 258 target_link_libraries(unicorn INTERFACE "${LIBUNICORN_LIBRARY}")
259 target_include_directories(unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}") 259 target_include_directories(unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}")
260else()
261 message(FATAL_ERROR "Could not find or build unicorn which is required.")
260endif() 262endif()
261 263
262if (ENABLE_QT) 264if (ENABLE_QT)
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 0cd519ea3..fd64eab39 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -11,7 +11,7 @@
11#include "core/hle/kernel/svc.h" 11#include "core/hle/kernel/svc.h"
12 12
13// Load Unicorn DLL once on Windows using RAII 13// Load Unicorn DLL once on Windows using RAII
14#ifdef MSVC 14#ifdef _MSC_VER
15#include <unicorn_dynload.h> 15#include <unicorn_dynload.h>
16struct LoadDll { 16struct LoadDll {
17private: 17private: