changeset 402:d859306e2db4 default tip

filesystem: actually check for inotify instead of blindly assuming it exists
author Paper <paper@tflc.us>
date Fri, 07 Nov 2025 18:36:18 -0500
parents 2f89797b6a44
children
files CMakeLists.txt src/core/filesystem.cc
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Nov 07 18:28:36 2025 -0500
+++ b/CMakeLists.txt	Fri Nov 07 18:36:18 2025 -0500
@@ -274,6 +274,8 @@
 	)
 	list(APPEND DEFINES WIN32)
 else()
+	include(CheckSymbolExists)
+
 	find_package(PkgConfig)
 	if (PKG_CONFIG_FOUND)
 		pkg_check_modules(GLIB gio-2.0 glib-2.0)
@@ -292,6 +294,15 @@
 			list(APPEND DEFINES HAVE_XCB)
 		endif()
 	endif()
+
+	check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
+	if(HAVE_INOTIFY_INIT1)
+		list(APPEND DEFINES HAVE_INOTIFY_INIT1)
+	endif()
+	check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY)
+	if(HAVE_INOTIFY)
+		list(APPEND DEFINES HAVE_INOTIFY)
+	endif()
 endif()
 
 ###########################################################################
--- a/src/core/filesystem.cc	Fri Nov 07 18:28:36 2025 -0500
+++ b/src/core/filesystem.cc	Fri Nov 07 18:36:18 2025 -0500
@@ -8,7 +8,7 @@
 
 #ifdef WIN32
 # include <windows.h>
-#elif defined(linux)
+#elif defined(HAVE_INOTIFY)
 /* ehhhh */
 # include <fcntl.h>
 # include <unistd.h>
@@ -368,7 +368,7 @@
 };
 
 using DefaultWatcher = Win32WatcherVista;
-#elif defined(__linux__)
+#elif defined(HAVE_INOTIFY)
 /* Inotify watcher */
 class InotifyWatcher : public StdFilesystemWatcher {
 public: