summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt126
1 files changed, 86 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f91ba950a..f5ef0ef50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modul
include(DownloadExternals)
include(CMakeDependentOption)
include(CTest)
+include(FetchContent)
# Set bundled sdl2/qt as dependent options.
# OFF by default, but if ENABLE_SDL2 and MSVC are true then ON
@@ -19,7 +20,7 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON
# On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion
CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF)
-option(ENABLE_LIBUSB "Enable the use of LibUSB" ON)
+cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF)
option(ENABLE_OPENGL "Enable OpenGL" ON)
mark_as_advanced(FORCE ENABLE_OPENGL)
@@ -48,7 +49,7 @@ option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
-option(YUZU_ROOM "Compile LDN room server" ON)
+cmake_dependent_option(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
@@ -56,15 +57,82 @@ option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON)
+option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF)
+
+option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" OFF)
+
CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
+# On Android, fetch and compile libcxx before doing anything else
+if (ANDROID)
+ set(CMAKE_SKIP_INSTALL_RULES ON)
+ set(LLVM_VERSION "15.0.6")
+
+ # Note: even though libcxx and libcxxabi have separate releases on the project page,
+ # the separated releases cannot be compiled. Only in-tree builds work. Therefore we
+ # must fetch the source release for the entire llvm tree.
+ FetchContent_Declare(llvm
+ URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/llvm-project-${LLVM_VERSION}.src.tar.xz"
+ URL_HASH SHA256=9d53ad04dc60cb7b30e810faf64c5ab8157dadef46c8766f67f286238256ff92
+ TLS_VERIFY TRUE
+ )
+ FetchContent_MakeAvailable(llvm)
+
+ # libcxx has support for most of the range library, but it's gated behind a flag:
+ add_compile_definitions(_LIBCPP_ENABLE_EXPERIMENTAL)
+
+ # Disable standard header inclusion
+ set(ANDROID_STL "none")
+
+ # libcxxabi
+ set(LIBCXXABI_INCLUDE_TESTS OFF)
+ set(LIBCXXABI_ENABLE_SHARED FALSE)
+ set(LIBCXXABI_ENABLE_STATIC TRUE)
+ set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXX_TARGET_INCLUDE_DIRECTORY}" CACHE STRING "" FORCE)
+ add_subdirectory("${llvm_SOURCE_DIR}/libcxxabi" "${llvm_BINARY_DIR}/libcxxabi")
+ link_libraries(cxxabi_static)
+
+ # libcxx
+ set(LIBCXX_ABI_NAMESPACE "__ndk1" CACHE STRING "" FORCE)
+ set(LIBCXX_CXX_ABI "libcxxabi")
+ set(LIBCXX_INCLUDE_TESTS OFF)
+ set(LIBCXX_INCLUDE_BENCHMARKS OFF)
+ set(LIBCXX_INCLUDE_DOCS OFF)
+ set(LIBCXX_ENABLE_SHARED FALSE)
+ set(LIBCXX_ENABLE_STATIC TRUE)
+ set(LIBCXX_ENABLE_ASSERTIONS FALSE)
+ add_subdirectory("${llvm_SOURCE_DIR}/libcxx" "${llvm_BINARY_DIR}/libcxx")
+ set_target_properties(cxx-headers PROPERTIES INTERFACE_COMPILE_OPTIONS "-isystem${CMAKE_BINARY_DIR}/${LIBCXX_INSTALL_INCLUDE_DIR}")
+ link_libraries(cxx_static cxx-headers)
+endif()
+
if (YUZU_USE_BUNDLED_VCPKG)
+ if (ANDROID)
+ set(ENV{ANDROID_NDK_HOME} "${ANDROID_NDK}")
+ list(APPEND VCPKG_MANIFEST_FEATURES "android")
+
+ if (CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a")
+ set(VCPKG_TARGET_TRIPLET "arm64-android")
+ # this is to avoid CMake using the host pkg-config to find the host
+ # libraries when building for Android targets
+ set(PKG_CONFIG_EXECUTABLE "aarch64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE)
+ elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
+ set(VCPKG_TARGET_TRIPLET "x64-android")
+ set(PKG_CONFIG_EXECUTABLE "x86_64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE)
+ else()
+ message(FATAL_ERROR "Unsupported Android architecture ${CMAKE_ANDROID_ARCH_ABI}")
+ endif()
+ endif()
+
if (YUZU_TESTS)
list(APPEND VCPKG_MANIFEST_FEATURES "yuzu-tests")
endif()
if (YUZU_CRASH_DUMPS)
list(APPEND VCPKG_MANIFEST_FEATURES "dbghelp")
endif()
+ if (ENABLE_WEB_SERVICE)
+ list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
+ endif()
include(${CMAKE_SOURCE_DIR}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake)
elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "")
@@ -189,7 +257,7 @@ endif()
# boost asio's concept usage doesn't play nicely with some compilers yet.
add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
if (MSVC)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++20>)
# boost still makes use of deprecated result_of.
add_definitions(-D_HAS_DEPRECATED_RESULT_OF)
@@ -205,9 +273,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# =======================================================================
# Enforce the search mode of non-required packages for better and shorter failure messages
+find_package(Boost 1.79.0 REQUIRED context)
find_package(enet 1.3 MODULE)
find_package(fmt 9 REQUIRED)
-find_package(inih MODULE)
+find_package(inih 52 MODULE COMPONENTS INIReader)
+find_package(LLVM MODULE COMPONENTS Demangle)
find_package(lz4 REQUIRED)
find_package(nlohmann_json 3.8 REQUIRED)
find_package(Opus 1.3 MODULE)
@@ -215,7 +285,7 @@ find_package(ZLIB 1.2 REQUIRED)
find_package(zstd 1.5 REQUIRED)
if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS)
- find_package(Vulkan 1.3.238 REQUIRED)
+ find_package(Vulkan 1.3.246 REQUIRED)
endif()
if (ENABLE_LIBUSB)
@@ -240,26 +310,13 @@ endif()
if (ENABLE_WEB_SERVICE)
find_package(cpp-jwt 1.4 CONFIG)
- find_package(httplib 0.11 MODULE)
+ find_package(httplib 0.12 MODULE COMPONENTS OpenSSL)
endif()
if (YUZU_TESTS)
find_package(Catch2 3.0.1 REQUIRED)
endif()
-find_package(Boost 1.73.0 COMPONENTS context)
-if (Boost_FOUND)
- set(Boost_LIBRARIES Boost::boost)
- # Conditionally add Boost::context only if the found Boost package provides it
- # The old version is missing Boost::context, so we want to avoid adding in that case
- # The new version requires adding Boost::context to prevent linking issues
- if (TARGET Boost::context)
- list(APPEND Boost_LIBRARIES Boost::context)
- endif()
-else()
- message(FATAL_ERROR "Boost 1.73.0 or newer not found")
-endif()
-
# boost:asio has functions that require AcceptEx et al
if (MINGW)
find_library(MSWSOCK_LIBRARY mswsock REQUIRED)
@@ -350,12 +407,12 @@ if(ENABLE_QT)
find_package(PkgConfig REQUIRED)
pkg_check_modules(QT_DEP_GLU QUIET glu>=9.0.0)
if (NOT QT_DEP_GLU_FOUND)
- message(FATAL_ERROR "Qt bundled pacakge dependency `glu` not found. \
+ message(FATAL_ERROR "Qt bundled package dependency `glu` not found. \
Perhaps `libglu1-mesa-dev` needs to be installed?")
endif()
pkg_check_modules(QT_DEP_MESA QUIET dri>=20.0.8)
if (NOT QT_DEP_MESA_FOUND)
- message(FATAL_ERROR "Qt bundled pacakge dependency `dri` not found. \
+ message(FATAL_ERROR "Qt bundled package dependency `dri` not found. \
Perhaps `mesa-common-dev` needs to be installed?")
endif()
@@ -432,7 +489,7 @@ if (ENABLE_SDL2)
if (YUZU_USE_BUNDLED_SDL2)
# Detect toolchain and platform
if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64)
- set(SDL2_VER "SDL2-2.0.18")
+ set(SDL2_VER "SDL2-2.28.0")
else()
message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable YUZU_USE_BUNDLED_SDL2 and provide your own.")
endif()
@@ -452,25 +509,18 @@ if (ENABLE_SDL2)
elseif (YUZU_USE_EXTERNAL_SDL2)
message(STATUS "Using SDL2 from externals.")
else()
- find_package(SDL2 2.0.18 REQUIRED)
+ find_package(SDL2 2.26.4 REQUIRED)
endif()
endif()
-# Reexport some targets that are named differently when using the upstream CmakeConfig
-# In order to ALIAS targets to a new name, they first need to be IMPORTED_GLOBAL
-# Dynarmic checks for target `boost` and so we want to make sure it can find it through our system instead of using their external
-if (TARGET Boost::boost)
- set_target_properties(Boost::boost PROPERTIES IMPORTED_GLOBAL TRUE)
- add_library(boost ALIAS Boost::boost)
-endif()
-
# List of all FFmpeg components required
set(FFmpeg_COMPONENTS
avcodec
+ avfilter
avutil
swscale)
-if (UNIX AND NOT APPLE)
+if (UNIX AND NOT APPLE AND NOT ANDROID)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBVA libva)
endif()
@@ -491,8 +541,8 @@ if (APPLE)
find_library(COCOA_LIBRARY Cocoa)
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
elseif (WIN32)
- # WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista)
- add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600)
+ # Target Windows 10
+ add_definitions(-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi)
if (MINGW)
# PSAPI is the Process Status API
@@ -513,7 +563,7 @@ endif()
# against all the src files. This should be used before making a pull request.
# =======================================================================
-set(CLANG_FORMAT_POSTFIX "-12")
+set(CLANG_FORMAT_POSTFIX "-15")
find_program(CLANG_FORMAT
NAMES clang-format${CLANG_FORMAT_POSTFIX}
clang-format
@@ -579,11 +629,7 @@ function(create_target_directory_groups target_name)
endfunction()
# Prevent boost from linking against libs when building
-add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY
- -DBOOST_SYSTEM_NO_LIB
- -DBOOST_DATE_TIME_NO_LIB
- -DBOOST_REGEX_NO_LIB
-)
+target_link_libraries(Boost::headers INTERFACE Boost::disable_autolinking)
# Adjustments for MSVC + Ninja
if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options(