diff options
| author | 2022-12-05 22:03:34 +0100 | |
|---|---|---|
| committer | 2022-12-06 05:30:40 +0100 | |
| commit | f385175aa21f47b5f4830fcc65128b19ee46e2fe (patch) | |
| tree | 093eec7642239bb4cfbea05121870191d2f181f7 | |
| parent | Merge pull request #9385 from Morph1984/dynarmic-ver (diff) | |
| download | yuzu-f385175aa21f47b5f4830fcc65128b19ee46e2fe.tar.gz yuzu-f385175aa21f47b5f4830fcc65128b19ee46e2fe.tar.xz yuzu-f385175aa21f47b5f4830fcc65128b19ee46e2fe.zip | |
cmake: prefer system libusb
| -rw-r--r-- | CMakeLists.txt | 23 | ||||
| -rw-r--r-- | externals/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | externals/find-modules/FindLibUSB.cmake | 44 | ||||
| -rw-r--r-- | externals/find-modules/Findlibusb.cmake | 18 | ||||
| -rw-r--r-- | externals/libusb/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/input_common/CMakeLists.txt | 4 |
6 files changed, 24 insertions, 71 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 523cf81ac..a2bdee819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -31,8 +31,6 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSV | |||
| 31 | 31 | ||
| 32 | option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) | 32 | option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) |
| 33 | 33 | ||
| 34 | option(YUZU_USE_BUNDLED_LIBUSB "Compile bundled libusb" OFF) | ||
| 35 | |||
| 36 | option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") | 34 | option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") |
| 37 | 35 | ||
| 38 | option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) | 36 | option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) |
| @@ -202,6 +200,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) | |||
| 202 | find_package(enet 1.3) | 200 | find_package(enet 1.3) |
| 203 | find_package(fmt 9 REQUIRED) | 201 | find_package(fmt 9 REQUIRED) |
| 204 | find_package(inih) | 202 | find_package(inih) |
| 203 | find_package(libusb 1.0.24) | ||
| 205 | find_package(lz4 REQUIRED) | 204 | find_package(lz4 REQUIRED) |
| 206 | find_package(nlohmann_json 3.8 REQUIRED) | 205 | find_package(nlohmann_json 3.8 REQUIRED) |
| 207 | find_package(Opus 1.3) | 206 | find_package(Opus 1.3) |
| @@ -461,26 +460,6 @@ if (TARGET Boost::boost) | |||
| 461 | add_library(boost ALIAS Boost::boost) | 460 | add_library(boost ALIAS Boost::boost) |
| 462 | endif() | 461 | endif() |
| 463 | 462 | ||
| 464 | # Ensure libusb is properly configured (based on dolphin libusb include) | ||
| 465 | if(NOT YUZU_USE_BUNDLED_LIBUSB) | ||
| 466 | find_package(PkgConfig) | ||
| 467 | if (PKG_CONFIG_FOUND AND NOT CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD") | ||
| 468 | pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24) | ||
| 469 | else() | ||
| 470 | find_package(LibUSB) | ||
| 471 | endif() | ||
| 472 | |||
| 473 | if (LIBUSB_FOUND) | ||
| 474 | add_library(usb INTERFACE) | ||
| 475 | target_include_directories(usb INTERFACE "${LIBUSB_INCLUDEDIR}" "${LIBUSB_INCLUDE_DIRS}") | ||
| 476 | target_link_directories(usb INTERFACE "${LIBUSB_LIBRARY_DIRS}") | ||
| 477 | target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}") | ||
| 478 | else() | ||
| 479 | message(WARNING "libusb not found, falling back to externals") | ||
| 480 | set(YUZU_USE_BUNDLED_LIBUSB ON) | ||
| 481 | endif() | ||
| 482 | endif() | ||
| 483 | |||
| 484 | # List of all FFmpeg components required | 463 | # List of all FFmpeg components required |
| 485 | set(FFmpeg_COMPONENTS | 464 | set(FFmpeg_COMPONENTS |
| 486 | avcodec | 465 | avcodec |
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index fea10d809..4ffafd18c 100644 --- 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 | |||
| 45 | endif() | 45 | endif() |
| 46 | 46 | ||
| 47 | # libusb | 47 | # libusb |
| 48 | if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) | 48 | if (NOT TARGET libusb::usb) |
| 49 | add_subdirectory(libusb) | 49 | add_subdirectory(libusb EXCLUDE_FROM_ALL) |
| 50 | endif() | 50 | endif() |
| 51 | 51 | ||
| 52 | # SDL2 | 52 | # SDL2 |
diff --git a/externals/find-modules/FindLibUSB.cmake b/externals/find-modules/FindLibUSB.cmake deleted file mode 100644 index 617daf9a5..000000000 --- a/externals/find-modules/FindLibUSB.cmake +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2009 Michal Cihar <michal@cihar.com> | ||
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | # - Find libusb-1.0 library | ||
| 5 | # This module defines | ||
| 6 | # LIBUSB_INCLUDE_DIR, where to find bluetooth.h | ||
| 7 | # LIBUSB_LIBRARIES, the libraries needed to use libusb-1.0. | ||
| 8 | # LIBUSB_FOUND, If false, do not try to use libusb-1.0. | ||
| 9 | # | ||
| 10 | # vim: expandtab sw=4 ts=4 sts=4: | ||
| 11 | |||
| 12 | if(ANDROID) | ||
| 13 | set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found") | ||
| 14 | message(STATUS "libusb-1.0 not found.") | ||
| 15 | elseif (NOT LIBUSB_FOUND) | ||
| 16 | pkg_check_modules (LIBUSB_PKG libusb-1.0) | ||
| 17 | |||
| 18 | find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h | ||
| 19 | PATHS | ||
| 20 | ${LIBUSB_PKG_INCLUDE_DIRS} | ||
| 21 | /usr/include/libusb-1.0 | ||
| 22 | /usr/include | ||
| 23 | /usr/local/include/libusb-1.0 | ||
| 24 | /usr/local/include | ||
| 25 | ) | ||
| 26 | |||
| 27 | find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb | ||
| 28 | PATHS | ||
| 29 | ${LIBUSB_PKG_LIBRARY_DIRS} | ||
| 30 | /usr/lib | ||
| 31 | /usr/local/lib | ||
| 32 | ) | ||
| 33 | |||
| 34 | if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) | ||
| 35 | set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found") | ||
| 36 | message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}") | ||
| 37 | else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) | ||
| 38 | set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found") | ||
| 39 | message(STATUS "libusb-1.0 not found.") | ||
| 40 | endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) | ||
| 41 | |||
| 42 | mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES) | ||
| 43 | endif () | ||
| 44 | |||
diff --git a/externals/find-modules/Findlibusb.cmake b/externals/find-modules/Findlibusb.cmake new file mode 100644 index 000000000..66f61001c --- /dev/null +++ b/externals/find-modules/Findlibusb.cmake | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf> | ||
| 2 | # | ||
| 3 | # SPDX-License-Identifier: GPL-3.0-or-later | ||
| 4 | |||
| 5 | find_package(PkgConfig QUIET) | ||
| 6 | if (PKG_CONFIG_FOUND) | ||
| 7 | pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0) | ||
| 8 | endif() | ||
| 9 | |||
| 10 | include(FindPackageHandleStandardArgs) | ||
| 11 | find_package_handle_standard_args(libusb | ||
| 12 | REQUIRED_VARS LIBUSB_LINK_LIBRARIES | ||
| 13 | VERSION_VAR LIBUSB_VERSION | ||
| 14 | ) | ||
| 15 | |||
| 16 | if (libusb_FOUND AND NOT TARGET libusb::usb) | ||
| 17 | add_library(libusb::usb ALIAS PkgConfig::LIBUSB) | ||
| 18 | endif() | ||
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt index 3cb1b3687..6317ea807 100644 --- a/externals/libusb/CMakeLists.txt +++ b/externals/libusb/CMakeLists.txt | |||
| @@ -273,3 +273,5 @@ else() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |||
| 273 | 273 | ||
| 274 | configure_file(config.h.in config.h) | 274 | configure_file(config.h.in config.h) |
| 275 | endif() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | 275 | endif() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 276 | |||
| 277 | add_library(libusb::usb ALIAS usb) | ||
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index e41da2726..2c9e1d359 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt | |||
| @@ -64,10 +64,8 @@ if (ENABLE_SDL2) | |||
| 64 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) | 64 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) |
| 65 | endif() | 65 | endif() |
| 66 | 66 | ||
| 67 | target_link_libraries(input_common PRIVATE usb) | ||
| 68 | |||
| 69 | create_target_directory_groups(input_common) | 67 | create_target_directory_groups(input_common) |
| 70 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) | 68 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost libusb::usb) |
| 71 | 69 | ||
| 72 | if (YUZU_USE_PRECOMPILED_HEADERS) | 70 | if (YUZU_USE_PRECOMPILED_HEADERS) |
| 73 | target_precompile_headers(input_common PRIVATE precompiled_headers.h) | 71 | target_precompile_headers(input_common PRIVATE precompiled_headers.h) |