diff --git a/cmake_modules/FindLIBUSB.cmake b/cmake_modules/FindLIBUSB.cmake index d2822eb..fb127cd 100644 --- a/cmake_modules/FindLIBUSB.cmake +++ b/cmake_modules/FindLIBUSB.cmake @@ -12,6 +12,19 @@ # Author: F. Kooman # +# FreeBSD has built-in libusb since 800069 +IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD) + EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION) + SET(MIN_FREEBSD_VERSION 800068) + IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION}) + SET(LIBUSB_FOUND TRUE) + SET(LIBUSB_INCLUDE_DIRS "/usr/include") + SET(LIBUSB_LIBRARIES "usb") + SET(LIBUSB_LIBRARY_DIRS "/usr/lib/") + ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION}) +ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD) + +IF(NOT LIBUSB_FOUND) IF(MSVC) # Windows with Microsoft Visual C++ FIND_PATH(LIBUSB_INCLUDE_DIRS usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include") @@ -35,6 +48,7 @@ ENDIF(MSVC) IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) SET(LIBUSB_FOUND TRUE) ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) +ENDIF(NOT LIBUSB_FOUND) IF(LIBUSB_FOUND) IF(NOT LIBUSB_FIND_QUIETLY) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 5d57533..1dffda8 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -2,6 +2,9 @@ SET(EXAMPLES-SOURCES nfc-list nfc-mfclassic nfc-mfultralight nfcip-initiator nfc INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../lib) +INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) +LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS}) + # Examples FOREACH(source ${EXAMPLES-SOURCES}) ADD_EXECUTABLE(${source} ${source}.c) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 21c637b..eea4859 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -26,6 +26,8 @@ IF(LIBNFC_USB) SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn531_usb" "drivers/pn533_usb") ENDIF(LIBNFC_USB) +INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) +LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS} ${PCSC_LIBRARY_DIRS}) # Library SET(LIBRARY_SOURCES nfc bitutils ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOURCES})