mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-26 05:06:43 +00:00
Build: Automagically handle unicorn
On MSVC if unicorn isn't found, fallback to bundled unicorn On everything else, fallback to building unicorn in externals Also fixes loading unicorn in msvc
This commit is contained in:
parent
b5b0d4e7c3
commit
2d7a85f7af
|
@ -12,8 +12,6 @@ option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
|
||||||
option(ENABLE_QT "Enable the Qt frontend" ON)
|
option(ENABLE_QT "Enable the Qt frontend" ON)
|
||||||
option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
|
option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
|
||||||
|
|
||||||
option(YUZU_USE_BUNDLED_UNICORN "Download bundled Unicorn binaries" OFF)
|
|
||||||
|
|
||||||
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
|
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
|
||||||
message(STATUS "Copying pre-commit hook")
|
message(STATUS "Copying pre-commit hook")
|
||||||
file(COPY hooks/pre-commit
|
file(COPY hooks/pre-commit
|
||||||
|
@ -29,7 +27,7 @@ function(check_submodules_present)
|
||||||
foreach(module ${gitmodules})
|
foreach(module ${gitmodules})
|
||||||
string(REGEX REPLACE "path *= *" "" module ${module})
|
string(REGEX REPLACE "path *= *" "" module ${module})
|
||||||
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/${module}/.git")
|
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/${module}/.git")
|
||||||
message(SEND_ERROR "Git submodule ${module} not found."
|
message(FATAL_ERROR "Git submodule ${module} not found. "
|
||||||
"Please run: git submodule update --init --recursive")
|
"Please run: git submodule update --init --recursive")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -204,7 +202,11 @@ else()
|
||||||
set(SDL2_FOUND NO)
|
set(SDL2_FOUND NO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_USE_BUNDLED_UNICORN)
|
# If unicorn isn't found, msvc -> download bundled unicorn; everyone else -> build external
|
||||||
|
find_package(Unicorn QUIET)
|
||||||
|
if (NOT UNICORN_FOUND)
|
||||||
|
if (MSVC)
|
||||||
|
message(STATUS "unicorn not found, falling back to bundled")
|
||||||
# Detect toolchain and platform
|
# Detect toolchain and platform
|
||||||
if (MSVC14 AND ARCHITECTURE_x86_64)
|
if (MSVC14 AND ARCHITECTURE_x86_64)
|
||||||
set(UNICORN_VER "unicorn-yuzu")
|
set(UNICORN_VER "unicorn-yuzu")
|
||||||
|
@ -221,13 +223,12 @@ if (YUZU_USE_BUNDLED_UNICORN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(UNICORN_FOUND YES)
|
set(UNICORN_FOUND YES)
|
||||||
set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers")
|
set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers" FORCE)
|
||||||
set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/lib/x64/unicorn_dynload.lib" CACHE PATH "Path to Unicorn library")
|
set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/lib/x64/unicorn_dynload.lib" CACHE PATH "Path to Unicorn library" FORCE)
|
||||||
set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/lib/x64/" CACHE PATH "Path to unicorn.dll")
|
set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/lib/x64/" CACHE PATH "Path to unicorn.dll" FORCE)
|
||||||
elseif (YUZU_BUILD_UNICORN)
|
else()
|
||||||
if (MSVC)
|
message(STATUS "unicorn not found, falling back to externals")
|
||||||
message(FATAL_ERROR "Cannot build unicorn on msvc. Use YUZU_USE_BUNDLED_UNICORN instead")
|
if (MINGW)
|
||||||
elseif (MINGW)
|
|
||||||
set(UNICORN_LIB_NAME "unicorn.a")
|
set(UNICORN_LIB_NAME "unicorn.a")
|
||||||
else()
|
else()
|
||||||
set(UNICORN_LIB_NAME "libunicorn.a")
|
set(UNICORN_LIB_NAME "libunicorn.a")
|
||||||
|
@ -235,28 +236,29 @@ elseif (YUZU_BUILD_UNICORN)
|
||||||
|
|
||||||
set(UNICORN_FOUND YES)
|
set(UNICORN_FOUND YES)
|
||||||
set(UNICORN_PREFIX ${CMAKE_SOURCE_DIR}/externals/unicorn)
|
set(UNICORN_PREFIX ${CMAKE_SOURCE_DIR}/externals/unicorn)
|
||||||
set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/${UNICORN_LIB_NAME}" CACHE PATH "Path to Unicorn library")
|
set(LIBUNICORN_LIBRARY "${UNICORN_PREFIX}/${UNICORN_LIB_NAME}" CACHE PATH "Path to Unicorn library" FORCE)
|
||||||
set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers")
|
set(LIBUNICORN_INCLUDE_DIR "${UNICORN_PREFIX}/include" CACHE PATH "Path to Unicorn headers" FORCE)
|
||||||
set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/" CACHE PATH "Path to unicorn dynamic library")
|
set(UNICORN_DLL_DIR "${UNICORN_PREFIX}/" CACHE PATH "Path to unicorn dynamic library" FORCE)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${LIBUNICORN_LIBRARY}
|
add_custom_command(OUTPUT ${LIBUNICORN_LIBRARY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" /bin/sh make.sh
|
COMMAND ${CMAKE_COMMAND} -E env UNICORN_ARCHS="aarch64" /bin/sh make.sh
|
||||||
WORKING_DIRECTORY ${UNICORN_PREFIX}
|
WORKING_DIRECTORY ${UNICORN_PREFIX}
|
||||||
)
|
)
|
||||||
# ALL makes this custom target build every time
|
# ALL makes this custom target build every time
|
||||||
# but it won't actually build if LIBUNICORN_LIBRARY exists
|
# but it won't actually build if LIBUNICORN_LIBRARY is up to date
|
||||||
add_custom_target(unicorn-build ALL
|
add_custom_target(unicorn-build ALL
|
||||||
DEPENDS ${LIBUNICORN_LIBRARY}
|
DEPENDS ${LIBUNICORN_LIBRARY}
|
||||||
)
|
)
|
||||||
unset(UNICORN_LIB_NAME)
|
unset(UNICORN_LIB_NAME)
|
||||||
else()
|
endif()
|
||||||
find_package(Unicorn REQUIRED)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNICORN_FOUND)
|
if (UNICORN_FOUND)
|
||||||
add_library(unicorn INTERFACE)
|
add_library(unicorn INTERFACE)
|
||||||
target_link_libraries(unicorn INTERFACE "${LIBUNICORN_LIBRARY}")
|
target_link_libraries(unicorn INTERFACE "${LIBUNICORN_LIBRARY}")
|
||||||
target_include_directories(unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}")
|
target_include_directories(unicorn INTERFACE "${LIBUNICORN_INCLUDE_DIR}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Could not find or build unicorn which is required.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_QT)
|
if (ENABLE_QT)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "core/hle/kernel/svc.h"
|
#include "core/hle/kernel/svc.h"
|
||||||
|
|
||||||
// Load Unicorn DLL once on Windows using RAII
|
// Load Unicorn DLL once on Windows using RAII
|
||||||
#ifdef MSVC
|
#ifdef _MSC_VER
|
||||||
#include <unicorn_dynload.h>
|
#include <unicorn_dynload.h>
|
||||||
struct LoadDll {
|
struct LoadDll {
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue