#
# Libevent CMake project
#
-# Based on initial work by:
+# Based on initial work by:
# Alexey Ozeritsky
#
# Additional changes:
# Brodie Thiesfield
-# Joakim Soderberg
+# Joakim Soderberg
# Trond Norbye
+# Sergei Nikulov
#
# Build example:
#
# TODO: Add --disable-largefile omit support for large files
# Put the libaries and binaries that get built into directories at the
-# top of the build tree rather than in hard-to-find leaf directories.
+# top of the build tree rather than in hard-to-find leaf directories.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug")
endif()
-
+
message("Setting coverage compiler flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endif()
CHECK_FUNCTION_EXISTS_EX(gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R)
if(EVENT__HAVE_GETHOSTBYNAME_R)
- CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
+ CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
"int gethostbyname_r(const char *name, struct hostent *hp, struct hostent_data *hdata)"
"0"
"netdb.h"
EVENT__HAVE_GETHOSTBYNAME_R_3_ARG)
- CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
+ CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
"struct hostent *gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, int *herr)"
"NULL"
"netdb.h"
EVENT__HAVE_GETHOSTBYNAME_R_5_ARG)
- CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
+ CHECK_PROTOTYPE_DEFINITION(gethostbyname_r
"int gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, struct hostent **result, int *herr)"
"0"
"netdb.h"
defer-internal.h
epolltable-internal.h
evbuffer-internal.h
- include/evdns.h
event-internal.h
- include/event.h
- include/evhttp.h
evmap-internal.h
evrpc-internal.h
- include/evrpc.h
evsignal-internal.h
evthread-internal.h
- include/evutil.h
ht-internal.h
http-internal.h
iocp-internal.h
evconfig-private.h
compat/sys/queue.h
)
-
+
+set(HDR_COMPAT
+ include/evdns.h
+ include/evrpc.h
+ include/event.h
+ include/evhttp.h
+ include/evutil.h
+ )
+
set(HDR_PUBLIC
include/event2/buffer.h
include/event2/bufferevent.h
)
set(SRC_CORE
- buffer.c
- bufferevent.c
- bufferevent_filter.c
- bufferevent_pair.c
- bufferevent_ratelim.c
- bufferevent_sock.c
- event.c
- evmap.c
- evthread.c
- evutil.c
+ buffer.c
+ bufferevent.c
+ bufferevent_filter.c
+ bufferevent_pair.c
+ bufferevent_ratelim.c
+ bufferevent_sock.c
+ event.c
+ evmap.c
+ evthread.c
+ evutil.c
evutil_rand.c
evutil_time.c
- listener.c
- log.c
- signal.c
+ listener.c
+ log.c
+ signal.c
strlcpy.c
)
endif()
set(SRC_EXTRA
- event_tagging.c
- http.c
- evdns.c
+ event_tagging.c
+ http.c
+ evdns.c
evrpc.c
)
${PROJECT_SOURCE_DIR}/include)
if(WIN32)
- list(APPEND SRC_CORE
- buffer_iocp.c
+ list(APPEND SRC_CORE
+ buffer_iocp.c
bufferevent_async.c
- event_iocp.c
- evthread_win32.c
- win32select.c
+ event_iocp.c
+ evthread_win32.c
+ win32select.c
)
-
+
list(APPEND HDR_PRIVATE WIN32-Code/getopt.h)
set(EVENT__DNS_USE_FTIME_FOR_ID 1)
endif()
source_group("Headers Private" FILES ${HDR_PRIVATE})
+source_group("Header Compat" FILES ${HDR_COMPAT})
source_group("Headers Public" FILES ${HDR_PUBLIC})
source_group("Source Core" FILES ${SRC_CORE})
source_group("Source Extra" FILES ${SRC_EXTRA})
# TODO: Add dynamic versions of the libraries as well.
add_library(event_core ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
+ ${HDR_COMPAT}
${HDR_PUBLIC}
${SRC_CORE}
)
add_library(event_extra ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
+ ${HDR_COMPAT}
${HDR_PUBLIC}
${SRC_CORE}
${SRC_EXTRA}
# go away in a future version of Libevent.
add_library(event ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
+ ${HDR_COMPAT}
${HDR_PUBLIC}
${SRC_CORE}
${SRC_EXTRA}
if (NOT EVENT__DISABLE_TESTS)
- # (We require python to generate the regress tests)
- find_package(PythonInterp 2.4)
-
#
# Generate Regress tests.
#
if (NOT EVENT__DISABLE_REGRESS)
- if (PYTHONINTERP_FOUND)
+
+ # (We require python to generate the regress tests)
+ find_package(PythonInterp)
+ if (PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0")
+ set(__FOUND_USABLE_PYTHON 1)
+ endif()
+
+ if (__FOUND_USABLE_PYTHON)
message("Generating regress tests...")
add_definitions(-DTINYTEST_LOCAL)
add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c
+ OUTPUT
+ ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c
${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.h
- DEPENDS
+ DEPENDS
event_rpcgen.py
- test/regress.rpc
- COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc
+ test/regress.rpc
+ COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
)
- list(APPEND SRC_REGRESS
+ list(APPEND SRC_REGRESS
test/regress.c
test/regress.gen.c
test/regress.gen.h
test/regress_dns.c
test/regress_et.c
test/regress_finalize.c
- test/regress_http.c
- test/regress_listener.c
+ test/regress_http.c
+ test/regress_listener.c
test/regress_main.c
test/regress_minheap.c
test/regress_rpc.c
test/regress_testutils.c
test/regress_testutils.h
- test/regress_util.c
+ test/regress_util.c
test/tinytest.c
${SRC_CORE}
${SRC_EXTRA}
target_link_libraries(regress ${LIB_APPS} ${LIB_PLATFORM})
else()
- message(WARNING "Python not found, cannot generate regress tests!")
+ message(WARNING "No suitable Python interpreter found, cannot generate regress tests!")
endif()
endif()
test-time
test-weof)
- set(ALL_TESTPROGS ${TESTPROGS} test-dumpevents test-ratelim)
+ set(ALL_TESTPROGS ${TESTPROGS} test-dumpevents test-ratelim)
# Create test program executables.
foreach (TESTPROG ${ALL_TESTPROGS})
endforeach()
# Dump events test.
- if (PYTHONINTERP_FOUND)
+ if (__FOUND_USABLE_PYTHON)
set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME})
add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py)
set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}")
endif()
# Regress tests.
- if (NOT EVENT__DISABLE_REGRESS AND PYTHONINTERP_FOUND)
+ if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON)
set(TEST_NAME regress__${BACKEND_TEST_NAME})
add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}")
# Connection limit, no group limit.
add_test(test-ratelim__con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -n 30 -t 100 --check-connlimit 50 --check-stddev 50)
-
+
# Connection limit and group limit.
add_test(test-ratelim__group_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50)
-
+
# Connection limit and group limit with independent drain.
add_test(test-ratelim__group_con_lim_drain ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 35000 -n 30 -t 100 -G 500 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50)
# Add a "make verify" target, same as for autoconf.
- # (Important! This will unset all EVENT_NO* environment variables.
+ # (Important! This will unset all EVENT_NO* environment variables.
# If they are set in the shell the tests are running using simply "ctest" or "make test" will fail)
if (WIN32)
# Windows doesn't have "unset". But you can use "set VAR=" instead.
DEPENDS event ${ALL_TESTPROGS})
endif()
- if (NOT EVENT__DISABLE_REGRESS)
+ if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON)
add_dependencies(verify regress)
endif()
export(PACKAGE libevent)
# Generate the config file for the build-tree.
-set(EVENT__INCLUDE_DIRS
+set(EVENT__INCLUDE_DIRS
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include")
set(LIBEVENT_INCLUDE_DIRS ${EVENT__INCLUDE_DIRS} CACHE PATH "Libevent include directories")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in
- ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
+ ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
@ONLY)
# Generate the config file for the installation tree.
-file(RELATIVE_PATH
- REL_INCLUDE_DIR
+file(RELATIVE_PATH
+ REL_INCLUDE_DIR
"${EVENT_INSTALL_CMAKE_DIR}"
"${EVENT_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir.
-# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in,
+# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in,
# we escape it here so it's evaluated when it is included instead
-# so that the include dirs are givenrelative to where the
+# so that the include dirs are givenrelative to where the
# config file is located.
-set(EVENT__INCLUDE_DIRS
+set(EVENT__INCLUDE_DIRS
"\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in
- ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
+ ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
@ONLY)
# Generate version info for both build-tree and install-tree.
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in
- ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
+ ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
@ONLY)
# Define the public headers.
LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev)
+# Install compat headers
+install(FILES ${HDR_COMPAT}
+ DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}"
+ COMPONENT dev)
# Install the configs.
install(FILES