FindInotify.cmake 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #.rst:
  2. # FindInotify
  3. # --------------
  4. #
  5. # Try to find inotify on this system. This finds:
  6. # - libinotify 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. # Since 5.32.0.
  24. #=============================================================================
  25. # SPDX-FileCopyrightText: 2016 Tobias C. Berner <tcberner@FreeBSD.org>
  26. # SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
  27. #
  28. # SPDX-License-Identifier: BSD-2-Clause
  29. #=============================================================================
  30. find_path(Inotify_INCLUDE_DIRS sys/inotify.h)
  31. if(Inotify_INCLUDE_DIRS)
  32. # On Linux there is no library to link against, on the BSDs there is.
  33. # On the BSD's, inotify is implemented through a library, libinotify.
  34. if( CMAKE_SYSTEM_NAME MATCHES "Linux")
  35. set(Inotify_FOUND TRUE)
  36. set(Inotify_LIBRARIES "")
  37. set(Inotify_INCLUDE_DIRS "")
  38. else()
  39. find_library(Inotify_LIBRARIES NAMES inotify)
  40. include(FindPackageHandleStandardArgs)
  41. find_package_handle_standard_args(Inotify
  42. FOUND_VAR
  43. Inotify_FOUND
  44. REQUIRED_VARS
  45. Inotify_LIBRARIES
  46. Inotify_INCLUDE_DIRS
  47. )
  48. mark_as_advanced(Inotify_LIBRARIES Inotify_INCLUDE_DIRS)
  49. include(FeatureSummary)
  50. set_package_properties(Inotify PROPERTIES
  51. URL "https://github.com/libinotify-kqueue/"
  52. DESCRIPTION "inotify API on the *BSD family of operating systems."
  53. )
  54. endif()
  55. else()
  56. set(Inotify_FOUND FALSE)
  57. endif()
  58. mark_as_advanced(Inotify_LIBRARIES Inotify_INCLUDE_DIRS)