IF(LCB_INSTALL_HEADERS)
  INSTALL(
      FILES
      libevent_io_opts.h
      DESTINATION
      include/libcouchbase)
ENDIF(LCB_INSTALL_HEADERS)


IF(NOT (HAVE_LIBEVENT OR HAVE_LIBEVENT2))
    RETURN()
ENDIF()

IF(HAVE_LIBEVENT2)
    ADD_DEFINITIONS(-DHAVE_LIBEVENT2)
    INCLUDE_DIRECTORIES(AFTER ${LIBEVENT_INCLUDE_DIR})
ELSE()
    INCLUDE_DIRECTORIES(AFTER ${LIBEVENT_INCLUDE_DIR})
    ADD_DEFINITIONS(-DHAVE_LIBEVENT)
ENDIF()

IF(LCB_EMBED_PLUGIN_LIBEVENT)
    ADD_LIBRARY(couchbase_libevent OBJECT plugin-libevent.c)
    SET(LCB_LINK_SPEC "${LCB_LINKS_SPEC} ${LIBEVENT_LIBRARIES}")
ELSE()
    ADD_LIBRARY(couchbase_libevent SHARED plugin-libevent.c)
    INSTALL(TARGETS couchbase_libevent LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/libcouchbase")
    TARGET_LINK_LIBRARIES(couchbase_libevent ${LIBEVENT_LIBRARIES})
ENDIF()

LCB_UTIL(couchbase_libevent)
