diff --git a/CMakeLists.txt b/CMakeLists.txt index 74addf6..b5457dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,12 @@ target_link_libraries(openFPGALoader ${LIBUSB_LIBRARIES} ${LIBFTDI_LIBRARIES} ) + +# libusb_attach_kernel_driver is only available on Linux. +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + add_definitions(-DATTACH_KERNEL) +endif() + if(ENABLE_UDEV) include_directories(${LIBUDEV_INCLUDE_DIRS}) target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES}) diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index c157826..4de2277 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -131,11 +131,14 @@ int FTDIpp_MPSSE::close_device() fprintf(stderr, "release interface failed %d\n", rtn); return EXIT_FAILURE; } +#ifdef ATTACH_KERNEL + /* libusb_attach_kernel_driver is only available on Linux. */ if (_ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE) { rtn = libusb_attach_kernel_driver(_ftdi->usb_dev, _ftdi->interface); if( rtn != 0) fprintf(stderr, "detach error %d\n", rtn); } +#endif } ftdi_usb_close_internal();