From 4b11185ae8999f061e77087ecaccb0c5094f3878 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 2 Jan 2023 21:25:29 +0100 Subject: [PATCH] early-access version 3274 --- CMakeLists.txt | 1 - CMakeModules/FindDiscordRPC.cmake | 27 ++++ CMakeModules/FindFFmpeg.cmake | 195 ++++++++++++++++++++++++++++ CMakeModules/FindOpus.cmake | 15 +++ CMakeModules/Findenet.cmake | 16 +++ CMakeModules/Findhttplib.cmake | 21 +++ CMakeModules/Findinih.cmake | 16 +++ CMakeModules/Findlibusb.cmake | 16 +++ CMakeModules/Findlz4.cmake | 26 ++++ CMakeModules/Findzstd.cmake | 26 ++++ CMakeModules/WindowsCopyFiles.cmake | 27 ++++ README.md | 2 +- externals/CMakeLists.txt | 4 - src/dedicated_room/CMakeLists.txt | 2 - src/yuzu/CMakeLists.txt | 1 - src/yuzu_cmd/CMakeLists.txt | 2 - 16 files changed, 386 insertions(+), 11 deletions(-) create mode 100755 CMakeModules/FindDiscordRPC.cmake create mode 100755 CMakeModules/FindFFmpeg.cmake create mode 100755 CMakeModules/FindOpus.cmake create mode 100755 CMakeModules/Findenet.cmake create mode 100755 CMakeModules/Findhttplib.cmake create mode 100755 CMakeModules/Findinih.cmake create mode 100755 CMakeModules/Findlibusb.cmake create mode 100755 CMakeModules/Findlz4.cmake create mode 100755 CMakeModules/Findzstd.cmake create mode 100755 CMakeModules/WindowsCopyFiles.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fb3c8b54..0d368f19c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ cmake_minimum_required(VERSION 3.22) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/find-modules") include(DownloadExternals) include(CMakeDependentOption) diff --git a/CMakeModules/FindDiscordRPC.cmake b/CMakeModules/FindDiscordRPC.cmake new file mode 100755 index 000000000..44ca9904f --- /dev/null +++ b/CMakeModules/FindDiscordRPC.cmake @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_path(DiscordRPC_INCLUDE_DIR discord_rpc.h) + +find_library(DiscordRPC_LIBRARY discord-rpc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(DiscordRPC + REQUIRED_VARS + DiscordRPC_LIBRARY + DiscordRPC_INCLUDE_DIR +) + +if (DiscordRPC_FOUND AND NOT TARGET DiscordRPC::discord-rpc) + add_library(DiscordRPC::discord-rpc UNKNOWN IMPORTED) + set_target_properties(DiscordRPC::discord-rpc PROPERTIES + IMPORTED_LOCATION "${DiscordRPC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${DiscordRPC_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + DiscordRPC_INCLUDE_DIR + DiscordRPC_LIBRARY +) diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/FindFFmpeg.cmake new file mode 100755 index 000000000..eedf28aea --- /dev/null +++ b/CMakeModules/FindFFmpeg.cmake @@ -0,0 +1,195 @@ +# SPDX-FileCopyrightText: 2019 Citra Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +# FindFFmpeg +# ---------- +# +# Find the native FFmpeg includes and libraries +# +# This module defines the following variables: +# +# FFmpeg_INCLUDE_: where to find .h +# FFmpeg_LIBRARY_: where to find the library +# FFmpeg_INCLUDE_DIR: aggregate all the include paths +# FFmpeg_LIBRARIES: aggregate all the paths to the libraries +# FFmpeg_FOUND: True if all components have been found +# +# This module defines the following targets, which are prefered over variables: +# +# FFmpeg::: Target to use directly, with include path, +# library and dependencies set up. If you are using a static build, you are +# responsible for adding any external dependencies (such as zlib, bzlib...). +# +# can be one of: +# avcodec +# avdevice +# avfilter +# avformat +# avutil +# postproc +# swresample +# swscale +# + +set(_FFmpeg_ALL_COMPONENTS + avcodec + avdevice + avfilter + avformat + avutil + postproc + swresample + swscale +) + +set(_FFmpeg_DEPS_avcodec avutil) +set(_FFmpeg_DEPS_avdevice avcodec avformat avutil) +set(_FFmpeg_DEPS_avfilter avutil) +set(_FFmpeg_DEPS_avformat avcodec avutil) +set(_FFmpeg_DEPS_postproc avutil) +set(_FFmpeg_DEPS_swresample avutil) +set(_FFmpeg_DEPS_swscale avutil) + +function(find_ffmpeg LIBNAME) + if(DEFINED ENV{FFMPEG_DIR}) + set(FFMPEG_DIR $ENV{FFMPEG_DIR}) + endif() + + if(FFMPEG_DIR) + list(APPEND INCLUDE_PATHS + ${FFMPEG_DIR} + ${FFMPEG_DIR}/ffmpeg + ${FFMPEG_DIR}/lib${LIBNAME} + ${FFMPEG_DIR}/include/lib${LIBNAME} + ${FFMPEG_DIR}/include/ffmpeg + ${FFMPEG_DIR}/include + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + list(APPEND LIB_PATHS + ${FFMPEG_DIR} + ${FFMPEG_DIR}/lib + ${FFMPEG_DIR}/lib${LIBNAME} + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + else() + list(APPEND INCLUDE_PATHS + /usr/local/include/ffmpeg + /usr/local/include/lib${LIBNAME} + /usr/include/ffmpeg + /usr/include/lib${LIBNAME} + /usr/include/ffmpeg/lib${LIBNAME} + ) + + list(APPEND LIB_PATHS + /usr/local/lib + /usr/lib + ) + endif() + + find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h + HINTS ${INCLUDE_PATHS} + ) + + find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} + HINTS ${LIB_PATHS} + ) + + if(NOT FFMPEG_DIR AND (NOT FFmpeg_LIBRARY_${LIBNAME} OR NOT FFmpeg_INCLUDE_${LIBNAME})) + # Didn't find it in the usual paths, try pkg-config + find_package(PkgConfig QUIET) + pkg_check_modules(FFmpeg_PKGCONFIG_${LIBNAME} QUIET lib${LIBNAME}) + + find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h + ${FFmpeg_PKGCONFIG_${LIBNAME}_INCLUDE_DIRS} + ) + + find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} + ${FFmpeg_PKGCONFIG_${LIBNAME}_LIBRARY_DIRS} + ) + endif() + + if(FFmpeg_INCLUDE_${LIBNAME} AND FFmpeg_LIBRARY_${LIBNAME}) + set(FFmpeg_INCLUDE_${LIBNAME} "${FFmpeg_INCLUDE_${LIBNAME}}" PARENT_SCOPE) + set(FFmpeg_LIBRARY_${LIBNAME} "${FFmpeg_LIBRARY_${LIBNAME}}" PARENT_SCOPE) + + # Extract FFmpeg version from version.h + foreach(v MAJOR MINOR MICRO) + set(FFmpeg_${LIBNAME}_VERSION_${v} 0) + endforeach() + string(TOUPPER ${LIBNAME} LIBNAME_UPPER) + file(STRINGS "${FFmpeg_INCLUDE_${LIBNAME}}/lib${LIBNAME}/version.h" _FFmpeg_VERSION_H_CONTENTS REGEX "#define LIB${LIBNAME_UPPER}_VERSION_(MAJOR|MINOR|MICRO) ") + set(_FFmpeg_VERSION_REGEX "([0-9]+)") + foreach(v MAJOR MINOR MICRO) + if("${_FFmpeg_VERSION_H_CONTENTS}" MATCHES "#define LIB${LIBNAME_UPPER}_VERSION_${v}[\\t ]+${_FFmpeg_VERSION_REGEX}") + set(FFmpeg_${LIBNAME}_VERSION_${v} "${CMAKE_MATCH_1}") + endif() + endforeach() + set(FFmpeg_${LIBNAME}_VERSION "${FFmpeg_${LIBNAME}_VERSION_MAJOR}.${FFmpeg_${LIBNAME}_VERSION_MINOR}.${FFmpeg_${LIBNAME}_VERSION_MICRO}") + set(FFmpeg_${c}_VERSION "${FFmpeg_${LIBNAME}_VERSION}" PARENT_SCOPE) + unset(_FFmpeg_VERSION_REGEX) + unset(_FFmpeg_VERSION_H_CONTENTS) + + set(FFmpeg_${c}_FOUND TRUE PARENT_SCOPE) + if(NOT FFmpeg_FIND_QUIETLY) + message("-- Found ${LIBNAME}: ${FFmpeg_INCLUDE_${LIBNAME}} ${FFmpeg_LIBRARY_${LIBNAME}} (version: ${FFmpeg_${LIBNAME}_VERSION})") + endif() + endif() +endfunction() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + find_ffmpeg(${c}) +endforeach() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + if(FFmpeg_${c}_FOUND) + list(APPEND FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_${c}}) + list(APPEND FFmpeg_LIBRARIES ${FFmpeg_LIBRARY_${c}}) + + add_library(FFmpeg::${c} IMPORTED UNKNOWN) + set_target_properties(FFmpeg::${c} PROPERTIES + IMPORTED_LOCATION ${FFmpeg_LIBRARY_${c}} + INTERFACE_INCLUDE_DIRECTORIES ${FFmpeg_INCLUDE_${c}} + ) + if(_FFmpeg_DEPS_${c}) + set(deps) + foreach(dep ${_FFmpeg_DEPS_${c}}) + list(APPEND deps FFmpeg::${dep}) + endforeach() + + set_target_properties(FFmpeg::${c} PROPERTIES + INTERFACE_LINK_LIBRARIES "${deps}" + ) + unset(deps) + endif() + endif() +endforeach() + +if(FFmpeg_INCLUDE_DIR) + list(REMOVE_DUPLICATES FFmpeg_INCLUDE_DIR) +endif() + +foreach(c ${FFmpeg_FIND_COMPONENTS}) + list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_INCLUDE_${c} FFmpeg_LIBRARY_${c}) +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg + REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS} + HANDLE_COMPONENTS +) + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + unset(_FFmpeg_DEPS_${c}) +endforeach() +unset(_FFmpeg_ALL_COMPONENTS) +unset(_FFmpeg_REQUIRED_VARS) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg + REQUIRED_VARS + FFmpeg_LIBRARIES + FFmpeg_INCLUDE_DIR + HANDLE_COMPONENTS +) diff --git a/CMakeModules/FindOpus.cmake b/CMakeModules/FindOpus.cmake new file mode 100755 index 000000000..25a44fd87 --- /dev/null +++ b/CMakeModules/FindOpus.cmake @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(OPUS QUIET IMPORTED_TARGET opus) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Opus + REQUIRED_VARS OPUS_LINK_LIBRARIES + VERSION_VAR OPUS_VERSION +) + +if (Opus_FOUND AND NOT TARGET Opus::opus) + add_library(Opus::opus ALIAS PkgConfig::OPUS) +endif() diff --git a/CMakeModules/Findenet.cmake b/CMakeModules/Findenet.cmake new file mode 100755 index 000000000..859a6f386 --- /dev/null +++ b/CMakeModules/Findenet.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(ENET QUIET IMPORTED_TARGET libenet) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(enet + REQUIRED_VARS ENET_LINK_LIBRARIES + VERSION_VAR ENET_VERSION +) + +if (enet_FOUND AND NOT TARGET enet::enet) + add_library(enet::enet ALIAS PkgConfig::ENET) +endif() diff --git a/CMakeModules/Findhttplib.cmake b/CMakeModules/Findhttplib.cmake new file mode 100755 index 000000000..861207eb5 --- /dev/null +++ b/CMakeModules/Findhttplib.cmake @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(httplib QUIET CONFIG) +if (httplib_CONSIDERED_CONFIGS) + find_package_handle_standard_args(httplib CONFIG_MODE) +else() + find_package(PkgConfig QUIET) + pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET cpp-httplib) + find_package_handle_standard_args(httplib + REQUIRED_VARS HTTPLIB_INCLUDEDIR + VERSION_VAR HTTPLIB_VERSION + ) +endif() + +if (httplib_FOUND AND NOT TARGET httplib::httplib) + add_library(httplib::httplib ALIAS PkgConfig::HTTPLIB) +endif() diff --git a/CMakeModules/Findinih.cmake b/CMakeModules/Findinih.cmake new file mode 100755 index 000000000..b8d38dcff --- /dev/null +++ b/CMakeModules/Findinih.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(inih + REQUIRED_VARS INIREADER_LINK_LIBRARIES + VERSION_VAR INIREADER_VERSION +) + +if (inih_FOUND AND NOT TARGET inih::INIReader) + add_library(inih::INIReader ALIAS PkgConfig::INIREADER) +endif() diff --git a/CMakeModules/Findlibusb.cmake b/CMakeModules/Findlibusb.cmake new file mode 100755 index 000000000..0eadce957 --- /dev/null +++ b/CMakeModules/Findlibusb.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(libusb + REQUIRED_VARS LIBUSB_LINK_LIBRARIES + VERSION_VAR LIBUSB_VERSION +) + +if (libusb_FOUND AND NOT TARGET libusb::usb) + add_library(libusb::usb ALIAS PkgConfig::LIBUSB) +endif() diff --git a/CMakeModules/Findlz4.cmake b/CMakeModules/Findlz4.cmake new file mode 100755 index 000000000..7a9a02d4e --- /dev/null +++ b/CMakeModules/Findlz4.cmake @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(lz4 QUIET CONFIG) +if (lz4_CONSIDERED_CONFIGS) + find_package_handle_standard_args(lz4 CONFIG_MODE) +else() + find_package(PkgConfig QUIET) + pkg_search_module(LZ4 QUIET IMPORTED_TARGET liblz4) + find_package_handle_standard_args(lz4 + REQUIRED_VARS LZ4_LINK_LIBRARIES + VERSION_VAR LZ4_VERSION + ) +endif() + +if (lz4_FOUND AND NOT TARGET lz4::lz4) + if (TARGET LZ4::lz4_shared) + add_library(lz4::lz4 ALIAS LZ4::lz4_shared) + elseif (TARGET LZ4::lz4_static) + add_library(lz4::lz4 ALIAS LZ4::lz4_static) + else() + add_library(lz4::lz4 ALIAS PkgConfig::LZ4) + endif() +endif() diff --git a/CMakeModules/Findzstd.cmake b/CMakeModules/Findzstd.cmake new file mode 100755 index 000000000..ae3ea0865 --- /dev/null +++ b/CMakeModules/Findzstd.cmake @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(zstd QUIET CONFIG) +if (zstd_CONSIDERED_CONFIGS) + find_package_handle_standard_args(zstd CONFIG_MODE) +else() + find_package(PkgConfig QUIET) + pkg_search_module(ZSTD QUIET IMPORTED_TARGET libzstd) + find_package_handle_standard_args(zstd + REQUIRED_VARS ZSTD_LINK_LIBRARIES + VERSION_VAR ZSTD_VERSION + ) +endif() + +if (zstd_FOUND AND NOT TARGET zstd::zstd) + if (TARGET zstd::libzstd_shared) + add_library(zstd::zstd ALIAS zstd::libzstd_shared) + elseif (TARGET zstd::libzstd_static) + add_library(zstd::zstd ALIAS zstd::libzstd_static) + else() + add_library(zstd::zstd ALIAS PkgConfig::ZSTD) + endif() +endif() diff --git a/CMakeModules/WindowsCopyFiles.cmake b/CMakeModules/WindowsCopyFiles.cmake new file mode 100755 index 000000000..08b598365 --- /dev/null +++ b/CMakeModules/WindowsCopyFiles.cmake @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2018 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +# This file provides the function windows_copy_files. +# This is only valid on Windows. + +# Include guard +if(__windows_copy_files) + return() +endif() +set(__windows_copy_files YES) + +# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR. +# This copying happens post-build. +function(windows_copy_files TARGET SOURCE_DIR DEST_DIR) + # windows commandline expects the / to be \ so switch them + string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR}) + string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR}) + + # /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output + # cmake adds an extra check for command success which doesn't work too well with robocopy + # so trick it into thinking the command was successful with the || cmd /c "exit /b 0" + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR} + COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0" + ) +endfunction() diff --git a/README.md b/README.md index 15ce7f207..5c2935b7a 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3273. +This is the source code for early-access 3274. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index f6991ec25..5a3b3b21d 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -5,10 +5,6 @@ # some of its variables, which is only possible in 3.13+ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/externals/find-modules") -include(DownloadExternals) - # xbyak if ((ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) AND NOT TARGET xbyak::xbyak) add_subdirectory(xbyak EXCLUDE_FROM_ALL) diff --git a/src/dedicated_room/CMakeLists.txt b/src/dedicated_room/CMakeLists.txt index 45403b342..9a762b266 100755 --- a/src/dedicated_room/CMakeLists.txt +++ b/src/dedicated_room/CMakeLists.txt @@ -1,8 +1,6 @@ # SPDX-FileCopyrightText: 2017 Citra Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) - add_executable(yuzu-room precompiled_headers.h yuzu_room.cpp diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index b20bfabc0..051e67cb8 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -5,7 +5,6 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) # Set the RPATH for Qt Libraries # This must be done before the `yuzu` target is created diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 5340fe836..f252416ff 100755 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -1,8 +1,6 @@ # SPDX-FileCopyrightText: 2018 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) - # Credits to Samantas5855 and others for this function. function(create_resource file output filename) # Read hex data from file