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               ENV LIBEVENT_DIR
12          PATH_SUFFIXES include
13          PATHS
14               ${DEPS_INCLUDE_DIR}
15               ~/Library/Frameworks
16               /Library/Frameworks
17               /opt/local
18               /opt/csw
19               /opt/libevent
20               /opt)
21
22FIND_LIBRARY(LIBEVENT_LIBRARIES
23             NAMES event_core libevent_core
24             HINTS
25                 ENV LIBEVENT_DIR
26             PATHS
27                 ${DEPS_LIB_DIR}
28                 ~/Library/Frameworks
29                 /Library/Frameworks
30                 /opt/local
31                 /opt/csw
32                 /opt/libevent
33                 /opt)
34
35INCLUDE(CMakePushCheckState)
36INCLUDE(CheckFunctionExists)
37
38IF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR)
39  SET(HAVE_LIBEVENT true)
40  MESSAGE(STATUS "Found libevent in ${LIBEVENT_INCLUDE_DIR} : ${LIBEVENT_LIBRARIES}")
41  CMAKE_PUSH_CHECK_STATE()
42  SET(CMAKE_REQUIRED_FLAGS "-I${LIBEVENT_INCLUDE_DIR}")
43  SET(CMAKE_REQUIRED_INCLUDES "event2/event.h")
44  SET(CMAKE_REQUIRED_LIBRARIES ${LIBEVENT_LIBRARIES})
45  CHECK_FUNCTION_EXISTS(event_new HAVE_LIBEVENT2)
46  CMAKE_POP_CHECK_STATE()
47
48ELSE (LIBEVENT_LIBRARIES)
49  SET(HAVE_LIBEVENT false)
50ENDIF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR)
51
52MARK_AS_ADVANCED(HAVE_LIBEVENT LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES)
53