summaryrefslogtreecommitdiffstats
path: root/cmake/FindLibusb.cmake
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2015-02-16 15:23:22 +0100
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2015-02-18 16:49:11 +0100
commit09ba1839225ea6adcba65ebec2f3a783edd6647d (patch)
tree8927087313c2d718350f540fd109a13383f3de0a /cmake/FindLibusb.cmake
parentFix UNIX CMake (and OS X autotools) builds for Heimdall CLI (diff)
downloadHeimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar.gz
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar.bz2
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar.lz
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar.xz
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.tar.zst
Heimdall-09ba1839225ea6adcba65ebec2f3a783edd6647d.zip
Diffstat (limited to '')
-rw-r--r--cmake/FindLibusb.cmake36
1 files changed, 36 insertions, 0 deletions
diff --git a/cmake/FindLibusb.cmake b/cmake/FindLibusb.cmake
new file mode 100644
index 0000000..4b099d3
--- /dev/null
+++ b/cmake/FindLibusb.cmake
@@ -0,0 +1,36 @@
+find_path(LIBUSB_INCLUDE_DIR
+ NAMES
+ libusb.h
+ PATHS
+ /usr/local/include
+ /opt/local/include
+ /usr/include
+ PATH_SUFFIXES
+ libusb-1.0
+)
+
+if (libusb_USE_STATIC_LIBS AND NOT MSVC)
+ set (LIBUSB_LIB_PREFIX "lib" CACHE INTERNAL "libusb library name prefox passed to find_library")
+ set (LIBUSB_LIB_SUFFIX ".a" CACHE INTERNAL "libusb library name suffix passed to find_library")
+else (libusb_USE_STATIC_LIBS AND NOT MSVC)
+ set (LIBUSB_LIB_PREFIX "" CACHE INTERNAL "libusb library name prefox passed to find_library")
+ set (LIBUSB_LIB_SUFFIX "" CACHE INTERNAL "libusb library name suffix passed to find_library")
+endif (libusb_USE_STATIC_LIBS AND NOT MSVC)
+
+find_library(LIBUSB_LIBRARY
+ NAMES
+ ${LIBUSB_LIB_PREFIX}usb-1.0${LIBUSB_LIB_SUFFIX} ${LIBUSB_LIB_PREFIX}usb${LIBUSB_LIB_SUFFIX}
+ PATHS
+ /usr/local/lib
+ /opt/local/lib
+ /usr/lib
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LIBUSB REQUIRED_VARS LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
+
+if (LIBUSB_FOUND)
+ set(LIBUSB_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIR})
+ set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARY})
+ mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
+endif (LIBUSB_FOUND)