Requires.private with optional dependencies?‏

Jef Driesen jefdriesen at
Fri Sep 23 03:59:02 PDT 2011

I have a library that depends on another library (libusb) for its implementation. My understanding is that I need to add the libusb library to the "Requires.private" of my pkg-config file. So far no problem, but what if the libusb dependency is optional?
My file contains:
# Checks for USB support.
PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [have_libusb=yes], [have_libusb=no])
if test "$have_libusb" = "yes"; then
   AC_DEFINE([HAVE_LIBUSB], [1], [libusb support])
With this I can use $(LIBUSB_CFLAGS) and $(LIBUSB_LIBS) in the and HAVE_LIBUSB in the source code. But how should I write th * file for m library? Obviously I can't just write:
Requires.private: libusb-1.0
Is the correct way to add this line inside the if statement above:
And then use this line in the * file:
Requires.private: @DEPENDENCIES@

More information about the pkg-config mailing list