2021-04-11 10:29:15 -04:00
|
|
|
# Findlibusb
|
|
|
|
# =======
|
|
|
|
#
|
|
|
|
# Find the usb library
|
|
|
|
#
|
|
|
|
# This will define the following variables::
|
|
|
|
#
|
|
|
|
# libusb_FOUND - True if the system has the usb library
|
|
|
|
# libusb_VERSION - The verion of the usb library which was found
|
|
|
|
#
|
|
|
|
# and the following imported targets::
|
|
|
|
#
|
|
|
|
# libusb::libusb - The libusb library
|
|
|
|
#
|
|
|
|
# If libusb_STATIC is TRUE then static linking will be assumed
|
|
|
|
#
|
|
|
|
|
2021-04-12 12:19:22 -04:00
|
|
|
function(dump_cmake_variables)
|
|
|
|
get_cmake_property(_variableNames VARIABLES)
|
|
|
|
list (SORT _variableNames)
|
|
|
|
foreach (_variableName ${_variableNames})
|
|
|
|
if (ARGV0)
|
|
|
|
unset(MATCHED)
|
|
|
|
string(REGEX MATCH ${ARGV0} MATCHED ${_variableName})
|
|
|
|
if (NOT MATCHED)
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
message(STATUS "${_variableName}=${${_variableName}}")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
2021-04-11 10:29:15 -04:00
|
|
|
|
2021-04-12 12:19:22 -04:00
|
|
|
include (LibFindMacros)
|
2021-04-11 18:04:07 -04:00
|
|
|
libfind_pkg_detect (libusb libusb-1.0 FIND_PATH libusb.h PATH_SUFFIXES libusb-1.0 FIND_LIBRARY libusb-1.0)
|
2021-04-12 12:19:22 -04:00
|
|
|
set (libusb_LIBRARY C:/Tools/libusb-1.0.24/MinGW64/dll/libusb-1.0.dll.a)
|
2021-04-11 18:04:07 -04:00
|
|
|
# # Use pkg-config to get hints about paths, libs and, flags
|
|
|
|
# libfind_pkg_check_modules (libusb_PC libusb-1.0)
|
2021-04-11 10:29:15 -04:00
|
|
|
|
2021-04-11 18:04:07 -04:00
|
|
|
# # Include dir
|
|
|
|
# find_path (libusb_INCLUDE_DIR
|
|
|
|
# libusb.h
|
|
|
|
# PATHS ${libusb_PC_INCLUDE_DIRS}
|
|
|
|
# PATH_SUFFIXES libusb-1.0
|
|
|
|
# )
|
2021-04-11 10:29:15 -04:00
|
|
|
|
2021-04-11 18:04:07 -04:00
|
|
|
# # Library
|
|
|
|
# if (libusb_STATIC)
|
|
|
|
# find_library (libusb_LIBRARY
|
|
|
|
# NAMES usb-1.0
|
|
|
|
# PATHS ${libusb_PC_STATIC_LIBRARY_DIRS}
|
|
|
|
# PATH_SUFFIXES static
|
|
|
|
# )
|
|
|
|
# else ()
|
|
|
|
# find_library (libusb_LIBRARY
|
|
|
|
# NAMES usb-1.0
|
|
|
|
# PATHS ${libusb_PC_LIBRARY_DIRS}
|
|
|
|
# )
|
|
|
|
# endif ()
|
|
|
|
# set (libusb_PROCESS_INCLUDES libusb_INCLUDE_DIR)
|
|
|
|
# set (libusb_PROCESS_LIBS libusb_LIBRARY)
|
2021-04-11 10:29:15 -04:00
|
|
|
libfind_process (libusb)
|
|
|
|
|
2021-04-11 18:04:07 -04:00
|
|
|
# include (FindPackageHandleStandardArgs)
|
|
|
|
# find_package_handle_standard_args (libusb
|
|
|
|
# REQUIRED_VARS
|
|
|
|
# libusb_LIBRARY
|
|
|
|
# libusb_INCLUDE_DIR
|
|
|
|
# VERSION_VAR libusb_VERSION
|
|
|
|
# )
|
2021-04-11 10:29:15 -04:00
|
|
|
|
2021-04-11 18:04:07 -04:00
|
|
|
# if (libusb_FOUND)
|
|
|
|
# set (libusb_LIBRARIES ${libusb_LIBRARY})
|
|
|
|
# set (libusb_INCLUDE_DIRS ${libusb_INCLUDE_DIR})
|
|
|
|
# set (libusb_DEFINITIONS ${libusb_CFLAGS_OTHER})
|
|
|
|
# endif ()
|
2021-04-11 10:29:15 -04:00
|
|
|
|
|
|
|
if (libusb_FOUND AND NOT TARGET libusb::libusb)
|
|
|
|
add_library (libusb::libusb UNKNOWN IMPORTED)
|
|
|
|
set_target_properties (libusb::libusb PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${libusb_LIBRARY}"
|
|
|
|
INTERFACE_COMPILE_OPTIONS "${libusb_CFLAGS_OTHER}"
|
2021-04-11 18:04:07 -04:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${libusb_INCLUDE_DIRS}"
|
|
|
|
INTERFACE_LINK_LIBRARAIES "${libusb_LIBRARIES}"
|
2021-04-11 10:29:15 -04:00
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
mark_as_advanced (
|
|
|
|
libusb_INCLUDE_DIR
|
|
|
|
libusb_LIBRARY
|
2021-04-11 18:04:07 -04:00
|
|
|
libusb_LIBRARIES
|
2021-04-11 10:29:15 -04:00
|
|
|
)
|