Hey osmocom-sdr,
I've got a choose your own adventure patch set here for the adventurous reviewer.
On OpenBSD (but not specific to OpenBSD) libusb-1.0 lives in /usr/local/lib. The default linker (lld 13.0.0 on 7.2) doesn't include /usr/local/lib in its out of the box search path, which triggers a build failure in rtl-sdr because the -L argument(s) aren't passed through to ld.
The root cause here is that we pass ${LIBUSB_LIBRARIES} to target_link_libraries, which is only the -lfoo arguments, but not the -L/foo/bar arguments. This tends to work on most systems, since libusb is usually in a place ld will search anyway.
There's two ways I could see to do this. Here comes the choose your own adventure part:
1) The first is to use the PkgConfig::LIBUSB helper, which can be passed directly to `target_link_libraries`, which allows all the arguments to be passed through. This means the existing hooks to pass in a manual path would be dropped and building without pkg-config against libusb won't be supported anymore. This is the attached git format-patch entitled "0001-Use-the-PkgConfig-imported-target-rather-than-_LIBRA.patch".
2) Punch the -L arguments through next to the LIBUSB_LIBRARIES argument to `target_link_libraries`, add a new knob to set the values ("manual libusb librarypath"), and when using pkg-config, generate the arguments with a FOREACH. This is the attached git format-patch "0001-Pass-additional-library-directory-arguments-to-ld.patch".
Both patch flavors build on my Debian sid box and an OpenBSD 7.2 box.
paultag