summaryrefslogtreecommitdiffstats
path: root/libevent/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'libevent/cmake')
-rw-r--r--libevent/cmake/AddCompilerFlags.cmake13
-rw-r--r--libevent/cmake/AddEventLibrary.cmake193
-rw-r--r--libevent/cmake/COPYING-CMAKE-SCRIPTS22
-rw-r--r--libevent/cmake/CheckConstExists.cmake25
-rw-r--r--libevent/cmake/CheckFileOffsetBits.c14
-rw-r--r--libevent/cmake/CheckFileOffsetBits.cmake43
-rw-r--r--libevent/cmake/CheckFunctionKeywords.cmake14
-rw-r--r--libevent/cmake/CheckPrototypeDefinition.c.in29
-rw-r--r--libevent/cmake/CheckPrototypeDefinition.cmake82
-rw-r--r--libevent/cmake/CheckWorkingKqueue.cmake52
-rw-r--r--libevent/cmake/CodeCoverage.cmake165
-rw-r--r--libevent/cmake/Copyright.txt57
-rw-r--r--libevent/cmake/LibeventConfig.cmake.in183
-rw-r--r--libevent/cmake/LibeventConfigVersion.cmake.in11
-rw-r--r--libevent/cmake/Macros.cmake36
-rw-r--r--libevent/cmake/Uninstall.cmake.in23
-rw-r--r--libevent/cmake/UseDoxygen.cmake111
-rw-r--r--libevent/cmake/VersionViaGit.cmake66
18 files changed, 1139 insertions, 0 deletions
diff --git a/libevent/cmake/AddCompilerFlags.cmake b/libevent/cmake/AddCompilerFlags.cmake
new file mode 100644
index 0000000..9dc21d0
--- /dev/null
+++ b/libevent/cmake/AddCompilerFlags.cmake
@@ -0,0 +1,13 @@
+include(CheckCCompilerFlag)
+
+macro(add_compiler_flags)
+ foreach(flag ${ARGN})
+ string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${flag}")
+
+ check_c_compiler_flag("${flag}" check_c_compiler_flag_${_flag_esc})
+
+ if (check_c_compiler_flag_${_flag_esc})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+ endif()
+ endforeach()
+endmacro()
diff --git a/libevent/cmake/AddEventLibrary.cmake b/libevent/cmake/AddEventLibrary.cmake
new file mode 100644
index 0000000..04f5837
--- /dev/null
+++ b/libevent/cmake/AddEventLibrary.cmake
@@ -0,0 +1,193 @@
+include(CMakeParseArguments)
+
+set(LIBEVENT_SHARED_LIBRARIES "")
+set(LIBEVENT_STATIC_LIBRARIES "")
+
+macro(set_event_shared_lib_flags LIB_NAME)
+ set_target_properties("${LIB_NAME}_shared" PROPERTIES
+ COMPILE_FLAGS ${ARGN})
+ set_target_properties("${LIB_NAME}_shared" PROPERTIES
+ LINK_FLAGS ${ARGN})
+endmacro()
+
+macro(generate_pkgconfig LIB_NAME)
+ set(prefix ${CMAKE_INSTALL_PREFIX})
+ set(exec_prefix ${CMAKE_INSTALL_PREFIX})
+ set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
+ set(includedir ${CMAKE_INSTALL_PREFIX}/include)
+
+ set(VERSION ${EVENT_ABI_LIBVERSION})
+
+ set(LIBS "")
+ foreach (LIB ${LIB_PLATFORM})
+ set(LIBS "${LIBS} -L${LIB}")
+ endforeach()
+
+ set(OPENSSL_LIBS "")
+ foreach(LIB ${OPENSSL_LIBRARIES})
+ set(OPENSSL_LIBS "${OPENSSL_LIBS} -L${LIB}")
+ endforeach()
+
+ configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc"
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
+ )
+endmacro()
+
+# LIB_NAME maybe event_core, event_extra, event_openssl, event_pthreads or event.
+# Targets whose LIB_NAME is not 'event' should be exported and installed.
+macro(export_install_target TYPE LIB_NAME OUTER_INCLUDES)
+ if("${LIB_NAME}" STREQUAL "event")
+ install(TARGETS "${LIB_NAME}_${TYPE}"
+ LIBRARY DESTINATION "lib" COMPONENT lib
+ ARCHIVE DESTINATION "lib" COMPONENT lib
+ RUNTIME DESTINATION "lib" COMPONENT lib
+ COMPONENT dev
+ )
+ else()
+ string(REPLACE "event_" "" PURE_NAME ${LIB_NAME})
+ string(TOUPPER ${TYPE} UPPER_TYPE)
+ list(APPEND LIBEVENT_${UPPER_TYPE}_LIBRARIES "${PURE_NAME}")
+ set(OUTER_INCS)
+ if (NOT "${OUTER_INCLUDES}" STREQUAL "NONE")
+ set(OUTER_INCS ${OUTER_INCLUDES})
+ endif()
+ target_include_directories("${LIB_NAME}_${TYPE}"
+ PUBLIC "$<INSTALL_INTERFACE:include>"
+ "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+ "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
+ ${OUTER_INCS}
+ )
+ set_target_properties("${LIB_NAME}_${TYPE}" PROPERTIES EXPORT_NAME ${PURE_NAME})
+ export(TARGETS "${LIB_NAME}_${TYPE}"
+ NAMESPACE ${PROJECT_NAME}::
+ FILE "${PROJECT_BINARY_DIR}/LibeventTargets-${TYPE}.cmake"
+ APPEND
+ )
+ install(TARGETS "${LIB_NAME}_${TYPE}"
+ EXPORT LibeventTargets-${TYPE}
+ LIBRARY DESTINATION "lib" COMPONENT lib
+ ARCHIVE DESTINATION "lib" COMPONENT lib
+ RUNTIME DESTINATION "lib" COMPONENT lib
+ COMPONENT dev
+ )
+ endif()
+endmacro()
+
+# Global variables that it uses:
+# - EVENT_ABI_LIBVERSION
+# - EVENT_ABI_LIBVERSION_CURRENT
+# - EVENT_ABI_LIBVERSION_REVISION
+# - EVENT_ABI_LIBVERSION_AGE
+# - EVENT_PACKAGE_RELEASE
+# - CMAKE_THREAD_LIBS_INIT LIB_PLATFORM
+# - OPENSSL_LIBRARIES
+# - EVENT_SHARED_FLAGS
+# - EVENT_LIBRARY_STATIC
+# - EVENT_LIBRARY_SHARED
+#
+# Exported variables:
+# - LIBEVENT_SHARED_LIBRARIES
+# - LIBEVENT_STATIC_LIBRARIES
+macro(add_event_library LIB_NAME)
+ cmake_parse_arguments(LIB
+ "" # Options
+ "VERSION" # One val
+ "SOURCES;LIBRARIES;INNER_LIBRARIES;OUTER_INCLUDES" # Multi val
+ ${ARGN}
+ )
+
+ if ("${LIB_OUTER_INCLUDES}" STREQUAL "")
+ set(LIB_OUTER_INCLUDES NONE)
+ endif()
+ set(ADD_EVENT_LIBRARY_INTERFACE)
+
+ if (${EVENT_LIBRARY_STATIC})
+ add_library("${LIB_NAME}_static" STATIC ${LIB_SOURCES})
+ set_target_properties("${LIB_NAME}_static" PROPERTIES
+ OUTPUT_NAME "${LIB_NAME}"
+ CLEAN_DIRECT_OUTPUT 1)
+
+ if(LIB_INNER_LIBRARIES)
+ set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_static")
+ endif()
+ target_link_libraries("${LIB_NAME}_static"
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${LIB_PLATFORM}
+ ${INNER_LIBRARIES}
+ ${LIB_LIBRARIES})
+
+ export_install_target(static "${LIB_NAME}" "${LIB_OUTER_INCLUDES}")
+
+ set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_static")
+ endif()
+
+ if (${EVENT_LIBRARY_SHARED})
+ add_library("${LIB_NAME}_shared" SHARED ${LIB_SOURCES})
+
+ if(LIB_INNER_LIBRARIES)
+ set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_shared")
+ endif()
+ target_link_libraries("${LIB_NAME}_shared"
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${LIB_PLATFORM}
+ ${INNER_LIBRARIES}
+ ${LIB_LIBRARIES})
+
+ if (EVENT_SHARED_FLAGS)
+ set_event_shared_lib_flags("${LIB_NAME}" "${EVENT_SHARED_FLAGS}")
+ endif()
+
+ if (WIN32)
+ set_target_properties(
+ "${LIB_NAME}_shared" PROPERTIES
+ OUTPUT_NAME "${LIB_NAME}"
+ SOVERSION ${EVENT_ABI_LIBVERSION})
+ elseif (APPLE)
+ math(EXPR COMPATIBILITY_VERSION "${EVENT_ABI_LIBVERSION_CURRENT}+1")
+ math(EXPR CURRENT_MINUS_AGE "${EVENT_ABI_LIBVERSION_CURRENT}-${EVENT_ABI_LIBVERSION_AGE}")
+ set_target_properties(
+ "${LIB_NAME}_shared" PROPERTIES
+ OUTPUT_NAME "${LIB_NAME}-${EVENT_PACKAGE_RELEASE}.${CURRENT_MINUS_AGE}"
+ INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
+ LINK_FLAGS "-compatibility_version ${COMPATIBILITY_VERSION} -current_version ${COMPATIBILITY_VERSION}.${EVENT_ABI_LIBVERSION_REVISION}")
+ else()
+ math(EXPR CURRENT_MINUS_AGE "${EVENT_ABI_LIBVERSION_CURRENT}-${EVENT_ABI_LIBVERSION_AGE}")
+ set_target_properties(
+ "${LIB_NAME}_shared" PROPERTIES
+ OUTPUT_NAME "${LIB_NAME}-${EVENT_PACKAGE_RELEASE}"
+ VERSION "${CURRENT_MINUS_AGE}.${EVENT_ABI_LIBVERSION_AGE}.${EVENT_ABI_LIBVERSION_REVISION}"
+ SOVERSION "${CURRENT_MINUS_AGE}"
+ INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+ endif()
+
+ if (NOT WIN32)
+ set(LIB_LINK_NAME
+ "${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+
+ add_custom_command(TARGET ${LIB_NAME}_shared
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ "$<TARGET_FILE_NAME:${LIB_NAME}_shared>"
+ "${LIB_LINK_NAME}"
+ WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+ endif()
+
+ export_install_target(shared "${LIB_NAME}" "${LIB_OUTER_INCLUDES}")
+
+ set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_shared")
+
+ if (NOT WIN32)
+ install(FILES
+ "$<TARGET_FILE_DIR:${LIB_NAME}_shared>/${LIB_LINK_NAME}"
+ DESTINATION "lib"
+ COMPONENT lib)
+ endif()
+ endif()
+
+ add_library(${LIB_NAME} INTERFACE)
+ target_link_libraries(${LIB_NAME} INTERFACE ${ADD_EVENT_LIBRARY_INTERFACE})
+
+ generate_pkgconfig("${LIB_NAME}")
+endmacro()
diff --git a/libevent/cmake/COPYING-CMAKE-SCRIPTS b/libevent/cmake/COPYING-CMAKE-SCRIPTS
new file mode 100644
index 0000000..ab3c4d2
--- /dev/null
+++ b/libevent/cmake/COPYING-CMAKE-SCRIPTS
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/libevent/cmake/CheckConstExists.cmake b/libevent/cmake/CheckConstExists.cmake
new file mode 100644
index 0000000..de07458
--- /dev/null
+++ b/libevent/cmake/CheckConstExists.cmake
@@ -0,0 +1,25 @@
+include(CheckCSourceCompiles)
+
+macro(check_const_exists CONST FILES VARIABLE)
+ if (NOT DEFINED ${VARIABLE})
+ set(check_const_exists_source "")
+ foreach(file ${FILES})
+ set(check_const_exists_source
+ "${check_const_exists_source}
+ #include <${file}>")
+ endforeach()
+ set(check_const_exists_source
+ "${check_const_exists_source}
+ int main() { (void)${CONST}; return 0; }")
+
+ check_c_source_compiles("${check_const_exists_source}" ${VARIABLE})
+
+ if (${${VARIABLE}})
+ set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}")
+ message(STATUS "Looking for ${CONST} - found")
+ else()
+ set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}")
+ message(STATUS "Looking for ${CONST} - not found")
+ endif()
+ endif()
+endmacro(check_const_exists)
diff --git a/libevent/cmake/CheckFileOffsetBits.c b/libevent/cmake/CheckFileOffsetBits.c
new file mode 100644
index 0000000..d948fec
--- /dev/null
+++ b/libevent/cmake/CheckFileOffsetBits.c
@@ -0,0 +1,14 @@
+#include <sys/types.h>
+
+#define KB ((off_t)1024)
+#define MB ((off_t)1024 * KB)
+#define GB ((off_t)1024 * MB)
+#define TB ((off_t)1024 * GB)
+int t2[(((64 * GB -1) % 671088649) == 268434537)
+ && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];
+
+int main()
+{
+ ;
+ return 0;
+}
diff --git a/libevent/cmake/CheckFileOffsetBits.cmake b/libevent/cmake/CheckFileOffsetBits.cmake
new file mode 100644
index 0000000..1253440
--- /dev/null
+++ b/libevent/cmake/CheckFileOffsetBits.cmake
@@ -0,0 +1,43 @@
+# - Check if _FILE_OFFSET_BITS macro needed for large files
+# CHECK_FILE_OFFSET_BITS ()
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+# Copyright (c) 2009, Michihiro NAKAJIMA
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+#INCLUDE(CheckCSourceCompiles)
+
+GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
+ "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+MACRO (CHECK_FILE_OFFSET_BITS)
+ IF(NOT DEFINED _FILE_OFFSET_BITS)
+ MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files")
+ TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
+ IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+ TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
+ ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+
+ IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+ SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
+ MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed")
+ ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+ SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
+ MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed")
+ ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+ ENDIF(NOT DEFINED _FILE_OFFSET_BITS)
+
+ENDMACRO (CHECK_FILE_OFFSET_BITS)
diff --git a/libevent/cmake/CheckFunctionKeywords.cmake b/libevent/cmake/CheckFunctionKeywords.cmake
new file mode 100644
index 0000000..3d968b8
--- /dev/null
+++ b/libevent/cmake/CheckFunctionKeywords.cmake
@@ -0,0 +1,14 @@
+include(CheckCSourceCompiles)
+
+macro(check_function_keywords _wordlist)
+ set(${_result} "")
+ foreach(flag ${_wordlist})
+ string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}")
+ string(TOUPPER "${flagname}" flagname)
+ set(have_flag "HAVE_${flagname}")
+ check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag})
+ if(${have_flag} AND NOT ${_result})
+ set(${_result} "${flag}")
+ endif(${have_flag} AND NOT ${_result})
+ endforeach(flag)
+endmacro(check_function_keywords)
diff --git a/libevent/cmake/CheckPrototypeDefinition.c.in b/libevent/cmake/CheckPrototypeDefinition.c.in
new file mode 100644
index 0000000..a97344a
--- /dev/null
+++ b/libevent/cmake/CheckPrototypeDefinition.c.in
@@ -0,0 +1,29 @@
+@CHECK_PROTOTYPE_DEFINITION_HEADER@
+
+static void cmakeRequireSymbol(int dummy, ...) {
+ (void) dummy;
+}
+
+static void checkSymbol(void) {
+#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
+ cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
+#endif
+}
+
+@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
+ return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
+}
+
+#ifdef __CLASSIC_C__
+int main() {
+ int ac;
+ char*av[];
+#else
+int main(int ac, char *av[]) {
+#endif
+ checkSymbol();
+ if (ac > 1000) {
+ return *av[0];
+ }
+ return 0;
+}
diff --git a/libevent/cmake/CheckPrototypeDefinition.cmake b/libevent/cmake/CheckPrototypeDefinition.cmake
new file mode 100644
index 0000000..940d1ff
--- /dev/null
+++ b/libevent/cmake/CheckPrototypeDefinition.cmake
@@ -0,0 +1,82 @@
+# - Check if the protoype we expect is correct.
+# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
+#
+# FUNCTION - The name of the function (used to check if prototype exists)
+# PROTOTYPE- The prototype to check.
+# RETURN - The return value of the function.
+# HEADER - The header files required.
+# VARIABLE - The variable to store the result.
+#
+# Example:
+#
+# check_prototype_definition(getpwent_r
+# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
+# "NULL"
+# "unistd.h;pwd.h"
+# SOLARIS_GETPWENT_R)
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+
+
+function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+ if (${_VARIABLE} MATCHES "^${_VARIABLE}$")
+ set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
+
+ set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ if (CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS
+ "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+ else(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS)
+ endif(CMAKE_REQUIRED_LIBRARIES)
+ if (CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES)
+ endif(CMAKE_REQUIRED_INCLUDES)
+
+ foreach(_FILE ${_HEADER})
+ set(CHECK_PROTOTYPE_DEFINITION_HEADER
+ "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
+ endforeach(_FILE)
+
+ set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
+ set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
+ set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
+
+ configure_file("${PROJECT_SOURCE_DIR}/cmake/CheckPrototypeDefinition.c.in"
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
+
+ file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
+
+ try_compile(${_VARIABLE}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
+ "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
+ "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ if (${_VARIABLE})
+ set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
+ "${OUTPUT}\n\n")
+ else (${_VARIABLE})
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+ set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
+ "${OUTPUT}\n\n${_SOURCE}\n\n")
+ endif (${_VARIABLE})
+ endif()
+endfunction(CHECK_PROTOTYPE_DEFINITION)
diff --git a/libevent/cmake/CheckWorkingKqueue.cmake b/libevent/cmake/CheckWorkingKqueue.cmake
new file mode 100644
index 0000000..f22f011
--- /dev/null
+++ b/libevent/cmake/CheckWorkingKqueue.cmake
@@ -0,0 +1,52 @@
+include(CheckCSourceRuns)
+
+check_c_source_runs(
+"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/event.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int
+main(int argc, char **argv)
+{
+ int kq;
+ int n;
+ int fd[2];
+ struct kevent ev;
+ struct timespec ts;
+ char buf[80000];
+
+ if (pipe(fd) == -1)
+ exit(1);
+ if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
+ exit(1);
+
+ while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
+ ;
+
+ if ((kq = kqueue()) == -1)
+ exit(1);
+
+ memset(&ev, 0, sizeof(ev));
+ ev.ident = fd[1];
+ ev.filter = EVFILT_WRITE;
+ ev.flags = EV_ADD | EV_ENABLE;
+ n = kevent(kq, &ev, 1, NULL, 0, NULL);
+ if (n == -1)
+ exit(1);
+
+ read(fd[0], buf, sizeof(buf));
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+ n = kevent(kq, NULL, 0, &ev, 1, &ts);
+ if (n == -1 || n == 0)
+ exit(1);
+
+ exit(0);
+}
+
+" EVENT__HAVE_WORKING_KQUEUE)
diff --git a/libevent/cmake/CodeCoverage.cmake b/libevent/cmake/CodeCoverage.cmake
new file mode 100644
index 0000000..eba85b3
--- /dev/null
+++ b/libevent/cmake/CodeCoverage.cmake
@@ -0,0 +1,165 @@
+#
+# Boost Software License - Version 1.0 - August 17th, 2003
+#
+# Permission is hereby granted, free of charge, to any person or organization
+# obtaining a copy of the software and accompanying documentation covered by
+# this license (the "Software") to use, reproduce, display, distribute,
+# execute, and transmit the Software, and to prepare derivative works of the
+# Software, and to permit third-parties to whom the Software is furnished to
+# do so, all subject to the following:
+#
+# The copyright notices in the Software and this entire statement, including
+# the above license grant, this restriction and the following disclaimer,
+# must be included in all copies of the Software, in whole or in part, and
+# all derivative works of the Software, unless such copies or derivative
+# works are solely in the form of machine-executable object code generated by
+# a source language processor.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+# 2012-01-31, Lars Bilke
+# - Enable Code Coverage
+#
+# 2013-09-17, Joakim Söderberg
+# - Added support for Clang.
+# - Some additional usage instructions.
+#
+# 2016-11-02, Azat Khuzhin
+# - Adopt for C compiler only (libevent)
+#
+# USAGE:
+# 1. Copy this file into your cmake modules path.
+#
+# 2. Add the following line to your CMakeLists.txt:
+# INCLUDE(CodeCoverage)
+#
+# 3. Set compiler flags to turn off optimization and enable coverage:
+# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+#
+# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
+# which runs your test executable and produces a lcov code coverage report:
+# Example:
+# SETUP_TARGET_FOR_COVERAGE(
+# my_coverage_target # Name for custom target.
+# test_driver # Name of the test driver executable that runs the tests.
+# # NOTE! This should always have a ZERO as exit code
+# # otherwise the coverage generation will not complete.
+# coverage # Name of output directory.
+# )
+#
+# 4. Build a Debug build:
+# cmake -DCMAKE_BUILD_TYPE=Debug ..
+# make
+# make my_coverage_target
+#
+#
+
+# Check prereqs
+FIND_PROGRAM( GCOV_PATH gcov )
+FIND_PROGRAM( LCOV_PATH lcov )
+FIND_PROGRAM( GENHTML_PATH genhtml )
+FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
+
+IF(NOT GCOV_PATH)
+ MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
+ENDIF() # NOT GCOV_PATH
+
+IF(NOT CMAKE_COMPILER_IS_GNUCC)
+ # Clang version 3.0.0 and greater now supports gcov as well.
+ MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.")
+
+ IF(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+ ENDIF()
+ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC
+
+IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
+ MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
+ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
+
+
+# Param _targetname The name of new the custom make target
+# Param _testrunner The name of the target which runs the tests.
+# MUST return ZERO always, even on errors.
+# If not, no coverage report will be created!
+# Param _outputname lcov output is generated as _outputname.info
+# HTML report is generated in _outputname/index.html
+# Optional fourth parameter is passed as arguments to _testrunner
+# Pass them in list form, e.g.: "-j;2" for -j 2
+FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
+
+ IF(NOT LCOV_PATH)
+ MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
+ ENDIF() # NOT LCOV_PATH
+
+ IF(NOT GENHTML_PATH)
+ MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
+ ENDIF() # NOT GENHTML_PATH
+
+ # Setup target
+ ADD_CUSTOM_TARGET(${_targetname}
+
+ # Cleanup lcov
+ ${LCOV_PATH} --directory . --zerocounters
+
+ # Run tests
+ COMMAND ${_testrunner} ${ARGV3}
+
+ # Capturing lcov counters and generating report
+ COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
+ COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned
+ COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
+ COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
+
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
+ )
+
+ # Show info where to find the report
+ ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
+ COMMAND ;
+ COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
+ )
+
+ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
+
+# Param _targetname The name of new the custom make target
+# Param _testrunner The name of the target which runs the tests
+# Param _outputname cobertura output is generated as _outputname.xml
+# Optional fourth parameter is passed as arguments to _testrunner
+# Pass them in list form, e.g.: "-j;2" for -j 2
+FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
+
+ IF(NOT PYTHON_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "Python not found! Aborting...")
+ ENDIF() # NOT PYTHON_EXECUTABLE
+
+ IF(NOT GCOVR_PATH)
+ MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
+ ENDIF() # NOT GCOVR_PATH
+
+ ADD_CUSTOM_TARGET(${_targetname}
+
+ # Run tests
+ ${_testrunner} ${ARGV3}
+
+ # Running gcovr
+ COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Running gcovr to produce Cobertura code coverage report."
+ )
+
+ # Show info where to find the report
+ ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
+ COMMAND ;
+ COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
+ )
+
+ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
diff --git a/libevent/cmake/Copyright.txt b/libevent/cmake/Copyright.txt
new file mode 100644
index 0000000..813124f
--- /dev/null
+++ b/libevent/cmake/Copyright.txt
@@ -0,0 +1,57 @@
+CMake - Cross Platform Makefile Generator
+Copyright 2000-2013 Kitware, Inc.
+Copyright 2000-2011 Insight Software Consortium
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+* Neither the names of Kitware, Inc., the Insight Software Consortium,
+ nor the names of their contributors may be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+------------------------------------------------------------------------------
+
+The above copyright and license notice applies to distributions of
+CMake in source and binary form. Some source files contain additional
+notices of original copyright by their contributors; see each source
+for details. Third-party software packages supplied with CMake under
+compatible licenses provide their own copyright notices documented in
+corresponding subdirectories.
+
+------------------------------------------------------------------------------
+
+CMake was initially developed by Kitware with the following sponsorship:
+
+ * National Library of Medicine at the National Institutes of Health
+ as part of the Insight Segmentation and Registration Toolkit (ITK).
+
+ * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
+ Visualization Initiative.
+
+ * National Alliance for Medical Image Computing (NAMIC) is funded by the
+ National Institutes of Health through the NIH Roadmap for Medical Research,
+ Grant U54 EB005149.
+
+ * Kitware, Inc. \ No newline at end of file
diff --git a/libevent/cmake/LibeventConfig.cmake.in b/libevent/cmake/LibeventConfig.cmake.in
new file mode 100644
index 0000000..7b808c3
--- /dev/null
+++ b/libevent/cmake/LibeventConfig.cmake.in
@@ -0,0 +1,183 @@
+# - Config file for the Libevent package
+# It defines the following variables
+# LIBEVENT_FOUND - true if libevent and all required components found on the system
+# LIBEVENT_xxx_FOUND - true if component xxx(see available components) found on the system
+# LIBEVENT_VERSION - libevent version in format Major.Minor.Patch
+# LIBEVENT_INCLUDE_DIRS - directories where libevent header is located.
+# LIBEVENT_INCLUDE_DIR - same as DIRS
+# LIBEVENT_LIBRARIES - libevent library to link against.
+# LIBEVENT_LIBRARY - same as LIBRARIES
+#
+# These variables are deprecated, don't use them.
+# LIBEVENT_STATIC_LIBRARIES - libraries to link against (archive/static)
+# LIBEVENT_SHARED_LIBRARIES - libraries to link against (shared)
+#
+# When you try to locate the libevent libraries, you should specify which components you want to use.
+# The following table lists all available components. If none is given, all imported targets will used.
+# core - the core functons of libevent
+# extra - extra functions, contains http, dns and rpc
+# pthreads - multiple threads for libevent, not exists on Windows
+# openssl - openssl support for libevent
+#
+# By default, the shared libraries of libevent will be found. To find the static ones instead,
+# you must set the LIBEVENT_STATIC_LINK variable to TRUE before calling find_package(Libevent ...).
+# If no component provided, all components will be used.
+# example:
+# set(LIBEVENT_STATIC_LINK TRUE)
+# find_package(Libevent 2.2 REQUIRED COMPONENTS core)
+# include_directories(${LIBEVENT_INCLUDE_DIRS}) # Can be omitted
+# target_link_libraries(myapp ${LIBEVENT_LIBRARIES})
+# or target_link_libraries(myapp libevent::core)
+#
+# find_package() can handle dependencies automatically. For example, given the 'openssl' component,
+# all dependencies (libevent_core, libssl, libcrypto and openssl include directories) will be found.
+
+set(CONFIG_FOR_INSTALL_TREE @CONFIG_FOR_INSTALL_TREE@)
+
+set(LIBEVENT_VERSION @EVENT_PACKAGE_VERSION@)
+
+# IMPORTED targets from LibeventTargets.cmake
+set(LIBEVENT_STATIC_LIBRARIES "@LIBEVENT_STATIC_LIBRARIES@")
+set(LIBEVENT_SHARED_LIBRARIES "@LIBEVENT_SHARED_LIBRARIES@")
+
+# Default to the same type as libevent was built:
+if(NOT DEFINED LIBEVENT_STATIC_LINK)
+ set(LIBEVENT_STATIC_LINK NOT @EVENT_LIBRARY_SHARED@)
+endif()
+
+set(CMAKE_FIND_LIBRARY_SUFFIXES_SAVE "${CMAKE_FIND_LIBRARY_SUFFIXES}")
+if(${LIBEVENT_STATIC_LINK})
+ set(_LIB_TYPE static)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+ set(_AVAILABLE_LIBS "${LIBEVENT_STATIC_LIBRARIES}")
+else()
+ set(_LIB_TYPE shared)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(_AVAILABLE_LIBS "${LIBEVENT_SHARED_LIBRARIES}")
+endif()
+
+# Get the path of the current file.
+get_filename_component(LIBEVENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_INSTALL_PREFIX "${LIBEVENT_CMAKE_DIR}/../../.." ABSOLUTE)
+
+macro(message_if_needed _flag _msg)
+ if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ message(${_flag} "${_msg}")
+ endif()
+endmacro()
+
+macro(no_component_msg _comp)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_comp})
+ set(pthreadlib)
+ if(NOT WIN32)
+ set(pthreadlib ", pthreads")
+ endif()
+ message(FATAL_ERROR "Your libevent library does not contain a ${_comp} component!\n"
+ "The valid components are core, extra${pthreadlib} and openssl.")
+ else()
+ message_if_needed(WARNING "Your libevent library does not contain a ${_comp} component!")
+ endif()
+endmacro()
+
+set(_EVENT_COMPONENTS)
+if(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
+ list(REMOVE_DUPLICATES ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
+ foreach(_comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
+ list(FIND _AVAILABLE_LIBS ${_comp} _INDEX)
+ if(_INDEX GREATER -1)
+ list(APPEND _EVENT_COMPONENTS ${_comp})
+ else()
+ no_component_msg(${_comp})
+ endif()
+ endforeach()
+else()
+ set(_EVENT_COMPONENTS ${_AVAILABLE_LIBS})
+endif()
+
+set(_POSSIBLE_PKG_NAMES)
+list(APPEND _POSSIBLE_PKG_NAMES ${CMAKE_FIND_PACKAGE_NAME} LIBEVENT Libevent libevent)
+list(REMOVE_DUPLICATES _POSSIBLE_PKG_NAMES)
+
+macro(set_case_insensitive_found _comp)
+ foreach(name ${_POSSIBLE_PKG_NAMES})
+ if("${_comp}" STREQUAL "")
+ set(${name}_FOUND TRUE)
+ set(${name}_NOTFOUND FALSE)
+ else()
+ set(${name}_${_comp}_FOUND TRUE)
+ set(${name}_${_comp}_NOTFOUND FALSE)
+ endif()
+ endforeach()
+endmacro()
+
+if(CONFIG_FOR_INSTALL_TREE)
+ ## Config for install tree ----------------------------------------
+ # Find includes
+ unset(_event_h CACHE)
+ find_path(_event_h
+ NAMES event2/event.h
+ PATHS "${_INSTALL_PREFIX}/include"
+ NO_DEFAULT_PATH)
+ if(_event_h)
+ set(LIBEVENT_INCLUDE_DIRS "${_event_h}")
+ message_if_needed(STATUS "Found libevent include directory: ${_event_h}")
+ else()
+ message_if_needed(WARNING "Your libevent library does not contain header files!")
+ endif()
+
+ # Find libraries
+ macro(find_event_lib _comp)
+ unset(_event_lib CACHE)
+ find_library(_event_lib
+ NAMES "event_${_comp}"
+ PATHS "${_INSTALL_PREFIX}/lib"
+ NO_DEFAULT_PATH)
+ if(_event_lib)
+ list(APPEND LIBEVENT_LIBRARIES "libevent::${_comp}")
+ set_case_insensitive_found(${_comp})
+ message_if_needed(STATUS "Found libevent component: ${_event_lib}")
+ else()
+ no_component_msg(${_comp})
+ endif()
+ endmacro()
+
+ foreach(comp ${_EVENT_COMPONENTS})
+ find_event_lib(${comp})
+ endforeach()
+else()
+ ## Config for build tree ----------------------------------------
+ set(LIBEVENT_INCLUDE_DIRS "@EVENT__INCLUDE_DIRS@")
+ foreach(_comp ${_EVENT_COMPONENTS})
+ list(APPEND LIBEVENT_LIBRARIES "libevent::${_comp}")
+ set_case_insensitive_found(${_comp})
+ endforeach()
+endif()
+
+set(LIBEVENT_INCLUDE_DIR ${LIBEVENT_INCLUDE_DIRS})
+if(LIBEVENT_LIBRARIES)
+ set(LIBEVENT_LIBRARY ${LIBEVENT_LIBRARIES})
+ if(CONFIG_FOR_INSTALL_TREE)
+ message_if_needed(STATUS "Found libevent ${LIBEVENT_VERSION} in ${_INSTALL_PREFIX}")
+ else()
+ message_if_needed(STATUS "Found libevent ${LIBEVENT_VERSION} in ${LIBEVENT_CMAKE_DIR}")
+ endif()
+
+ # Avoid including targets more than one times
+ if(NOT TARGET event_core_${_LIB_TYPE})
+ # Include the project Targets file, this contains definitions for IMPORTED targets.
+ include(${LIBEVENT_CMAKE_DIR}/LibeventTargets-${_LIB_TYPE}.cmake)
+ endif()
+else()
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ message(FATAL_ERROR "Can not find any libraries for libevent.")
+ else()
+ message_if_needed(WARNING "Can not find any libraries for libevent.")
+ endif()
+endif()
+
+set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES_SAVE}")
+unset(_LIB_TYPE)
+unset(_AVAILABLE_LIBS)
+unset(_EVENT_COMPONENTS)
+unset(_POSSIBLE_PKG_NAMES)
+unset(_INSTALL_PREFIX)
diff --git a/libevent/cmake/LibeventConfigVersion.cmake.in b/libevent/cmake/LibeventConfigVersion.cmake.in
new file mode 100644
index 0000000..56371a8
--- /dev/null
+++ b/libevent/cmake/LibeventConfigVersion.cmake.in
@@ -0,0 +1,11 @@
+set(PACKAGE_VERSION "@EVENT_PACKAGE_VERSION@")
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/libevent/cmake/Macros.cmake b/libevent/cmake/Macros.cmake
new file mode 100644
index 0000000..e480bbf
--- /dev/null
+++ b/libevent/cmake/Macros.cmake
@@ -0,0 +1,36 @@
+include(CheckSymbolExists)
+include(CheckIncludeFiles)
+
+# Check if each symbol in the symbol list exists,
+# and define PREFIX__HAVE_SYMNAME to 1 if yes.
+#
+# SYMLIST: list of symbols to check
+# HEADERS: header files to be included in check code
+# PREFIX: the prefix of definition
+macro(CHECK_SYMBOLS_EXIST SYMLIST HEADERS PREFIX)
+ foreach(SYMNAME ${SYMLIST})
+ string(TOUPPER "${SYMNAME}" SYMNAME_UPPER)
+ if ("${PREFIX}" STREQUAL "")
+ set(HAVE_SYM_DEF "HAVE_${SYMNAME_UPPER}")
+ else()
+ set(HAVE_SYM_DEF "${PREFIX}__HAVE_${SYMNAME_UPPER}")
+ endif()
+ CHECK_SYMBOL_EXISTS(${SYMNAME} "${HEADERS}" ${HAVE_SYM_DEF})
+ endforeach()
+endmacro()
+
+# Check if file exists, define PREFIX__HAVE_FILE to 1 if yes,
+# and collect file to EVENT_INCLUDES
+macro(CHECK_INCLUDE_FILE_CONCAT FILE PREFIX)
+ string(REGEX REPLACE "[./]" "_" FILE_UL ${FILE})
+ string(TOUPPER "${FILE_UL}" FILE_UL_UPPER)
+ if ("${PREFIX}" STREQUAL "")
+ set(HAVE_FILE_DEF "HAVE_${FILE_UL_UPPER}")
+ else()
+ set(HAVE_FILE_DEF "${PREFIX}__HAVE_${FILE_UL_UPPER}")
+ endif()
+ CHECK_INCLUDE_FILES("${EVENT_INCLUDES};${FILE}" ${HAVE_FILE_DEF})
+ if(${HAVE_FILE_DEF})
+ set(EVENT_INCLUDES ${EVENT_INCLUDES} ${FILE})
+ endif()
+endmacro()
diff --git a/libevent/cmake/Uninstall.cmake.in b/libevent/cmake/Uninstall.cmake.in
new file mode 100644
index 0000000..c6dc09e
--- /dev/null
+++ b/libevent/cmake/Uninstall.cmake.in
@@ -0,0 +1,23 @@
+# https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
+
+if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/libevent/cmake/UseDoxygen.cmake b/libevent/cmake/UseDoxygen.cmake
new file mode 100644
index 0000000..3b60d5a
--- /dev/null
+++ b/libevent/cmake/UseDoxygen.cmake
@@ -0,0 +1,111 @@
+# Use FindDoxygen.cmake to generate documentation.
+
+option(DOXYGEN_GENERATE_HTML "Generate HTML" ON)
+option(DOXYGEN_GENERATE_MAN "Generate man pages" OFF)
+option(DOXYGEN_MAN_LINKS "Generate man links" ON)
+option(DOXYGEN_GENERATE_LATEX "Generate LaTeX" OFF)
+
+# If the case-insensitive value of the cmake option is one of
+# "off, no, false" or 0, it is equal to false, otherwise true.
+# And the values of the doxygen config does not exactly match it.
+# So we need to convert the cmake option to a doxygen config.
+macro(_convert_to_dx_cfg CMK_OPTION)
+ if (${CMK_OPTION})
+ set(${CMK_OPTION} YES)
+ else()
+ set(${CMK_OPTION} NO)
+ endif()
+endmacro()
+
+macro(UseDoxygen)
+ if (${CMAKE_VERSION} VERSION_LESS "3.9")
+ # Old versions of cmake have poor support for Doxygen generation.
+ message(FATAL_ERROR "Doxygen generation only enabled for cmake 3.9 and higher")
+ else()
+ find_package(Doxygen)
+ if (DOXYGEN_FOUND)
+ set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
+ set(DOXYGEN_PROJECT_NUMBER ${EVENT_PACKAGE_VERSION})
+ set(DOXYGEN_PROJECT_BRIEF "Event notification library")
+ set(DOXYGEN_OUTPUT_DIRECTORY doxygen)
+ set(DOXYGEN_STRIP_FROM_PATH include)
+ set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
+ set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
+ set(DOXYGEN_SORT_BRIEF_DOCS YES)
+ set(DOXYGEN_RECURSIVE NO)
+
+ _convert_to_dx_cfg(DOXYGEN_GENERATE_HTML)
+ _convert_to_dx_cfg(DOXYGEN_GENERATE_MAN)
+ _convert_to_dx_cfg(DOXYGEN_MAN_LINKS)
+ _convert_to_dx_cfg(DOXYGEN_GENERATE_LATEX)
+
+ set(DOXYGEN_LATEX_CMD_NAME latex)
+ set(DOXYGEN_PAPER_TYPE a4wide)
+ set(DOXYGEN_PDF_HYPERLINKS NO)
+
+ set(DOXYGEN_GENERATE_RTF NO)
+ set(DOXYGEN_GENERATE_XML NO)
+ set(DOXYGEN_GENERATE_CHI NO)
+
+ set(DOXYGEN_PREDEFINED TAILQ_ENTRY
+ RB_ENTRY
+ EVENT_DEFINED_TQENTRY_
+ EVENT_IN_DOXYGEN_
+ )
+
+ set(DOX_INPUT include/event2/buffer.h
+ include/event2/buffer_compat.h
+ include/event2/bufferevent.h
+ include/event2/bufferevent_compat.h
+ include/event2/bufferevent_ssl.h
+ include/event2/dns.h
+ include/event2/dns_compat.h
+ include/event2/event.h
+ include/event2/event_compat.h
+ include/event2/http.h
+ include/event2/http_compat.h
+ include/event2/listener.h
+ include/event2/rpc.h
+ include/event2/rpc_compat.h
+ include/event2/tag.h
+ include/event2/tag_compat.h
+ include/event2/thread.h
+ include/event2/util.h
+ )
+ # Add 'doxygen' target
+ doxygen_add_docs(doxygen
+ ${DOX_INPUT}
+ ALL
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Generating doxygen documentation for ${PROJECT_NAME}..."
+ )
+
+ # Use 'make clean' to remove the generated directory
+ set_property(DIRECTORY
+ PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ "${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}"
+ )
+
+ # Install html into <prefix>/share/doc/<project>
+ if ("${DOXYGEN_GENERATE_HTML}" STREQUAL "YES")
+ install(DIRECTORY
+ ${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}/html
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}
+ COMPONENT doc
+ )
+ endif()
+
+ # Install manual into <prefix>/share/man/man3
+ if ("${DOXYGEN_GENERATE_MAN}" STREQUAL "YES")
+ install(DIRECTORY
+ ${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}/man/man3
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man
+ COMPONENT doc
+ )
+ endif()
+
+ else(DOXYGEN_FOUND)
+ message(FATAL_ERROR "Doxygen command not found, set EVENT__DOXYGEN to disable")
+ endif (DOXYGEN_FOUND)
+ endif()
+endmacro()
diff --git a/libevent/cmake/VersionViaGit.cmake b/libevent/cmake/VersionViaGit.cmake
new file mode 100644
index 0000000..24eb6af
--- /dev/null
+++ b/libevent/cmake/VersionViaGit.cmake
@@ -0,0 +1,66 @@
+# This module defines the following variables utilizing
+# git to determine the parent tag. And if found the macro
+# will attempt to parse them in the github tag fomat
+#
+# Useful for auto-versioning in our CMakeLists
+#
+# EVENT_GIT___VERSION_MAJOR - Major version.
+# EVENT_GIT___VERSION_MINOR - Minor version
+# EVENT_GIT___VERSION_STAGE - Stage version
+#
+# Example usage:
+#
+# event_fuzzy_version_from_git()
+# message("Libvent major=${EVENT_GIT___VERSION_MAJOR}")
+# message(" minor=${EVENT_GIT___VERSION_MINOR}")
+# message(" patch=${EVENT_GIT___VERSION_PATCH}")
+# message(" stage=${EVENT_GIT___VERSION_STAGE}")
+# endif()
+
+include(FindGit)
+
+macro(event_fuzzy_version_from_git)
+ # set our defaults.
+ set(EVENT_GIT___VERSION_MAJOR 2)
+ set(EVENT_GIT___VERSION_MINOR 1)
+ set(EVENT_GIT___VERSION_PATCH 12)
+ set(EVENT_GIT___VERSION_STAGE "stable")
+
+ find_package(Git)
+
+ if (GIT_FOUND)
+ execute_process(
+ COMMAND
+ ${GIT_EXECUTABLE} describe --abbrev=0 --always
+ WORKING_DIRECTORY
+ ${PROJECT_SOURCE_DIR}
+ RESULT_VARIABLE
+ GITRET
+ OUTPUT_VARIABLE
+ GITVERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ string(REGEX REPLACE "[\\._-]" ";" VERSION_LIST "${GITVERSION}")
+ if(VERSION_LIST)
+ list(LENGTH VERSION_LIST VERSION_LIST_LENGTH)
+ endif()
+
+ if ((GITRET EQUAL 0) AND (VERSION_LIST_LENGTH EQUAL 5))
+ list(GET VERSION_LIST 1 _MAJOR)
+ list(GET VERSION_LIST 2 _MINOR)
+ list(GET VERSION_LIST 3 _PATCH)
+ list(GET VERSION_LIST 4 _STAGE)
+
+ set(_DEFAULT_VERSION "${EVENT_GIT___VERSION_MAJOR}.${EVENT_GIT___VERSION_MINOR}.${EVENT_GIT___VERSION_PATCH}-${EVENT_GIT___VERSION_STAGE}")
+ set(_GIT_VERSION "${_MAJOR}.${_MINOR}.${_PATCH}-${_STAGE}")
+
+ if (${_DEFAULT_VERSION} VERSION_LESS ${_GIT_VERSION})
+ set(EVENT_GIT___VERSION_MAJOR ${_MAJOR})
+ set(EVENT_GIT___VERSION_MINOR ${_MINOR})
+ set(EVENT_GIT___VERSION_PATCH ${_PATCH})
+ set(EVENT_GIT___VERSION_STAGE ${_STAGE})
+ endif()
+ endif()
+ endif()
+endmacro()