Browse Source

Check the system for inotify in cmake and use a config.h file.

Klaas Freitag 13 years ago
parent
commit
4b33997678
4 changed files with 31 additions and 6 deletions
  1. 6 3
      CMakeLists.txt
  2. 19 0
      cmake/modules/FindINotify.cmake
  3. 4 0
      config.h.in
  4. 2 3
      src/CMakeLists.txt

+ 6 - 3
CMakeLists.txt

@@ -21,10 +21,13 @@ endif()
 
 find_package(Qt4 4.6.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest REQUIRED )
 find_package(Csync)
+find_package(INotify)
+
+set(WITH_CSYNC CSYNC_FOUND)
+set(USE_INOTIFY INOTIFY_FOUND)
+
+configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
-if(CSYNC_FOUND)
-  add_definitions(-DWITH_CSYNC)
-endif(CSYNC_FOUND)
 
 macro(add_tests)
 foreach( loop_var ${ARGV} )

+ 19 - 0
cmake/modules/FindINotify.cmake

@@ -0,0 +1,19 @@
+# This module defines
+#  INOTIFY_INCLUDE_DIR, where to find inotify.h, etc.
+#  INOTIFY_FOUND, If false, do not try to use inotify.
+# also defined, but not for general use are
+#  INOTIFY_LIBRARY, where to find the inotify library.
+
+find_path(INOTIFY_INCLUDE_DIR sys/inotify.h)
+mark_as_advanced(INOTIFY_INCLUDE_DIR)
+
+
+# handle the QUIETLY and REQUIRED arguments and set INOTIFY_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(INOTIFY DEFAULT_MSG INOTIFY_INCLUDE_DIR)
+
+IF(INOTIFY_FOUND)
+  SET(INotify_INCLUDE_DIRS ${INOTIFY_INCLUDE_DIR})
+ENDIF(INOTIFY_FOUND)
+

+ 4 - 0
config.h.in

@@ -0,0 +1,4 @@
+
+#cmakedefine USE_INOTIFY 1
+#cmakedefine WITH_CSYNC 1
+

+ 2 - 3
src/CMakeLists.txt

@@ -49,8 +49,7 @@ set(libsync_HEADERS
     mirall/csyncthread.h
 )
 
-IF( USE_INOTIFY )
-    add_definitions( -DUSE_INOTIFY )
+IF( INOTIFY_FOUND )
     set(libsync_SRCS ${libsync_SRCS} mirall/inotify.cpp)
     set(libsync_HEADERS ${libsync_HEADERS} mirall/inotify.h)
 ENDIF()
@@ -105,7 +104,7 @@ if( UNIX AND NOT APPLE)
 endif()
 
 # csync is required.
-include_directories(${CSYNC_INCLUDE_DIR}/csync ${CSYNC_INCLUDE_DIR})
+include_directories(${CSYNC_INCLUDE_DIR}/csync ${CSYNC_INCLUDE_DIR} ${CMAKE_BINARY_DIR})
 
 qt4_wrap_cpp(mirallMoc ${mirall_HEADERS})