# - Try to find the LibEvent config processing library
# Once done this will define
#
# LIBEVENT_FOUND - System has LibEvent
# LIBEVENT_INCLUDE_DIRS - the LibEvent include directory
# LIBEVENT_LIBRARIES 0 The libraries needed to use Libevent
find_package(Libevent NO_MODULE QUIET)

if (NOT Libevent_FOUND)
	FIND_PATH(LIBEVENT_INCLUDE_DIRS NAMES event2/event.h)
	FIND_LIBRARY(LIBEVENT_LIBRARIES NAMES event)
	FIND_LIBRARY(LIBEVENT_CORE_LIBRARY NAMES event_core)
	FIND_LIBRARY(LIBEVENT_PTHREADS_LIBRARY NAMES event_pthreads)
	FIND_LIBRARY(LIBEVENT_EXTRA_LIBRARY NAMES event_extra)
	FIND_LIBRARY(LIBEVENT_OPENSSL_LIBRARY NAMES event_openssl)


	INCLUDE(FindPackageHandleStandardArgs)
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libevent DEFAULT_MSG LIBEVENT_LIBRARIES LIBEVENT_INCLUDE_DIRS)
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibeventPthreads DEFAULT_MSG LIBEVENT_PTHREADS_LIBRARY LIBEVENT_INCLUDE_DIRS)
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibeventCore DEFAULT_MSG LIBEVENT_CORE_LIBRARY LIBEVENT_INCLUDE_DIRS)
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibeventExtra DEFAULT_MSG LIBEVENT_EXTRA_LIBRARY LIBEVENT_INCLUDE_DIRS)
	FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibeventOpenssl DEFAULT_MSG LIBEVENT_OPENSSL_LIBRARY LIBEVENT_INCLUDE_DIRS)

	MARK_AS_ADVANCED(LIBEVENT_INCLUDE_DIRS LIBEVENT_LIBRARIES LIBEVENT_PTHREADS_LIBRARY LIBEVENT_OPENSSL_LIBRARY LIBEVENT_CORE_LIBRARY LIBEVENT_EXTRA_LIBRARY)
endif()
