Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
project('hidapi', 'c', version: files('VERSION'),meson_version: '>=0.60')

iconv_dep = dependency('iconv', required: get_option('libusb'))
libusb_dep = dependency('libusb-1.0', required: get_option('libusb'))
udev_dep = dependency('libudev', required: get_option('hidraw'))

incdirs = include_directories('hidapi')

install_headers('hidapi/hidapi.h', subdir: 'hidapi')

pconf = import('pkgconfig')

if libusb_dep.found() and iconv_dep.found()
libhidapi = library('hidapi-libusb',
'libusb/hid.c',
dependencies: [ iconv_dep, libusb_dep ],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should depend on threads, I think.

Also, it is only called "-libusb" on linux.

And on Windows or macOS it uses the sources from windows/ or mac/ instead. See e.g.

hidapi/Makefile.am

Lines 18 to 40 in 59e84ca

if OS_LINUX
SUBDIRS += linux libusb
endif
if OS_DARWIN
SUBDIRS += mac
endif
if OS_FREEBSD
SUBDIRS += libusb
endif
if OS_KFREEBSD
SUBDIRS += libusb
endif
if OS_HAIKU
SUBDIRS += libusb
endif
if OS_WINDOWS
SUBDIRS += windows
endif

Copy link
Copy Markdown
Author

@neheb neheb Jun 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

threads probably implicitly gets included with libusb.

edit: as for the others, I'd probably have to use wrapdb's CI for that. Need libusb first though.

include_directories: incdirs,
version: meson.project_version(),
install: true
)

pconf.generate(
libhidapi,
description: 'C Library for USB HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the libusb implementation.',
url: 'https://github.com/libusb/hidapi',
subdirs: 'hidapi',
)
endif

if udev_dep.found() and host_machine.system() == 'linux'
hidraw_lib = library('hidapi-hidraw',
'linux/hid.c',
Comment thread
neheb marked this conversation as resolved.
dependencies: udev_dep,
include_directories: incdirs,
version: meson.project_version(),
install: true
)

pconf.generate(
hidraw_lib,
description: 'C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the hidraw implementation.',
url: 'https://github.com/libusb/hidapi',
subdirs: 'hidapi',
)

install_headers('libusb/hidapi_libusb.h', subdir: 'hidapi')
endif
7 changes: 7 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
option('hidraw', type : 'feature',
description : 'Build hidraw. Requires udev.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description : 'Build hidraw. Requires udev.',
description : 'Build hidapi with hidraw backend. Requires udev.',

)

option('libusb', type : 'feature',
description : 'Build hidapi. Requires libusb.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description : 'Build hidapi. Requires libusb.',
description : 'Build hidapi with libusb backend. Requires libusb.',

)