1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-21 18:22:33 +01:00

Use official libusb repo

This commit is contained in:
RipleyTom 2020-02-21 20:41:34 +01:00 committed by Ivan
parent 96be40bf30
commit 4befa36365
12 changed files with 493 additions and 4 deletions

3
.gitmodules vendored
View File

@ -45,7 +45,7 @@
ignore = dirty
[submodule "3rdparty/libusb"]
path = 3rdparty/libusb
url = https://github.com/RPCS3/libusb.git
url = https://github.com/libusb/libusb.git
ignore = dirty
[submodule "3rdparty/FAudio"]
path = 3rdparty/FAudio
@ -54,3 +54,4 @@
[submodule "3rdparty/span"]
path = 3rdparty/span
url = https://github.com/tcbrindle/span
ignore = dirty

View File

@ -138,9 +138,9 @@ if(CMAKE_SYSTEM MATCHES "DragonFly|FreeBSD")
elseif(MSVC)
# Windows time.h defines timespec but doesn't add any flag for it, which makes libusb attempt to define it again
add_definitions(-DHAVE_STRUCT_TIMESPEC=1)
add_subdirectory(libusb EXCLUDE_FROM_ALL)
add_subdirectory(libusb_cmake EXCLUDE_FROM_ALL)
else()
add_subdirectory(libusb EXCLUDE_FROM_ALL)
add_subdirectory(libusb_cmake EXCLUDE_FROM_ALL)
endif()

2
3rdparty/libusb vendored

@ -1 +1 @@
Subproject commit 7cfa00e9d723f10167b4d71bceebf2b4b2cbd70e
Subproject commit e782eeb2514266f6738e242cdcb18e3ae1ed06fa

25
3rdparty/libusb_cmake/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.8.4)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules")
set(LIBUSB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libusb/)
project(libusb)
option(WITH_DEBUG_LOG "enable debug logging" OFF)
# if debug logging is enabled, by default enable logging
option(WITH_LOGGING "if false, disable all logging" ON)
option(WITHOUT_PTHREADS "force pthreads to not be used. if on, then they are used based on detection logic" OFF)
set(LIBUSB_MAJOR 1)
set(LIBUSB_MINOR 0)
set(LIBUSB_MICRO 23)
macro(append_compiler_flags)
foreach(FLAG IN ITEMS ${ARGN})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endforeach()
endmacro()
include(libusb.cmake)

View File

@ -0,0 +1,17 @@
# CoreFoundation_INCLUDE_DIR
# CoreFoundation_LIBRARIES
# CoreFoundation_FOUND
include(LibFindMacros)
find_path(CoreFoundation_INCLUDE_DIR
CoreFoundation.h
PATH_SUFFIXES CoreFoundation
)
find_library(CoreFoundation_LIBRARY
NAMES CoreFoundation
)
set(CoreFoundation_PROCESS_INCLUDES CoreFoundation_INCLUDE_DIR)
set(CoreFoundation_PROCESS_LIBS CoreFoundation_LIBRARY)
libfind_process(CoreFoundation)

View File

@ -0,0 +1,20 @@
# IOKit_INCLUDE_DIR
# IOKit_LIBRARIES
# IOKit_FOUND
include(LibFindMacros)
# IOKit depends on CoreFoundation
find_package(CoreFoundation REQUIRED)
find_path(IOKit_INCLUDE_DIR
IOKitLib.h
PATH_SUFFIXES IOKit
)
find_library(IOKit_LIBRARY
NAMES IOKit
)
set(IOKit_PROCESS_INCLUDES IOKit_INCLUDE_DIR CoreFoundation_INCLUDE_DIR)
set(IOKit_PROCESS_LIBS IOKit_LIBRARY CoreFoundation_LIBRARIES)
libfind_process(IOKit)

View File

