Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 1 | # 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 Sukegawa | e8c71d8 | 2015-11-23 19:51:37 +0900 | [diff] [blame] | 9 | set(LIBEVENT_ROOT CACHE PATH "Root directory of libevent installation") |
| 10 | set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}" ${LIBEVENT_ROOT}) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 11 | foreach(prefix ${LibEvent_EXTRA_PREFIXES}) |
| 12 | list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include") |
| 13 | list(APPEND LibEvent_LIBRARIES_PATHS "${prefix}/lib") |
| 14 | endforeach() |
| 15 | |
James E. King, III | 7edc8fa | 2017-01-20 10:11:41 -0500 | [diff] [blame] | 16 | # 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 |
| 18 | find_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 |
| 22 | find_library(LIBEVENT_LIBRARIES NAMES event event_core event_extra libevent PATHS ${LibEvent_LIBRARIES_PATHS}) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 23 | |
| 24 | if (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIRS) |
| 25 | set(Libevent_FOUND TRUE) |
| 26 | set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES}) |
| 27 | else () |
| 28 | set(Libevent_FOUND FALSE) |
| 29 | endif () |
| 30 | |
| 31 | if (Libevent_FOUND) |
| 32 | if (NOT Libevent_FIND_QUIETLY) |
| 33 | message(STATUS "Found libevent: ${LIBEVENT_LIBRARIES}") |
| 34 | endif () |
| 35 | else () |
| 36 | if (LibEvent_FIND_REQUIRED) |
| 37 | message(FATAL_ERROR "Could NOT find libevent.") |
| 38 | endif () |
| 39 | message(STATUS "libevent NOT found.") |
| 40 | endif () |
| 41 | |
| 42 | mark_as_advanced( |
| 43 | LIBEVENT_LIBRARIES |
| 44 | LIBEVENT_INCLUDE_DIRS |
| 45 | ) |