Skip to content

Commit

Permalink
Findhidapi: Link udev in static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Nov 12, 2023
1 parent 5b21632 commit 7b032e0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmake/modules/Findhidapi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The following cache variables may also be set:
#]=======================================================================]

include(IsStaticLibrary)

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(PC_hidapi QUIET hidapi-libusb hidapi)
Expand Down Expand Up @@ -121,6 +123,23 @@ if(hidapi_FOUND)
INTERFACE_COMPILE_OPTIONS "${PC_hidapi_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${hidapi_INCLUDE_DIR}"
)

find_package(Udev)
if(Udev_FOUND)
is_static_library(hidapi_IS_STATIC hidapi::hidapi)
if(hidapi_IS_STATIC)
set_property(TARGET hidapi::hidapi APPEND PROPERTY INTERFACE_LINK_LIBRARIES
Udev::Udev
)
endif()

is_static_library(hidapi-hidraw_IS_STATIC hidapi::hidraw)
if(hidapi-hidraw_IS_STATIC)
set_property(TARGET hidapi::hidraw APPEND PROPERTY INTERFACE_LINK_LIBRARIES
Udev::Udev
)
endif()
endif()
endif()
endif()
endif()

0 comments on commit 7b032e0

Please sign in to comment.