Updating submodules
[hiphop-php.git] / CMake / FindLibEvent.cmake
blobcec5e59fe05ad4ccea784a537e0706fe55a91d4a
1 # - Find LibEvent (a cross event library)
2 # This module defines
3 # LIBEVENT_INCLUDE_DIR, where to find LibEvent headers
4 # LIBEVENT_LIB, LibEvent libraries
5 # LibEvent_FOUND, If false, do not try to use libevent
7 set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}")
8 foreach(prefix ${LibEvent_EXTRA_PREFIXES})
9   list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include")
10   list(APPEND LibEvent_LIB_PATHS "${prefix}/lib")
11 endforeach()
13 find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LibEvent_INCLUDE_PATHS})
14 find_library(LIBEVENT_LIB NAMES event PATHS ${LibEvent_LIB_PATHS})
15 find_library(LIBEVENT_PTHREAD_LIB NAMES event_pthreads PATHS ${LibEvent_LIB_PATHS})
17 if (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR AND LIBEVENT_PTHREAD_LIB)
18   set(LibEvent_FOUND TRUE)
19   set(LIBEVENT_LIB ${LIBEVENT_LIB} ${LIBEVENT_PTHREAD_LIB})
20 else ()
21   set(LibEvent_FOUND FALSE)
22 endif ()
24 if (LibEvent_FOUND)
25   if (NOT LibEvent_FIND_QUIETLY)
26     message(STATUS "Found libevent: ${LIBEVENT_LIB}")
27   endif ()
28 else ()
29   if (LibEvent_FIND_REQUIRED)
30     message(FATAL_ERROR "Could NOT find libevent and libevent_pthread.")
31   endif ()
32   message(STATUS "libevent and libevent_pthread NOT found.")
33 endif ()
35 mark_as_advanced(
36     LIBEVENT_LIB
37     LIBEVENT_INCLUDE_DIR
38   )