CMake implementation based on https://github.com/nonolith/libusb and updated

This commit is contained in:
RipleyTom 2019-02-06 00:40:36 +01:00 committed by Ivan
parent ac5c05b3c3
commit 2e41930f74
11 changed files with 572 additions and 0 deletions

49
CMakeLists.txt Normal file
View File

@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 2.6)
# Can be removed once CMake >= 2.8.4 is required
# this has to be set before the project directive
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
project(libusb)
option(WITHOUT_EXPERIMENTAL_WARNING "Disable the warning that CMake build is experimental whenever CMake is run" ON)
if (NOT WITHOUT_EXPERIMENTAL_WARNING)
message(WARNING "The CMake build system is not officially endorsed. Support may or may not be provided on the libusb-devel@sourceforge.net mailing list")
endif()
option(WITH_SHARED "Build a shared library" OFF)
option(WITH_STATIC "Build a static library" ON)
option(WITH_DOCS "Build the documentation" OFF)
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)
# enable examples by default if building with maintainer mode
option(WITH_EXAMPLES "build example applications" ${WITH_MAINTAINER_MODE})
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 22)
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()
if (WITH_DOCS)
add_subdirectory(docs)
endif ()
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif()
add_subdirectory(libusb)

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)

27
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,27 @@
include(CheckFunctionExists)
include(FindThreads)
check_function_exists(sigaction HAVE_SIGACTION)
if (WITH_SHARED)
set(LIBUSB_LIBRARY usb-1.0)
else()
set(LIBUSB_LIBRARY usb-1.0-static)
endif()
include_directories(../libusb)
add_executable(lsusb lsusb.c)
target_link_libraries(lsusb ${LIBUSB_LIBRARY})
add_executable(xusb xusb.c)
target_link_libraries(xusb ${LIBUSB_LIBRARY})
if (HAVE_SIGACTION)
add_executable(dpfp dpfp.c)
target_link_libraries(dpfp ${LIBUSB_LIBRARY})
if (CMAKE_USE_PTHREADS_INIT)
add_executable(dpfp_threaded dpfp_threaded.c)
target_link_libraries(dpfp_threaded ${LIBUSB_LIBRARY})
endif()
endif()

106
libusb/CMakeLists.txt Normal file
View File

@ -0,0 +1,106 @@
add_subdirectory(os)
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
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/os)
if (CMAKE_THREAD_LIBS_INIT)
list(APPEND LIBUSB_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
# The CLEAN_DIRECT_OUTPUT property setting can be removed once CMake >= 2.8.4
if (WITH_SHARED)
add_library(usb-1.0
SHARED
${LIBUSB_COMMON}
${LIBUSB_PLATFORM}
)
if (MSVC)
set_target_properties(usb-1.0 PROPERTIES PREFIX "lib")
set_target_properties(usb-1.0 PROPERTIES IMPORT_PREFIX "lib")
set_target_properties(usb-1.0 PROPERTIES IMPORT_SUFFIX ".dll.lib")
endif()
target_include_directories(usb-1.0 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
set_target_properties(usb-1.0 PROPERTIES
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)
message("Linking shared library against ${LIBUSB_LIBRARIES}")
target_link_libraries(usb-1.0
${LIBUSB_LIBRARIES}
)
endif()
list(APPEND LIBUSB_LIBTARGETS usb-1.0)
endif()
if (WITH_STATIC)
add_library(usb-1.0-static
STATIC
${LIBUSB_COMMON}
${LIBUSB_PLATFORM}
)
target_include_directories(usb-1.0-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
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)
endif()
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)

97
libusb/config.cmake Normal file
View File

@ -0,0 +1,97 @@
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)
append_compiler_flags(/Wp64)
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
libusb/config.h.cmake 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

107
libusb/os/CMakeLists.txt 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 ${CMAKE_CURRENT_SOURCE_DIR}/${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)

View File

@ -28,8 +28,10 @@
# endif
# include <unistd.h>
# include <sys/syscall.h>
# include <sys/time.h>
#elif defined(__APPLE__)
# include <pthread.h>
# include <sys/time.h>
#elif defined(__CYGWIN__)
# include <windows.h>
#endif