Skip to content

Commit

Permalink
Improve libusb-1.0 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rjonaitis committed Feb 9, 2024
1 parent 86bd297 commit 9ded814
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ add_subdirectory(amarisoft-plugin)
#########################################################################
include(FeatureSummary)
message(STATUS "")
message(STATUS "######################################################")
feature_summary(WHAT PACKAGES_FOUND
DESCRIPTION "Packages found:"
)

message(STATUS "######################################################")
feature_summary(WHAT RECOMMENDED_PACKAGES_NOT_FOUND
DESCRIPTION "Recommended packages not found:"
)

message(STATUS "######################################################")
message(STATUS "## ${PROJECT_NAME} enabled features")
message(STATUS "######################################################")
Expand Down
17 changes: 10 additions & 7 deletions cmake/Modules/Findlibusb-1.0.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
# in cache already
set(LIBUSB_FOUND TRUE)
set(LIBUSB_1_FOUND TRUE)
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
find_path(LIBUSB_1_INCLUDE_DIR
NAMES
Expand Down Expand Up @@ -101,18 +101,21 @@ endif(bananapi-r2)
endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)

if (LIBUSB_1_FOUND)
if (NOT libusb_1_FIND_QUIETLY)
if (NOT libusb-1.0_FIND_QUIETLY)
message(STATUS "Found libusb-1.0:")
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
endif (NOT libusb_1_FIND_QUIETLY)
message(STATUS " - LIBUSB_1_INCLUDE_DIRS: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - LIBUSB_1_LIBRARIES: ${LIBUSB_1_LIBRARIES}")
endif (NOT libusb-1.0_FIND_QUIETLY)
else (LIBUSB_1_FOUND)
if (libusb_1_FIND_REQUIRED)
if (libusb-1.0_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libusb")
endif (libusb_1_FIND_REQUIRED)
endif (libusb-1.0_FIND_REQUIRED)
endif (LIBUSB_1_FOUND)

# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
mark_as_advanced(LIBUSB_1_INCLUDE_DIR LIBUSB_1_LIBRARY)

endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)

set(libusb-1.0_FOUND ${LIBUSB_1_FOUND})
5 changes: 5 additions & 0 deletions src/comms/USB/FT601/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ if(WIN32)
message(STATUS "FTDI_LIBRARIES: ${FTDI_LIBRARIES}")
elseif(UNIX)
find_package(libusb-1.0)
set_package_properties(libusb-1.0 PROPERTIES
TYPE RECOMMENDED
PURPOSE "Adds USB communication support for FT601 chip"
)

set(FTDI_FOUND ${LIBUSB_1_FOUND})
if (NOT ${FTDI_FOUND})
message(WARNING "libusb-1.0 libraries not found. Omitting FTDI USB support")
Expand Down
8 changes: 8 additions & 0 deletions src/comms/USB/FX3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if(WIN32)
find_package(CyAPI)
set_package_properties(CyAPI
TYPE RECOMMENDED
PURPOSE "Adds USB communication support for Cypress FX3 chip"
)
set(FX3_FOUND ${CYAPI_FOUND})
set(FX3_INCLUDE_DIRS ${CYAPI_INCLUDE_DIRS})
set(FX3_LIBRARIES ${CYAPI_LIBRARIES} SetupAPI)
Expand All @@ -11,6 +15,10 @@ if(WIN32)
endif()
elseif(UNIX)
find_package(libusb-1.0)
set_package_properties(libusb-1.0 PROPERTIES
TYPE RECOMMENDED
PURPOSE "Adds USB communication support for Cypress FX3 chip"
)
set(FX3_FOUND ${LIBUSB_1_FOUND})
if (NOT ${FX3_FOUND})
message(WARNING "libusb-1.0 libraries not found. Omitting Cypress FX3 USB support")
Expand Down

0 comments on commit 9ded814

Please sign in to comment.