1#.rest:
2# FindInotify
3# --------------
4#
5# Try to find inotify on this system. This finds:
6#  - libinotiy on Unix like systems, or
7#  - the kernel's inotify on Linux systems.
8#
9# This will define the following variables:
10#
11# ``Inotify_FOUND``
12#    True if inotify is available
13# ``Inotify_LIBRARIES``
14#    This has to be passed to target_link_libraries()
15# ``Inotify_INCLUDE_DIRS``
16#    This has to be passed to target_include_directories()
17#
18# On Linux, the libraries and include directories are empty,
19# even though Inotify_FOUND may be set to TRUE. This is because
20# no special includes or libraries are needed. On other systems
21# these may be needed to use inotify.
22
23#=============================================================================
24# Copyright 2016 Tobias C. Berner <tcberner@FreeBSD.org>
25# Copyright 2017 Adriaan de Groot <groot@kde.org>
26#
27# Redistribution and use in source and binary forms, with or without
28# modification, are permitted provided that the following conditions
29# are met:
30#
31# 1. Redistributions of source code must retain the copyright
32#    notice, this list of conditions and the following disclaimer.
33# 2. Redistributions in binary form must reproduce the copyright
34#    notice, this list of conditions and the following disclaimer in the
35#    documentation and/or other materials provided with the distribution.
36#
37# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
38# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
40# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
41# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
46# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47#=============================================================================
48
49find_path(Inotify_INCLUDE_DIRS sys/inotify.h)
50if(Inotify_INCLUDE_DIRS)
51# On Linux there is no library to link against, on the BSDs there is.
52# On the BSD's, inotify is implemented through a library, libinotify.
53    if( CMAKE_SYSTEM_NAME MATCHES "Linux")
54        set(Inotify_FOUND TRUE)
55
56        set(Inotify_INCLUDE_DIRS "")
57    else()
58        find_library(Inotify_LIBRARIES NAMES inotify)
59        include(FindPackageHandleStandardArgs)
60        find_package_handle_standard_args(Inotify
61            FOUND_VAR
62                Inotify_FOUND
63            REQUIRED_VARS
64                Inotify_LIBRARIES
65                Inotify_INCLUDE_DIRS
66        )
67        mark_as_advanced(Inotify_LIBRARIES Inotify_INCLUDE_DIRS)
68        include(FeatureSummary)
69        set_package_properties(Inotify PROPERTIES
70            URL "https://github.com/libinotify-kqueue/"
71            DESCRIPTION "inotify API on the *BSD family of operating systems."
72        )
73    endif()
74else()
75   set(Inotify_FOUND FALSE)
76endif()
77
78mark_as_advanced(Inotify_LIBRARIES Inotify_INCLUDE_DIRS)
79