@@ -13,83 +13,29 @@ IF(PKG_CONFIG_FOUND)
1313 RETURN ()
1414ENDIF ()
1515
16- include ( CheckLibraryExists )
17- include ( CheckIncludeFile )
18-
19- find_path ( LibUSB_INCLUDE_DIRS
20- NAMES
21- libusb.h
16+ FIND_PATH (LibUSB_INCLUDE_DIRS
17+ NAMES libusb.h
2218 PATHS
23- ${CMAKE_SOURCE_DIR} /../../depends /libusbx/include
24- $ENV{LibUSB_ROOT}
19+ ${CMAKE_SOURCE_DIR} /../../depends /libusb
20+ ${CMAKE_SOURCE_DIR} /../../depends /libusbx
21+ ENV LibUSB_ROOT
2522 PATH_SUFFIXES
26- libusb
27- )
28-
29- mark_as_advanced ( LibUSB_INCLUDE_DIRS )
30-
31- if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
32- # LibUSB binary distribution contains several libs.
33- # Use the lib that got compiled with the same compiler.
34- if ( MSVC )
35- if ( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
36- set ( LibUSB_LIBRARY_PATH_SUFFIX_RELEASE x64/Release/dll )
37- set ( LibUSB_LIBRARY_PATH_SUFFIX_DEBUG x64/Debug/dll )
38- else ()
39- set ( LibUSB_LIBRARY_PATH_SUFFIX_RELEASE win32 /Release/dll )
40- set ( LibUSB_LIBRARY_PATH_SUFFIX_DEBUG win32 /Debug/dll )
41- endif ()
42- endif ( MSVC )
43- endif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
23+ include
24+ )
4425
45- find_library ( LibUSB_LIBRARY_RELEASE
46- NAMES
47- libusb libusb-1.0 usb
48- PATHS
49- ${CMAKE_SOURCE_DIR} /../../depends /libusbx/MS64
50- $ENV{LibUSB_ROOT}
51- PATH_SUFFIXES
52- ${LibUSB_LIBRARY_PATH_SUFFIX_RELEASE}
53- )
54-
55- find_library ( LibUSB_LIBRARY_DEBUG
56- NAMES
57- libusb libusb-1.0 libusb-1.0d usb
26+ FIND_LIBRARY (LibUSB_LIBRARIES
27+ NAMES libusb-1.0
5828 PATHS
59- $ENV{LibUSB_ROOT}
29+ "${DEPENDS_DIR} /libusb"
30+ "${DEPENDS_DIR} /libusbx"
31+ ENV LibUSB_ROOT
6032 PATH_SUFFIXES
61- ${LibUSB_LIBRARY_PATH_SUFFIX_DEBUG}
62- )
63-
64- if ( ${LibUSB_LIBRARY_DEBUG} STREQUAL "LibUSB_LIBRARY_DEBUG-NOTFOUND" AND NOT ${LibUSB_LIBRARY_RELEASE} STREQUAL "LibUSB_LIBRARY_RELEASE-NOTFOUND" )
65- message (STATUS "Debug version not found - setting debug to release." )
66- unset (LibUSB_LIBRARY_DEBUG CACHE )
67- set (LibUSB_LIBRARY_DEBUG ${LibUSB_LIBRARY_RELEASE} CACHE STRING "LibUSB_LIBRARY_DEBUG" )
68- endif ()
69-
70- set (LibUSB_LIBRARIES
71- debug ${LibUSB_LIBRARY_DEBUG}
72- optimized ${LibUSB_LIBRARY_RELEASE}
73- )
74-
75- if ( LibUSB_INCLUDE_DIRS AND LibUSB_LIBRARIES )
76- set ( LibUSB_FOUND 1 )
77- endif ( LibUSB_INCLUDE_DIRS AND LibUSB_LIBRARIES )
78-
79- if ( LibUSB_FOUND )
80- set ( CMAKE_REQUIRED_INCLUDES "${LibUSB_INCLUDE_DIRS} " )
81- check_include_file ( usb.h LibUSB_FOUND )
82- endif ( LibUSB_FOUND )
83-
84- if ( LibUSB_FOUND )
85- check_library_exists ( "${LibUSB_LIBRARIES} " usb_open "" LibUSB_FOUND )
86- endif ( LibUSB_FOUND )
87-
88- if ( NOT LibUSB_FOUND )
89- if ( NOT LibUSB_FIND_QUIETLY )
90- message ( STATUS "LibUSB not found, try setting LibUSB_ROOT environment variable." )
91- endif ( NOT LibUSB_FIND_QUIETLY )
92- if ( LibUSB_FIND_REQUIRED )
93- message ( FATAL_ERROR "LibUSB could not be found." )
94- endif ( LibUSB_FIND_REQUIRED )
95- endif ( NOT LibUSB_FOUND )
33+ x64/Release/dll
34+ x64/Debug/dll
35+ Win32 /Release/dll
36+ Win32 /Debug/dll
37+ MS64
38+ )
39+
40+ INCLUDE (FindPackageHandleStandardArgs)
41+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUSB DEFAULT_MSG LibUSB_LIBRARIES LibUSB_INCLUDE_DIRS)
0 commit comments