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