diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,9 +41,13 @@ option(ENABLE_INOTIFY "Try to use inotify for directory monitoring" ON) if(ENABLE_INOTIFY) - include(CheckIncludeFiles) - check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND) - set(HAVE_SYS_INOTIFY_H ${SYS_INOTIFY_H_FOUND}) + # Find libinotify + find_package(Inotify) + set_package_properties(Inotify PROPERTIES + PURPOSE "Filesystem alteration notifications using inotify") + set(HAVE_SYS_INOTIFY_H ${Inotify_FOUND}) +else() + set(HAVE_SYS_INOTIFY_H FALSE) endif() # Generate io/config-kdirwatch.h diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -23,6 +23,11 @@ set(kcoreaddons_OPTIONAL_LIBS ${kcoreaddons_OPTIONAL_LIBS} ${FAM_LIBRARIES}) endif () +if (Inotify_FOUND) + include_directories(${Inotify_INCLUDE_DIRS}) + set(kcoreaddons_OPTIONAL_LIBS ${kcoreaddons_OPTIONAL_LIBS} ${Inotify_LIBRARIES}) +endif () + if(NOT WIN32) set(kcoreaddons_OPTIONAL_SRCS caching/kshareddatacache.cpp) set(kcoreaddons_OPTIONAL_LIBS ${kcoreaddons_OPTIONAL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/lib/io/kdirwatch.cpp b/src/lib/io/kdirwatch.cpp --- a/src/lib/io/kdirwatch.cpp +++ b/src/lib/io/kdirwatch.cpp @@ -110,7 +110,7 @@ } else if (method == "QFSWatch") { return KDirWatch::QFSWatch; } else { -#ifdef Q_OS_LINUX +#if defined(HAVE_SYS_INOTIFY_H) // inotify supports delete+recreate+modify, which QFSWatch doesn't support return KDirWatch::INotify; #else