@ -0,0 +1,99 @@
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
macro (libfind_package PREFIX)
set (LIBFIND_PACKAGE_ARGS ${ARGN})
if (${PREFIX}_FIND_QUIETLY)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
endif (${PREFIX}_FIND_QUIETLY)
if (${PREFIX}_FIND_REQUIRED)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
endif (${PREFIX}_FIND_REQUIRED)
find_package(${LIBFIND_PACKAGE_ARGS})
endmacro (libfind_package)
# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
# where they added pkg_check_modules. Consequently I need to support both in my scripts
# to avoid those deprecated warnings. Here's a helper that does just that.
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
macro (libfind_pkg_check_modules PREFIX PKGNAME)
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
endmacro (libfind_pkg_check_modules)
# Do the final processing once the paths have been detected.
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
# all the variables, each of which contain one include directory.
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
# Also handles errors in case library detection was required, etc.
macro (libfind_process PREFIX)
# Skip processing if already processed during this run
if (NOT ${PREFIX}_FOUND)
# Start with the assumption that the library was found
set (${PREFIX}_FOUND TRUE)
# Process all includes and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
if (${i})
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Process all libraries and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_LIBS})
if (${i})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Print message and/or exit on fatal error
if (${PREFIX}_FOUND)
if (NOT ${PREFIX}_FIND_QUIETLY)
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
endif (NOT ${PREFIX}_FIND_QUIETLY)
else (${PREFIX}_FOUND)
if (${PREFIX}_FIND_REQUIRED)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
endif (${PREFIX}_FOUND)
endif (NOT ${PREFIX}_FOUND)
endmacro (libfind_process)
macro(libfind_library PREFIX basename)
set(TMP "")
if(MSVC80)
set(TMP -vc80)
endif(MSVC80)
if(MSVC90)
set(TMP -vc90)
endif(MSVC90)
set(${PREFIX}_LIBNAMES ${basename}${TMP})
if(${ARGC} GREATER 2)
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
endif(${ARGC} GREATER 2)
find_library(${PREFIX}_LIBRARY
NAMES ${${PREFIX}_LIBNAMES}
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
)
endmacro(libfind_library)

96
3rdparty/libusb_cmake/config.cmake vendored Normal file
View File

