1# Locate libevent library
2# This module defines
3#  HAVE_LIBEVENT, if false, do not try to link with libevent
4#  LIBEVENT_LIBRARIES, Library path and libs
5#  LIBEVENT_INCLUDE_DIR, where to find the ICU headers
6#  HAVE_LIBEVENT
7#  HAVE_LIBEVENT2
8
9FIND_PATH(LIBEVENT_INCLUDE_DIR evutil.h
10          HINTS
11               ${LIBEVENT_ROOT}
12               ENV LIBEVENT_DIR
13          PATH_SUFFIXES include
14          PATHS
15               ${DEPS_INCLUDE_DIR}
16               ~/Library/Frameworks
17               /Library/Frameworks
18               /opt/local
19               /opt/csw
20               /opt/libevent
21               /opt)
22
23FIND_LIBRARY(LIBEVENT_LIBRARIES
24             NAMES event_core libevent_core
25             HINTS
26                 ${LIBEVENT_ROOT}
27                 ENV LIBEVENT_DIR
28             PATHS
29                 ${DEPS_LIB_DIR}
30                 ~/Library/Frameworks
31                 /Library/Frameworks
32                 /opt/local
33                 /opt/csw
34                 /opt/libevent
35                 /opt)
36
37INCLUDE(CMakePushCheckState)
38INCLUDE(CheckFunctionExists)
39
40IF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR)
41  SET(HAVE_LIBEVENT true)
42  MESSAGE(STATUS "Found libevent in ${LIBEVENT_INCLUDE_DIR} : ${LIBEVENT_LIBRARIES}")
43  CMAKE_PUSH_CHECK_STATE()
44  SET(CMAKE_REQUIRED_FLAGS "-I${LIBEVENT_INCLUDE_DIR}")
45  SET(CMAKE_REQUIRED_INCLUDES "event2/event.h")
46  SET(CMAKE_REQUIRED_LIBRARIES ${LIBEVENT_LIBRARIES})
47  CHECK_FUNCTION_EXISTS(event_new HAVE_LIBEVENT2)
48  CMAKE_POP_CHECK_STATE()
49
50ELSE (LIBEVENT_LIBRARIES)
51  SET(HAVE_LIBEVENT false)
52ENDIF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR)
53
54MARK_AS_ADVANCED(HAVE_LIBEVENT LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES)
55