[CMake] Include dir for inotify.h

RazZziel razielmine at gmail.com
Fri Feb 29 20:28:29 EST 2008


Hi, I'm working on ap project that users inotify.h, a module that is
included in recent versions of glibc, but for example not in Debian
Etch.

The thing is, in any modern distro I'd have to include sys/inotify.h,
while in etch I have to include inotifytools/inotify.h. I've managed
to do it in CMake with CHECK_INCLUDE_FILES and a config.h, but I found
a cleaner solution that should work in theory but actually doesn't,
for me:


src/CMakeList.txt

>SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
>
>FIND_PACKAGE(Inotify REQUIRED)
>IF(INOTIFY_FOUND)
>  INCLUDE_DIRECTORIES( ${INOTIFY_INCLUDE_DIR} )
>ENDIF(INOTIFY_FOUND)


cmake_modules/FindInotify.cmake

>IF (INOTIFY_FOUND)
>  IF (NOT Inotify_FIND_QUIETLY)
>    MESSAGE(STATUS "Found Inotify: ${INOTIFY_INCLUDE_DIR}")
>  ENDIF (NOT Inotify_FIND_QUIETLY)
>ELSE (INOTIFY_FOUND)
>  IF (Inotify_FIND_REQUIRED)
>    MESSAGE(FATAL_ERROR "Could not find Inotify")
>  ENDIF (Inotify_FIND_REQUIRED)
>ENDIF (INOTIFY_FOUND)
>
>INCLUDE_DIRECTORIES( ${INOTIFY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )


So, when I get the correct inotify path I get it into my include dirs,
but if CMake can't find it gives an error. This should work, but how
do I include inotify.h in my source? #include <inotify.h> or
"inotify.h" doesn't seem to work.


Also, I've tried compiling this with plain g++, and I get a very weird error:


>[raziel at Bebop klikd]$ g++ -I/usr/include/sys src/*.cpp -lpthread -lrt
>In file included from /usr/include/sys/signal.h:1,
>                 from /usr/include/sys/signal.h:1,
>                 from /usr/include/sys/signal.h:1,
>                 from /usr/include/sys/signal.h:1,
>                 from /usr/include/sys/signal.h:1,
>                 from /usr/include/sys/signal.h:1,
>
>(...)
>/usr/include/sys/signal.h:1:20: error: #include nested too deeply
>In file included from /usr/include/sys/unistd.h:1,
>                 from /usr/include/sys/unistd.h:1,
>                 from /usr/include/sys/unistd.h:1,
>                 from /usr/include/sys/unistd.h:1,
>                 from /usr/include/sys/unistd.h:1,
>(...)

Being:

>[raziel at Bebop klikd]$ cat /usr/include/sys/signal.h
>#include <signal.h>
>[raziel at Bebop klikd]$ cat /usr/include/sys/unistd.h
>#include <unistd.h>


Is this normal? Anyone know how to make it work?


More information about the CMake mailing list