blob: 2bcd7099a7f084383921c72172e82fc58946ebc2 [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
16find_path(LIBEVENT_INCLUDE_DIRS event.h PATHS ${LibEvent_INCLUDE_PATHS})
Nobuaki Sukegawae8c71d82015-11-23 19:51:37 +090017# "lib" prefix is needed on Windows
18find_library(LIBEVENT_LIBRARIES NAMES event libevent PATHS ${LibEvent_LIBRARIES_PATHS})
Roger Meier26593812015-04-12 16:10:35 +020019
20if (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIRS)
21 set(Libevent_FOUND TRUE)
22 set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES})
23else ()
24 set(Libevent_FOUND FALSE)
25endif ()
26
27if (Libevent_FOUND)
28 if (NOT Libevent_FIND_QUIETLY)
29 message(STATUS "Found libevent: ${LIBEVENT_LIBRARIES}")
30 endif ()
31else ()
32 if (LibEvent_FIND_REQUIRED)
33 message(FATAL_ERROR "Could NOT find libevent.")
34 endif ()
35 message(STATUS "libevent NOT found.")
36endif ()
37
38mark_as_advanced(
39 LIBEVENT_LIBRARIES
40 LIBEVENT_INCLUDE_DIRS
41 )