aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt87
1 files changed, 73 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa2154cb1..bcd169643 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,14 +3,19 @@ cmake_minimum_required(VERSION 3.6)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
include(DownloadExternals)
+include(CMakeDependentOption)
project(yuzu)
+# Set bundled sdl2/qt as dependent options.
+# OFF by default, but if ENABLE_SDL2 and MSVC are true then ON
option(ENABLE_SDL2 "Enable the SDL2 frontend" ON)
-option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
+CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON "ENABLE_SDL2;MSVC" OFF)
option(ENABLE_QT "Enable the Qt frontend" ON)
-option(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
+CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" ON "ENABLE_QT;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")
@@ -54,15 +59,18 @@ function(detect_architecture symbol arch)
endif()
endfunction()
-if (MSVC)
- detect_architecture("_M_AMD64" x86_64)
- detect_architecture("_M_IX86" x86)
- detect_architecture("_M_ARM" ARM)
-else()
- detect_architecture("__x86_64__" x86_64)
- detect_architecture("__i386__" x86)
- detect_architecture("__arm__" ARM)
+if (NOT ENABLE_GENERIC)
+ if (MSVC)
+ detect_architecture("_M_AMD64" x86_64)
+ detect_architecture("_M_IX86" x86)
+ detect_architecture("_M_ARM" ARM)
+ else()
+ detect_architecture("__x86_64__" x86_64)
+ detect_architecture("__i386__" x86)
+ detect_architecture("__arm__" ARM)
+ endif()
endif()
+
if (NOT DEFINED ARCHITECTURE)
set(ARCHITECTURE "GENERIC")
set(ARCHITECTURE_GENERIC 1)
@@ -152,6 +160,9 @@ set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
+math(EXPR EMU_ARCH_BITS ${CMAKE_SIZEOF_VOID_P}*8)
+add_definitions(-DEMU_ARCH_BITS=${EMU_ARCH_BITS})
+
# System imported libraries
# ======================
@@ -203,8 +214,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
@@ -243,7 +253,7 @@ if (NOT UNICORN_FOUND)
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
@@ -253,6 +263,8 @@ if (NOT UNICORN_FOUND)
)
unset(UNICORN_LIB_NAME)
endif()
+else()
+ find_package(Unicorn REQUIRED)
endif()
if (UNICORN_FOUND)
@@ -316,6 +328,53 @@ if (UNIX OR MINGW)
endif()
endif()
+# Setup a custom clang-format target (if clang-format can be found) that will run
+# against all the src files. This should be used before making a pull request.
+# =======================================================================
+
+set(CLANG_FORMAT_POSTFIX "-6.0")
+find_program(CLANG_FORMAT
+ NAMES clang-format${CLANG_FORMAT_POSTFIX}
+ clang-format
+ PATHS ${CMAKE_BINARY_DIR}/externals)
+# if find_program doesn't find it, try to download from externals
+if (NOT CLANG_FORMAT)
+ if (WIN32)
+ message(STATUS "Clang format not found! Downloading...")
+ set(CLANG_FORMAT "${CMAKE_BINARY_DIR}/externals/clang-format${CLANG_FORMAT_POSTFIX}.exe")
+ file(DOWNLOAD
+ https://github.com/yuzu-emu/ext-windows-bin/raw/master/clang-format${CLANG_FORMAT_POSTFIX}.exe
+ "${CLANG_FORMAT}" SHOW_PROGRESS
+ STATUS DOWNLOAD_SUCCESS)
+ if (NOT DOWNLOAD_SUCCESS EQUAL 0)
+ message(WARNING "Could not download clang format! Disabling the clang format target")
+ file(REMOVE ${CLANG_FORMAT})
+ unset(CLANG_FORMAT)
+ endif()
+ else()
+ message(WARNING "Clang format not found! Disabling the clang format target")
+ endif()
+endif()
+
+if (CLANG_FORMAT)
+ set(SRCS ${CMAKE_SOURCE_DIR}/src)
+ set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
+ if (WIN32)
+ add_custom_target(clang-format
+ COMMAND powershell.exe -Command "${CLANG_FORMAT} -i @(Get-ChildItem -Recurse ${SRCS}/* -Include \'*.h\', \'*.cpp\')"
+ COMMENT ${CCOMMENT})
+ elseif(MINGW)
+ add_custom_target(clang-format
+ COMMAND find `cygpath -u ${SRCS}` -iname *.h -o -iname *.cpp | xargs `cygpath -u ${CLANG_FORMAT}` -i
+ COMMENT ${CCOMMENT})
+ else()
+ add_custom_target(clang-format
+ COMMAND find ${SRCS} -iname *.h -o -iname *.cpp | xargs ${CLANG_FORMAT} -i
+ COMMENT ${CCOMMENT})
+ endif()
+ unset(SRCS)
+ unset(CCOMMENT)
+endif()
# Include source code
# ===================
@@ -367,7 +426,7 @@ if(ENABLE_QT AND UNIX AND NOT APPLE)
install(FILES "${CMAKE_SOURCE_DIR}/dist/yuzu.desktop"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
install(FILES "${CMAKE_SOURCE_DIR}/dist/yuzu.svg"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pixmaps")
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps")
install(FILES "${CMAKE_SOURCE_DIR}/dist/yuzu.xml"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/mime/packages")
endif()