From 80ee8ddb9dc3e8f83c7bffa4ab2fe070b3822dc1 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 6 Dec 2022 17:31:52 +0100 Subject: [PATCH] early-access version 3191 --- CMakeLists.txt | 39 +++--------------------- README.md | 2 +- externals/CMakeLists.txt | 4 +-- externals/find-modules/FindOpus.cmake | 18 +++++------ externals/find-modules/Findenet.cmake | 9 +++--- externals/find-modules/Findhttplib.cmake | 9 +++--- externals/find-modules/Findinih.cmake | 9 +++--- externals/find-modules/Findlibusb.cmake | 18 +++++++++++ externals/find-modules/Findlz4.cmake | 28 ++++++++--------- externals/find-modules/Findzstd.cmake | 28 ++++++++--------- externals/libusb/CMakeLists.txt | 2 ++ src/audio_core/CMakeLists.txt | 6 +--- src/input_common/CMakeLists.txt | 10 ++---- src/yuzu/CMakeLists.txt | 6 +--- src/yuzu_cmd/CMakeLists.txt | 8 +---- 15 files changed, 81 insertions(+), 115 deletions(-) create mode 100755 externals/find-modules/Findlibusb.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 32c6bddbb..011b1f82d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,6 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSV option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) -option(YUZU_USE_BUNDLED_LIBUSB "Compile bundled libusb" OFF) - option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) @@ -202,6 +200,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) find_package(enet 1.3) find_package(fmt 9 REQUIRED) find_package(inih) +find_package(libusb 1.0.24) find_package(lz4 REQUIRED) find_package(nlohmann_json 3.8 REQUIRED) find_package(Opus 1.3) @@ -433,23 +432,13 @@ if (ENABLE_SDL2) set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library") set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll") - add_library(SDL2 INTERFACE) - target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") - target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") + add_library(SDL2::SDL2 INTERFACE IMPORTED) + target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARY}") + target_include_directories(SDL2::SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") elseif (YUZU_USE_EXTERNAL_SDL2) message(STATUS "Using SDL2 from externals.") else() find_package(SDL2 2.0.18 REQUIRED) - - # Some installations don't set SDL2_LIBRARIES - if("${SDL2_LIBRARIES}" STREQUAL "") - message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2") - set(SDL2_LIBRARIES "SDL2::SDL2") - endif() - - include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) - add_library(SDL2 INTERFACE) - target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") endif() endif() @@ -461,26 +450,6 @@ if (TARGET Boost::boost) add_library(boost ALIAS Boost::boost) endif() -# Ensure libusb is properly configured (based on dolphin libusb include) -if(NOT YUZU_USE_BUNDLED_LIBUSB) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND AND NOT CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD") - pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24) - else() - find_package(LibUSB) - endif() - - if (LIBUSB_FOUND) - add_library(usb INTERFACE) - target_include_directories(usb INTERFACE "${LIBUSB_INCLUDEDIR}" "${LIBUSB_INCLUDE_DIRS}") - target_link_directories(usb INTERFACE "${LIBUSB_LIBRARY_DIRS}") - target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}") - else() - message(WARNING "libusb not found, falling back to externals") - set(YUZU_USE_BUNDLED_LIBUSB ON) - endif() -endif() - # List of all FFmpeg components required set(FFmpeg_COMPONENTS avcodec diff --git a/README.md b/README.md index efe98453a..2a815a777 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3190. +This is the source code for early-access 3191. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 3f320e720..dc195005d 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -45,8 +45,8 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER endif() # libusb -if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) - add_subdirectory(libusb) +if (NOT TARGET libusb::usb) + add_subdirectory(libusb EXCLUDE_FROM_ALL) endif() # SDL2 diff --git a/externals/find-modules/FindOpus.cmake b/externals/find-modules/FindOpus.cmake index a69a36950..e0764b316 100755 --- a/externals/find-modules/FindOpus.cmake +++ b/externals/find-modules/FindOpus.cmake @@ -1,19 +1,17 @@ # SPDX-FileCopyrightText: 2022 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later -find_package(PkgConfig) - +find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(opus IMPORTED_TARGET GLOBAL opus) - if (opus_FOUND) - add_library(Opus::opus ALIAS PkgConfig::opus) - endif() + pkg_search_module(OPUS QUIET IMPORTED_TARGET opus) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Opus - REQUIRED_VARS - opus_LINK_LIBRARIES - opus_FOUND - VERSION_VAR opus_VERSION + 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/externals/find-modules/Findenet.cmake b/externals/find-modules/Findenet.cmake index 663a2592f..6dae76f4c 100755 --- a/externals/find-modules/Findenet.cmake +++ b/externals/find-modules/Findenet.cmake @@ -4,10 +4,7 @@ find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(ENET QUIET IMPORTED_TARGET GLOBAL libenet) - if (ENET_FOUND) - add_library(enet::enet ALIAS PkgConfig::ENET) - endif() + pkg_search_module(ENET QUIET IMPORTED_TARGET libenet) endif() include(FindPackageHandleStandardArgs) @@ -15,3 +12,7 @@ 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/externals/find-modules/Findhttplib.cmake b/externals/find-modules/Findhttplib.cmake index 56e92a637..b72bad076 100755 --- a/externals/find-modules/Findhttplib.cmake +++ b/externals/find-modules/Findhttplib.cmake @@ -10,13 +10,14 @@ if (httplib_FOUND) else() find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET GLOBAL cpp-httplib) - if (HTTPLIB_FOUND) - add_library(httplib::httplib ALIAS PkgConfig::HTTPLIB) - endif() + pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET cpp-httplib) endif() 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/externals/find-modules/Findinih.cmake b/externals/find-modules/Findinih.cmake index 844396471..8d1a07243 100755 --- a/externals/find-modules/Findinih.cmake +++ b/externals/find-modules/Findinih.cmake @@ -4,10 +4,7 @@ find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(INIREADER QUIET IMPORTED_TARGET GLOBAL INIReader) - if (INIREADER_FOUND) - add_library(inih::INIReader ALIAS PkgConfig::INIREADER) - endif() + pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader) endif() include(FindPackageHandleStandardArgs) @@ -15,3 +12,7 @@ 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/externals/find-modules/Findlibusb.cmake b/externals/find-modules/Findlibusb.cmake new file mode 100755 index 000000000..66f61001c --- /dev/null +++ b/externals/find-modules/Findlibusb.cmake @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +if (PKG_CONFIG_FOUND) + pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0) +endif() + +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/externals/find-modules/Findlz4.cmake b/externals/find-modules/Findlz4.cmake index 76f666f25..da39f5918 100755 --- a/externals/find-modules/Findlz4.cmake +++ b/externals/find-modules/Findlz4.cmake @@ -6,25 +6,23 @@ include(FindPackageHandleStandardArgs) find_package(lz4 QUIET CONFIG) if (lz4_FOUND) find_package_handle_standard_args(lz4 CONFIG_MODE) - if (NOT TARGET lz4::lz4) - if (TARGET LZ4::lz4_shared) - set_target_properties(LZ4::lz4_shared PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(lz4::lz4 ALIAS LZ4::lz4_shared) - else() - set_target_properties(LZ4::lz4_static PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(lz4::lz4 ALIAS LZ4::lz4_static) - endif() - endif() else() find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(liblz4 QUIET IMPORTED_TARGET GLOBAL liblz4) - if (liblz4_FOUND) - add_library(lz4::lz4 ALIAS PkgConfig::liblz4) - endif() + pkg_search_module(LZ4 QUIET IMPORTED_TARGET liblz4) endif() find_package_handle_standard_args(lz4 - REQUIRED_VARS liblz4_LINK_LIBRARIES - VERSION_VAR liblz4_VERSION + 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/externals/find-modules/Findzstd.cmake b/externals/find-modules/Findzstd.cmake index 868054d46..8ed94e94d 100755 --- a/externals/find-modules/Findzstd.cmake +++ b/externals/find-modules/Findzstd.cmake @@ -6,25 +6,23 @@ include(FindPackageHandleStandardArgs) find_package(zstd QUIET CONFIG) if (zstd_FOUND) find_package_handle_standard_args(zstd CONFIG_MODE) - if (NOT TARGET zstd::zstd) - if (TARGET zstd::libzstd_shared) - set_target_properties(zstd::libzstd_shared PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(zstd::zstd ALIAS zstd::libzstd_shared) - else() - set_target_properties(zstd::libzstd_static PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(zstd::zstd ALIAS zstd::libzstd_static) - endif() - endif() else() find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) - pkg_search_module(libzstd QUIET IMPORTED_TARGET GLOBAL libzstd) - if (libzstd_FOUND) - add_library(zstd::zstd ALIAS PkgConfig::libzstd) - endif() + pkg_search_module(ZSTD QUIET IMPORTED_TARGET libzstd) endif() find_package_handle_standard_args(zstd - REQUIRED_VARS libzstd_LINK_LIBRARIES - VERSION_VAR libzstd_VERSION + 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/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt index 27cceac97..45ccbd94d 100755 --- a/externals/libusb/CMakeLists.txt +++ b/externals/libusb/CMakeLists.txt @@ -273,3 +273,5 @@ else() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") configure_file(config.h.in config.h) endif() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + +add_library(libusb::usb ALIAS usb) diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 3d9ae21ba..56ef22772 100755 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -227,11 +227,7 @@ if(ENABLE_CUBEB) target_compile_definitions(audio_core PRIVATE -DHAVE_CUBEB=1) endif() if(ENABLE_SDL2) - if (YUZU_USE_EXTERNAL_SDL2) - target_link_libraries(audio_core PRIVATE SDL2-static) - else() - target_link_libraries(audio_core PRIVATE SDL2) - endif() + target_link_libraries(audio_core PRIVATE SDL2::SDL2) target_compile_definitions(audio_core PRIVATE HAVE_SDL2) endif() diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 9c28394be..384e27222 100755 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -56,18 +56,12 @@ if (ENABLE_SDL2) drivers/sdl_driver.cpp drivers/sdl_driver.h ) - if (YUZU_USE_EXTERNAL_SDL2) - target_link_libraries(input_common PRIVATE SDL2-static) - else() - target_link_libraries(input_common PRIVATE SDL2) - endif() + target_link_libraries(input_common PRIVATE SDL2::SDL2) target_compile_definitions(input_common PRIVATE HAVE_SDL2) endif() -target_link_libraries(input_common PRIVATE usb) - create_target_directory_groups(input_common) -target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) +target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost libusb::usb) if (YUZU_USE_PRECOMPILED_HEADERS) target_precompile_headers(input_common PRIVATE precompiled_headers.h) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 1d2d8fd61..12d7fb259 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -391,11 +391,7 @@ if (YUZU_USE_BUNDLED_QT AND QT_VERSION VERSION_LESS 6) endif() if (ENABLE_SDL2) - if (YUZU_USE_EXTERNAL_SDL2) - target_link_libraries(yuzu PRIVATE SDL2-static) - else() - target_link_libraries(yuzu PRIVATE SDL2) - endif() + target_link_libraries(yuzu PRIVATE SDL2::SDL2) target_compile_definitions(yuzu PRIVATE HAVE_SDL2) endif() diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index d7561a263..772a6fc7f 100755 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -43,13 +43,7 @@ target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) create_resource("../../dist/yuzu.bmp" "yuzu_cmd/yuzu_icon.h" "yuzu_icon") target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR}) -target_link_libraries(yuzu-cmd PRIVATE Vulkan::Headers) - -if (YUZU_USE_EXTERNAL_SDL2) - target_link_libraries(yuzu-cmd PRIVATE SDL2-static) -else() - target_link_libraries(yuzu-cmd PRIVATE SDL2) -endif() +target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers) if(UNIX AND NOT APPLE) install(TARGETS yuzu-cmd)