blob: ac6a078a1a489061a23c9f9ecc9db3407775e24e [file] [log] [blame]
Roger Meier26593812015-04-12 16:10:35 +02001# find LibEvent
2# an event notification library (http://libevent.org/)
3#
4# Usage:
5# LIBEVENT_INCLUDE_DIRS, where to find LibEvent headers
6# LIBEVENT_LIBRARIES, LibEvent libraries
7# Libevent_FOUND, If false, do not try to use libevent
8
Nobuaki Sukegawae8c71d82015-11-23 19:51:37 +09009set(LIBEVENT_ROOT CACHE PATH "Root directory of libevent installation")
10set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}" ${LIBEVENT_ROOT})
Roger Meier26593812015-04-12 16:10:35 +020011foreach(prefix ${LibEvent_EXTRA_PREFIXES})
12 list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include")
13 list(APPEND LibEvent_LIBRARIES_PATHS "${prefix}/lib")
14endforeach()
15
James E. King, III7edc8fa2017-01-20 10:11:41 -050016# Looking for "event.h" will find the Platform SDK include dir on windows
17# so we also look for a peer header like evhttp.h to get the right path
18find_path(LIBEVENT_INCLUDE_DIRS evhttp.h event.h PATHS ${LibEvent_INCLUDE_PATHS})
19
20# "lib" prefix is needed on Windows in some cases
21# newer versions of libevent use three libraries
22find_library(LIBEVENT_LIBRARIES NAMES event event_core event_extra libevent PATHS ${LibEvent_LIBRARIES_PATHS})
Roger Meier26593812015-04-12 16:10:35 +020023
24if (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIRS)
25 set(Libevent_FOUND TRUE)
26 set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES})
27else ()
28 set(Libevent_FOUND FALSE)
29endif ()
30
31if (Libevent_FOUND)
32 if (NOT Libevent_FIND_QUIETLY)
33 message(STATUS "Found libevent: ${LIBEVENT_LIBRARIES}")
34 endif ()
35else ()
36 if (LibEvent_FIND_REQUIRED)
37 message(FATAL_ERROR "Could NOT find libevent.")
38 endif ()
39 message(STATUS "libevent NOT found.")
40endif ()
41
42mark_as_advanced(
43 LIBEVENT_LIBRARIES
44 LIBEVENT_INCLUDE_DIRS
45 )