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