@ -0,0 +1,96 @@
include(CheckCXXCompilerFlag)
include(CheckIncludeFiles)
include(CheckTypeSize)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if (NOT OS_WINDOWS)
# mingw appears to print a bunch of warnings about this
check_cxx_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
endif()
check_cxx_compiler_flag("-Wno-pointer-sign" HAVE_WARN_NO_POINTER_SIGN)
set(_GNU_SOURCE 1 CACHE INTERNAL "" FORCE)
unset(ADDITIONAL_CC_FLAGS)
if (HAVE_VISIBILITY)
list(APPEND ADDITIONAL_CC_FLAGS -fvisibility=hidden)
endif()
if (HAVE_WARN_NO_POINTER_SIGN)
list(APPEND ADDITIONAL_CC_FLAGS -Wno-pointer-sign)
endif()
append_compiler_flags(
-std=gnu99
-Wall
-Wundef
-Wunused
-Wstrict-prototypes
-Werror-implicit-function-declaration
-Wshadow
${ADDITIONAL_CC_FLAGS}
)
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE)
#check_type_size(struct timespec STRUCT_TIMESPEC)
if (HAVE_VISIBILITY)
set(DEFAULT_VISIBILITY "__attribute__((visibility(\"default\")))" CACHE INTERNAL "visibility attribute to function decl" FORCE)
else()
set(DEFAULT_VISIBILITY "" CACHE INTERNAL "visibility attribute to function decl" FORCE)
endif()
if (NOT WITHOUT_POLL_H)
check_include_files(poll.h HAVE_POLL_H)
else()
set(HAVE_POLL_H FALSE CACHE INTERNAL "poll.h explicitely disabled" FORCE)
endif()
if (HAVE_POLL_H)
list(APPEND CMAKE_EXTRA_INCLUDE_FILES "poll.h")
check_type_size(nfds_t NFDS_T)
unset(CMAKE_EXTRA_INCLUDE_FILES)
else()
set(HAVE_NFDS_T FALSE CACHE INTERNAL "poll.h not found - assuming no nfds_t (windows)" FORCE)
set(NFDS_T "" CACHE INTERNAL "" FORCE)
endif()
if (HAVE_NFDS_T)
set(POLL_NFDS_TYPE nfds_t CACHE INTERNAL "the poll nfds types for this platform" FORCE)
else()
set(POLL_NFDS_TYPE "unsigned int" CACHE INTERNAL "the poll nfds for this platform" FORCE)
endif()
if (OS_WINDOWS)
macro(copy_header_if_missing HEADER VARIABLE ALTERNATIVE_DIR)
check_include_files(${HEADER} ${VARIABLE})
if (NOT ${VARIABLE})
message(STATUS "Missing ${HEADER} - grabbing from ${ALTERNATIVE_DIR}")
file(COPY "${ALTERNATIVE_DIR}/${HEADER}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
endif()
endmacro()
# Only VS 2010 has stdint.h
copy_header_if_missing(stdint.h HAVE_STDINT_H ../msvc)
copy_header_if_missing(inttypes.h HAVE_INTTYPES_H ../msvc)
endif()
set(ENABLE_DEBUG_LOGGING ${WITH_DEBUG_LOG} CACHE INTERNAL "enable debug logging (WITH_DEBUG_LOGGING)" FORCE)
set(ENABLE_LOGGING ${WITH_LOGGING} CACHE INTERNAL "enable logging (WITH_LOGGING)" FORCE)
set(PACKAGE "libusb" CACHE INTERNAL "The package name" FORCE)
set(PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net" CACHE INTERNAL "Where to send bug reports" FORCE)
set(PACKAGE_VERSION "${LIBUSB_MAJOR}.${LIBUSB_MINOR}.${LIBUSB_MICRO}" CACHE INTERNAL "package version" FORCE)
set(PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}" CACHE INTERNAL "package string" FORCE)
set(PACKAGE_URL "http://www.libusb.org" CACHE INTERNAL "package url" FORCE)
set(PACKAGE_TARNAME "libusb" CACHE INTERNAL "tarball name" FORCE)
set(VERSION "${PACKAGE_VERSION}" CACHE INTERNAL "version" FORCE)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
message(STATUS "Generated configuration file in ${CMAKE_CURRENT_BINARY_DIR}/config.h")
# for generated config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})

37
3rdparty/libusb_cmake/config.h.cmake vendored Normal file
View File

@ -0,0 +1,37 @@
#ifndef LIBUSB_CONFIG_H
#define LIBUSB_CONFIG_H
#define DEFAULT_VISIBILITY @DEFAULT_VISIBILITY@
#cmakedefine ENABLE_DEBUG_LOGGING
#cmakedefine ENABLE_LOGGING
#define LIBUSB_MAJOR @LIBUSB_MAJOR@
#define LIBUSB_MINOR @LIBUSB_MINOR@
#define LIBUSB_MICRO @LIBUSB_MINOR@
#define _GNU_SOURCE 1
#define PACKAGE @PACKAGE@
#define PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@
#define PACKAGE_STRING @PACKAGE_STRING@
#define PACKAGE_URL @PACKAGE_URL@
#define PACKAGE_VERSION @PACKAGE_VERSION@
#define PACKAGE_TARNAME @PACKAGE_TARNAME@
#define VERSION @VERSION@
#cmakedefine OS_LINUX
#cmakedefine OS_DARWIN
#cmakedefine OS_WINDOWS
#cmakedefine THREADS_POSIX
#cmakedefine USBI_TIMERFD_AVAILABLE
#cmakedefine HAVE_STRUCT_TIMESPEC
#cmakedefine HAVE_POLL_H
#cmakedefine HAVE_SYS_TIME_H
#define POLL_NFDS_TYPE @POLL_NFDS_TYPE@
#endif /* LIBUSB_CONFIG_H */

View File

@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/lib@
includedir=@CMAKE_INSTALL_PREFIX@/include@
Name: libusb-1.0
Description: C API for USB device access from Linux, Mac OS X and Windows userspace
Version: @VERSION@
Libs: -L${libdir} -lusb-1.0
Libs.private: @LIBUSB_LIB_DEPENDS@
Cflags: -I${includedir}/libusb-1.0

76
3rdparty/libusb_cmake/libusb.cmake vendored Normal file
View File

@ -0,0 +1,76 @@
include(os.cmake)
include(config.cmake)
include(FindThreads)
set (LIBUSB_COMMON
core.c
descriptor.c
io.c
sync.c
hotplug.c
strerror.c
libusb-1.0.rc
libusb-1.0.def
)
foreach(SRC IN LISTS LIBUSB_COMMON)
list(APPEND LIBUSB_COMMON_FINAL ${LIBUSB_SOURCE_DIR}/libusb/${SRC})
endforeach()
include_directories(${LIBUSB_SOURCE_DIR}/libusb)
include_directories(${LIBUSB_SOURCE_DIR}/libusb/os)
if (CMAKE_THREAD_LIBS_INIT)
list(APPEND LIBUSB_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
add_library(usb-1.0-static
STATIC
${LIBUSB_COMMON_FINAL}
${LIBUSB_PLATFORM}
)
target_include_directories(usb-1.0-static PUBLIC $<BUILD_INTERFACE:${LIBUSB_SOURCE_DIR}/libusb>)
set_target_properties(usb-1.0-static PROPERTIES
PREFIX "lib"
OUTPUT_NAME "usb-1.0"
CLEAN_DIRECT_OUTPUT 1
PUBLIC_HEADER libusb.h
VERSION "${LIBUSB_MAJOR}.${LIBUSB_MINOR}.${LIBUSB_MICRO}"
SOVERSION "${LIBUSB_MAJOR}.${LIBUSB_MINOR}.${LIBUSB_MICRO}"
)
if (DEFINED LIBUSB_LIBRARIES)
target_link_libraries(usb-1.0-static
${LIBUSB_LIBRARIES}
)
endif()
list(APPEND LIBUSB_LIBTARGETS usb-1.0-static)
install(TARGETS ${LIBUSB_LIBTARGETS} EXPORT libusb-1
PUBLIC_HEADER DESTINATION include/libusb-1.0
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
)
install(EXPORT libusb-1 DESTINATION lib/libusb)
foreach(LIB IN LISTS LIBUSB_LIBRARIES)
if (LIB MATCHES .framework$)
get_filename_component(LIB "${LIB}" NAME)
set(LIB "-Wl,-framework,${LIB}")
elseif (LIB MATCHES .dylib$)
get_filename_component(LIBDIR "${LIB}" PATH)
get_filename_component(LIB "${LIB}" NAME)
string(REGEX REPLACE "lib(.*).dylib$" "\\1" LIB "${LIB}")
set(LIB "-L${LIBDIR} -l${LIB}")
endif()
set(LIBUSB_LIB_DEPENDS "${LIBUSB_LIB_DEPENDS} ${LIB}")
endforeach()
configure_file(libusb-1.0.pc.cmake "${CMAKE_CURRENT_BINARY_DIR}/libusb-1.0.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libusb-1.0.pc" DESTINATION lib/pkgconfig)

107
3rdparty/libusb_cmake/os.cmake vendored Normal file
View File

@ -0,0 +1,107 @@
include(FindThreads)
set(PTHREADS_ENABLED FALSE)
if (CMAKE_USE_PTHREADS_INIT)
set(PTHREADS_ENABLED TRUE)
endif()
if (WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
set(OS_WINDOWS 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
# Enable MingW support for RC language (for CMake pre-2.8)
if (MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif()
enable_language(RC)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
message(STATUS "Detected cygwin")
set(PTHREADS_ENABLED TRUE)
set(WITHOUT_POLL_H TRUE CACHE INTERNAL "Disable using poll.h even if it's available - use windows poll instead fo cygwin's" FORCE)
endif()
list(APPEND PLATFORM_SRC
poll_windows.c
windows_usbdk.c
windows_nt_common.c
windows_winusb.c
threads_windows.c
)
if (PTHREADS_ENABLED AND NOT WITHOUT_PTHREADS)
list(APPEND PLATFORM_SRC threads_posix)
else()
list(APPEND PLATFORM_SRC threads_windows.c)
endif()
elseif (APPLE)
# Apple != OSX alone
set(OS_DARWIN 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(PLATFORM_SRC
darwin_usb.c
threads_posix.c
poll_posix.c
)
find_package(IOKit REQUIRED)
list(APPEND LIBUSB_LIBRARIES ${IOKit_LIBRARIES})
# Currently only objc_registerThreadWithCollector requires linking against it
# which is only for MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
include(CheckCSourceCompiles)
check_c_source_compiles(
"#include <AvailabilityMacros.h>
int main()
{
#if !(MAC_OS_X_VERSION_MIN_REQUIRED >= 1060)
#error \"Don't need objc\"
#endif
}
" NEED_OBJC_REGISTER_THREAD_WITH_COLLECTOR)
if (NEED_OBJC_REGISTER_THREAD_WITH_COLLECTOR)
find_library(LIBOBJC objc)
if (NOT LIBOBJC)
message(SEND_ERROR "Need objc library but can't find it")
else()
list(APPEND LIBUSB_LIBRARIES ${LIBOBJC})
endif()
endif()
endif()
elseif (UNIX)
# Unix is for all *NIX systems including OSX
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(OS_LINUX 1 CACHE INTERNAL "controls config.h macro definition" FORCE)
set(PLATFORM_SRC
linux_usbfs.c
linux_netlink.c
threads_posix.c
poll_posix.c
)
list(APPEND LIBUSB_LIBRARIES rt)
endif()
endif()
if (NOT PLATFORM_SRC)
message(FATAL_ERROR "Unsupported platform ${CMAKE_SYSTEM_NAME}. Currently only support Windows, OSX, & Linux.")
endif()
# the paths are relative to this directory but used in the parent directory,
# so we have to adjust the paths
foreach(SRC IN LISTS PLATFORM_SRC)
list(APPEND LIBUSB_PLATFORM ${LIBUSB_SOURCE_DIR}/libusb/os/${SRC})
endforeach()
# export one level up so that the generic
# libusb parts know what the platform bits are supposed to be
set(LIBUSB_PLATFORM ${LIBUSB_PLATFORM} PARENT_SCOPE)
set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARIES} PARENT_SCOPE)
if (WITHOUT_PTHREADS)
set(PTHREADS_ENABLED FALSE)
endif()
set(THREADS_POSIX ${PTHREADS_ENABLED} CACHE INTERNAL "use pthreads" FORCE)