On Tue, Feb 24, 2026 at 5:41 PM Warner Losh <[email protected]> wrote:
>
> Check to make sure that we have inotify in libc, before looking for it
> in libinotify.

This is how I solved the same problem in KDE lands (which uses CMake) [1].
In short, the algorithm is following:
1. Call into pkg-config to see if there is a .pc module for inotify
2. Check if /usr/include/sys/inotify.h exists
3. If there is no pkg-config module and no header -> no inotify
4. If there is no pkg-config module, but the header exists -> we have
"native" inotify,
    no CFLAGS/LDFLAGS manipulation needed
5. If there is pkg-config module, but no header -> use CFLAGS/LDFLAGS from
    pkg-config (IIRC, this is handled by the "dependency" function in
Meson). This
    case happens on FreeBSD where system and 3rd party headers are separated
    (/usr/include vs. /usr/local/include)
6. If we have both pkg-config module and /usr/include/sys/inotify.h,
then we need
    to figure if this header corresponds to libinotify-kqueue, or it
is a native one.
    This is done by comparing the installation prefix of the library and "/usr".

Hope that helps.

[1] https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/566

Reply via email to