cmake: align dir watch backend detection with autotools
[platform/upstream/dbus.git] / cmake / CMakeLists.txt
index 6c17461..45d90c9 100644 (file)
@@ -267,6 +267,27 @@ if(NOT MSVC)
     endif(DBUS_GCOV_ENABLED)
 endif(NOT MSVC)
 
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+    option (DBUS_BUS_ENABLE_INOTIFY "build with inotify support (linux only)" ON)
+    if(DBUS_BUS_ENABLE_INOTIFY)
+        check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
+        if(NOT HAVE_SYS_INOTIFY_H)
+            message(FATAL_ERROR "sys/inotify.h not found!")
+        endif(NOT HAVE_SYS_INOTIFY_H)
+    endif(DBUS_BUS_ENABLE_INOTIFY)
+elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*BSD")
+    option (DBUS_BUS_ENABLE_KQUEUE "build with kqueue support (FreeBSD only)" ON)
+    if(DBUS_BUS_ENABLE_KQUEUE)
+        # cmake check a header by compiling a test program with
+        # the header, sys/event.h needs stdint.h and sys/types.h
+        # to work.
+        check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
+        if(NOT HAVE_SYS_EVENT_H)
+            message(FATAL_ERROR "sys/event.h not found!")
+        endif(NOT HAVE_SYS_EVENT_H)
+    endif(DBUS_BUS_ENABLE_KQUEUE)
+endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+
 STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname)
 if("${sysname}" MATCHES ".*SOLARIS.*")
     option (HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON)
@@ -511,6 +532,8 @@ message("        Building w/o assertions:  ${DBUS_DISABLE_ASSERT}             ")
 message("        Building w/o checks:      ${DBUS_DISABLE_CHECKS}              ")
 message("        Building bus stats API:   ${DBUS_ENABLE_STATS}                ")
 message("        installing system libs:   ${DBUS_INSTALL_SYSTEM_LIBS}         ")
+message("        Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY}          ")
+message("        Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE}            ")
 message("        Building Doxygen docs:    ${DBUS_ENABLE_DOXYGEN_DOCS}         ")
 message("        Building XML docs:        ${DBUS_ENABLE_XML_DOCS}             ")
 message("        Daemon executable name:   ${DBUS_DAEMON_NAME}")