INSTALL(
    FILES
    libevent_io_opts.h
    DESTINATION
    include/libcouchbase)


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})
    TARGET_LINK_LIBRARIES(couchbase_libevent ${LIBEVENT_LIBRARIES})
ENDIF()

SET_TARGET_PROPERTIES(couchbase_libevent PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${LCB_CORE_CFLAGS}")

INSTALL(
    FILES
    libevent_io_opts.h
    DESTINATION
    include/libcouchbase)


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})
    TARGET_LINK_LIBRARIES(couchbase_libevent ${LIBEVENT_LIBRARIES})
ENDIF()

LCB_UTIL(couchbase_libevent)

Use LCB_UTIL on the libevent plugin
Use LCB_UTIL on the libevent plugin

This normalizes the plugin wrt our build process, and also ensures it's
built with -fPIC

Change-Id: I186e71fd96fc54646634d42b28f4f88b8a870fe5
Reviewed-on: http://review.couchbase.org/51337
Reviewed-by: Subhashni Balakrishnan <7129c8e37b832c7bd362ff375532d24b98ef5162@gmail.com>
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
