CMAKE CMAKE CMAKE CLEANUPS

It's almost useful.
This commit is contained in:
Mark Ellzey 2015-12-20 00:43:46 -08:00
parent 8b228e27f5
commit a9db46aec2
4 changed files with 479 additions and 221 deletions

View File

@ -21,8 +21,8 @@
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release set(CMAKE_BUILD_TYPE Release
CACHE STRING "Set build type to Debug o Release (default Release)" FORCE) CACHE STRING "Set build type to Debug o Release (default Release)" FORCE)
endif() endif()
# get rid of the extra default configurations # get rid of the extra default configurations
@ -31,78 +31,9 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configuratio
project(libevent C) project(libevent C)
set(EVENT_VERSION_MAJOR 2) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
set(EVENT_VERSION_MINOR 1)
set(EVENT_VERSION_PATCH 5)
set(EVENT_NUMERIC_VERSION 0x02010500)
set(EVENT_PACKAGE_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}")
# what is the point of MAJOR/MINOR/PATCH if they are just going
# to be the same as the above, am I missing something? - ellzey?
set(EVENT_ABI_MAJOR 2)
set(EVENT_ABI_MINOR 1)
set(EVENT_ABI_PATCH 5)
set(EVENT_ABI_LIBVERSION "${EVENT_ABI_MAJOR}.${EVENT_ABI_MINOR}.${EVENT_ABI_PATCH}")
######## the following section sets the development stage name. Defaults
######## to beta, but with the option of alpha, rc, and release.
# only a subset of names can be used, defaults to "beta"
set(EVENT__STAGE_VERSION "beta"
CACHE STRING "set EVENT_STAGE_VERSION")
# a list that defines what can set for EVENT_STAGE_VERSION
set(EVENT__ALLOWED_STAGE_NAMES
beta
alpha
rc
release)
# attempt to find the EVENT__STAGE_VERSION in the allowed list
# of accepted stage names, the return value is stord in
# EVENT__STAGE_RET
list(FIND
EVENT__ALLOWED_STAGE_NAMES
${EVENT__STAGE_VERSION}
EVENT__STAGE_RET)
# if EVENT__STAGE_RET is -1, the name was not
# found, so we fall back to "beta".
set(EVENT_STAGE_VERSION "beta")
if (EVENT__STAGE_RET EQUAL "-1")
message(WARNING "${EVENT__STAGE_VERSION} invalid, defaulting to ${EVENT_STAGE_VERSION}")
else()
set(EVENT_STAGE_VERSION ${EVENT__STAGE_VERSION})
endif()
set(EVENT_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-${EVENT_STAGE_VERSION}")
option(EVENT__BUILD_SHARED_LIBRARIES "Define if libevent should be built with shared libraries instead of archives" OFF)
option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" OFF)
option(EVENT__ENABLE_VERBOSE_DEBUG "Enables verbose debugging" OFF)
option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" OFF)
option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" OFF)
option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" OFF)
option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" OFF)
option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF)
option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF)
option(EVENT__DISABLE_SAMPLES "Disable sample files" OFF)
option(EVENT__FORCE_KQUEUE_CHECK "When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF)
option(EVENT__COVERAGE "Enable running gcov to get a test coverage report (only works with GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well." OFF)
# 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.
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)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
include(CheckFunctionExistsEx) include(CheckFunctionExistsEx)
include(CheckFileOffsetBits) include(CheckFileOffsetBits)
include(CheckFunctionExists) include(CheckFunctionExists)
@ -115,19 +46,96 @@ include(CheckStructHasMember)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
include(CheckPrototypeDefinition) include(CheckPrototypeDefinition)
include(CheckFunctionKeywords) include(CheckFunctionKeywords)
include(CheckCCompilerFlag) include(AddCompilerFlags)
include(VersionViaGit)
macro(add_compiler_flags _flags) event_fuzzy_version_from_git()
foreach(flag ${_flags})
string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${flag}")
check_c_compiler_flag("${flag}" check_c_compiler_flag_${_flag_esc}) set(EVENT_VERSION_MAJOR ${EVENT_GIT___VERSION_MAJOR})
set(EVENT_VERSION_MINOR ${EVENT_GIT___VERSION_MINOR})
set(EVENT_VERSION_PATCH ${EVENT_GIT___VERSION_PATCH})
if (check_c_compiler_flag_${_flag_esc})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") set(EVENT_ABI_MAJOR ${EVENT_VERSION_MAJOR})
endif() set(EVENT_ABI_MINOR ${EVENT_VERSION_MINOR})
endforeach() set(EVENT_ABI_PATCH ${EVENT_VERSION_PATCH})
endmacro()
set(EVENT_ABI_LIBVERSION
"${EVENT_ABI_MAJOR}.${EVENT_ABI_MINOR}.${EVENT_ABI_PATCH}")
set(EVENT_PACKAGE_VERSION
"${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}")
set(EVENT_NUMERIC_VERSION 0x02010500)
# only a subset of names can be used, defaults to "beta"
set(EVENT__STAGE_NAME "${EVENT_GIT___VERSION_STAGE}"
CACHE STRING "set EVENT_STAGE_NAM")
# a list that defines what can set for EVENT_STAGE_VERSION
set(EVENT__ALLOWED_STAGE_NAMES
rc
beta
alpha
release)
# attempt to find the EVENT__STAGE_VERSION in the allowed list
# of accepted stage names, the return value is stord in
# EVENT__STAGE_RET
list(FIND EVENT__ALLOWED_STAGE_NAMES
${EVENT__STAGE_NAME}
EVENT__STAGE_RET)
if (EVENT__STAGE_RET EQUAL "-1")
set(EVENT__STAGE_NAM "beta")
endif()
set(EVENT_VERSION
"${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-${EVENT_STAGE_NAM}")
option(EVENT__BUILD_SHARED_LIBRARIES
"Define if libevent should be built with shared libraries instead of archives" OFF)
option(EVENT__DISABLE_DEBUG_MODE
"Define if libevent should build without support for a debug mode" OFF)
option(EVENT__ENABLE_VERBOSE_DEBUG
"Enables verbose debugging" OFF)
option(EVENT__DISABLE_MM_REPLACEMENT
"Define if libevent should not allow replacing the mm functions" OFF)
option(EVENT__DISABLE_THREAD_SUPPORT
"Define if libevent should not be compiled with thread support" OFF)
option(EVENT__DISABLE_OPENSSL
"Define if libevent should build without support for OpenSSL encrpytion" OFF)
option(EVENT__DISABLE_BENCHMARK
"Defines if libevent should build without the benchmark exectuables" OFF)
option(EVENT__DISABLE_TESTS
"If tests should be compiled or not" OFF)
option(EVENT__DISABLE_REGRESS
"Disable the regress tests" OFF)
option(EVENT__DISABLE_SAMPLES
"Disable sample files" OFF)
option(EVENT__FORCE_KQUEUE_CHECK
"When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF)
# TODO: Add --disable-largefile omit support for large files
option(EVENT__COVERAGE
"Enable running gcov to get a test coverage report (only works with GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well." OFF)
# 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.
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 (EVENT__ENABLE_VERBOSE_DEBUG) if (EVENT__ENABLE_VERBOSE_DEBUG)
add_definitions(-DUSE_DBUG=1) add_definitions(-DUSE_DBUG=1)
@ -135,73 +143,63 @@ endif()
# Setup compiler flags for coverage. # Setup compiler flags for coverage.
if (EVENT__COVERAGE) if (EVENT__COVERAGE)
if(NOT CMAKE_COMPILER_IS_GNUCC) if ((NOT CMAKE_COMPILER_IS_GNUCC) AND (NOT ${CMAKE_CXX_COMPILER_ID} STREQAL "Clang"))
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message(FATAL_ERROR"Trying to compile coverage support, but compiler is not GNU gcc! Try CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
message(FATAL_ERROR "Trying to compile coverage support (--DEVENT__COVERAGE) but compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
endif()
endif() endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") 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") message(FATAL_ERROR "Coverage requires -DCMAKE_BUILD_TYPE=Debug")
endif() endif()
message(STATUS "Setting coverage compiler flags") message(STATUS "Setting coverage compiler flags")
add_compiler_flags(-g -O0 -fprofile-arcs -ftest-coverage) add_compiler_flags(-g -O0 -fprofile-arcs -ftest-coverage)
endif() endif()
# GCC specific options. # GCC specific options.
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCC)
option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF) option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF)
option(EVENT__ENABLE_GCC_HARDENING "Enable compiler security checks" OFF) option(EVENT__ENABLE_GCC_HARDENING "Enable compiler security checks" OFF)
option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF) option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF)
option(EVENT__ENABLE_GCC_WARNINGS "Make all GCC warnings into errors" OFF) option(EVENT__ENABLE_GCC_WARNINGS "Make all GCC warnings into errors" OFF)
list(APPEND __FLAGS -Wall) list(APPEND __FLAGS -Wall)
if (EVENT__DISABLE_GCC_WARNINGS) if (EVENT__DISABLE_GCC_WARNINGS)
list(APPEND __FLAGS -w) list(APPEND __FLAGS -w)
endif() endif()
if (EVENT__ENABLE_GCC_HARDENING) if (EVENT__ENABLE_GCC_HARDENING)
list(APPEND __FLAGS list(APPEND __FLAGS
-fstack-protector-all -fstack-protector-all
-fwrapv -fwrapv
-fPIE -fPIE
-Wstack-protector -Wstack-protector
"--param ssp-buffer-size=1") "--param ssp-buffer-size=1")
add_definitions(-D_FORTIFY_SOURCE=2) add_definitions(-D_FORTIFY_SOURCE=2)
endif() endif()
if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS) if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS)
list(APPEND __FLAGS -ffunction-sections) list(APPEND __FLAGS -ffunction-sections)
# TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works. # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works.
endif() endif()
if (EVENT__ENABLE_GCC_WARNINGS) if (EVENT__ENABLE_GCC_WARNINGS)
list(APPEND __FLAGS -Werror) list(APPEND __FLAGS -Werror)
endif() endif()
# We need to test for at least gcc 2.95 here, because older versions don't # We need to test for at least gcc 2.95 here, because older versions don't
# have -fno-strict-aliasing # have -fno-strict-aliasing
list(APPEND __FLAGS -fno-strict-aliasing) list(APPEND __FLAGS -fno-strict-aliasing)
#execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion add_compiler_flags(__FLAGS)
# OUTPUT_VARIABLE GCC_VERSION)
#if (GCC_VERSION VERSION_GREATER 2.95)
# message(STATUS "GCC Version >= 2.95 enabling no-strict-aliasing")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
#endif()
add_compiler_flags(__FLAGS)
endif() endif()
if (APPLE) if (APPLE)
# Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater. # Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater.
add_compiler_flags( add_compiler_flags(
-Wno-error=deprecated-declarations -Wno-error=deprecated-declarations
-Qunused-arguments) -Qunused-arguments)
endif() endif()
# Winsock. # Winsock.
@ -389,13 +387,13 @@ endif()
check_function_keywords("inline" "__inline" "__inline__") check_function_keywords("inline" "__inline" "__inline__")
if (HAVE_INLINE) if (HAVE_INLINE)
set (EVENT__inline inline) set (EVENT__inline inline)
elseif (HAVE___INLINE) elseif (HAVE___INLINE)
set(EVENT__inline __inline) set(EVENT__inline __inline)
elseif(HAVE___INLINE__) elseif(HAVE___INLINE__)
set(EVENT__inline __inline__) set(EVENT__inline __inline__)
else() else()
set(EVENT__inline) set(EVENT__inline)
endif() endif()
CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH) CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH)
@ -410,16 +408,17 @@ CHECK_TYPE_SIZE(size_t EVENT__SIZEOF_SIZE_T)
if(NOT EVENT__SIZEOF_SIZE_T) if(NOT EVENT__SIZEOF_SIZE_T)
set(EVENT__size_t unsigned) set(EVENT__size_t unsigned)
# and the point is??? # and the point is???
set(EVENT__SIZEOF_SIZE_T ${EVENT__SIZEOF_UNSIGNED}) set(EVENT__SIZEOF_SIZE_T ${EVENT__SIZEOF_UNSIGNED})
else() else()
set(EVENT__size_t "size_t") set(EVENT__size_t "size_t")
endif() endif()
CHECK_TYPE_SIZE("off_t" EVENT__SIZEOF_OFF_T) CHECK_TYPE_SIZE("off_t" EVENT__SIZEOF_OFF_T)
CHECK_TYPE_SIZE(ssize_t EVENT__SIZEOF_SSIZE_T) CHECK_TYPE_SIZE(ssize_t EVENT__SIZEOF_SSIZE_T)
CHECK_TYPE_SIZE(SSIZE_T EVENT__SIZEOF_UPPERCASE_SSIZE_T) CHECK_TYPE_SIZE(SSIZE_T EVENT__SIZEOF_UPPERCASE_SSIZE_T)
# Winsock.
if(NOT EVENT__SIZEOF_SSIZE_T) if(NOT EVENT__SIZEOF_SSIZE_T)
if(EVENT__SIZEOF_UPPERCASE_SSIZE_T) if(EVENT__SIZEOF_UPPERCASE_SSIZE_T)
set(EVENT__ssize_t SSIZE_T) set(EVENT__ssize_t SSIZE_T)
@ -433,10 +432,10 @@ endif()
CHECK_TYPE_SIZE(socklen_t EVENT__SIZEOF_SOCKLEN_T) CHECK_TYPE_SIZE(socklen_t EVENT__SIZEOF_SOCKLEN_T)
if(NOT EVENT__SIZEOF_SOCKLEN_T) if(NOT EVENT__SIZEOF_SOCKLEN_T)
set(EVENT__socklen_t "unsigned int") set(EVENT__socklen_t "unsigned int")
# what is the poitn of this if EVENT__SIZEOF_UNSIGNED_INT is 0? # what is the poitn of this if EVENT__SIZEOF_UNSIGNED_INT is 0?
set(EVENT__SIZEOF_SOCKLEN_T ${EVENT__SIZEOF_UNSIGNED_INT}) set(EVENT__SIZEOF_SOCKLEN_T ${EVENT__SIZEOF_UNSIGNED_INT})
else() else()
set(EVENT__socklen_t "socklen_t") set(EVENT__socklen_t "socklen_t")
endif() endif()
CHECK_TYPE_SIZE(pid_t EVENT__SIZEOF_PID_T) CHECK_TYPE_SIZE(pid_t EVENT__SIZEOF_PID_T)
@ -446,7 +445,7 @@ if(NOT EVENT__SIZEOF_PID_T)
endif() endif()
if (NOT EVENT__DISABLE_THREAD_SUPPORT) if (NOT EVENT__DISABLE_THREAD_SUPPORT)
CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T) CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T)
endif() endif()
if(EVENT__HAVE_CLOCK_GETTIME) if(EVENT__HAVE_CLOCK_GETTIME)
@ -520,21 +519,36 @@ endif()
CHECK_TYPE_SIZE("struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR) CHECK_TYPE_SIZE("struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR)
if(EVENT__HAVE_STRUCT_IN6_ADDR) if(EVENT__HAVE_STRUCT_IN6_ADDR)
CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr16 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16) CHECK_STRUCT_HAS_MEMBER("struct in6_addr"
CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr32 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32) s6_addr16 "${SOCKADDR_HEADERS}"
EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16)
CHECK_STRUCT_HAS_MEMBER("struct in6_addr"
s6_addr32 "${SOCKADDR_HEADERS}"
EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32)
endif() endif()
CHECK_TYPE_SIZE("sa_family_t" EVENT__HAVE_SA_FAMILY_T) CHECK_TYPE_SIZE("sa_family_t" EVENT__HAVE_SA_FAMILY_T)
CHECK_TYPE_SIZE("struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6) CHECK_TYPE_SIZE("struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6)
if(EVENT__HAVE_STRUCT_SOCKADDR_IN6) if(EVENT__HAVE_STRUCT_SOCKADDR_IN6)
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6"
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) sin6_len "${SOCKADDR_HEADERS}"
EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN)
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6"
sin_len "${SOCKADDR_HEADERS}"
EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN)
endif() endif()
CHECK_TYPE_SIZE("struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) CHECK_TYPE_SIZE("struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE)
if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE)
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage"
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) ss_family "${SOCKADDR_HEADERS}"
EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage"
__ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY)
endif() endif()
# Group the source files. # Group the source files.
@ -560,16 +574,14 @@ set(HDR_PRIVATE
strlcpy-internal.h strlcpy-internal.h
util-internal.h util-internal.h
evconfig-private.h evconfig-private.h
compat/sys/queue.h compat/sys/queue.h)
)
set(HDR_COMPAT set(HDR_COMPAT
include/evdns.h include/evdns.h
include/evrpc.h include/evrpc.h
include/event.h include/event.h
include/evhttp.h include/evhttp.h
include/evutil.h include/evutil.h)
)
set(HDR_PUBLIC set(HDR_PUBLIC
include/event2/buffer.h include/event2/buffer.h
@ -596,8 +608,7 @@ set(HDR_PUBLIC
include/event2/thread.h include/event2/thread.h
include/event2/util.h include/event2/util.h
include/event2/visibility.h include/event2/visibility.h
${PROJECT_BINARY_DIR}/include/event2/event-config.h ${PROJECT_BINARY_DIR}/include/event2/event-config.h)
)
set(SRC_CORE set(SRC_CORE
buffer.c buffer.c
@ -615,8 +626,7 @@ set(SRC_CORE
listener.c listener.c
log.c log.c
signal.c signal.c
strlcpy.c strlcpy.c)
)
if(EVENT__HAVE_SELECT) if(EVENT__HAVE_SELECT)
list(APPEND SRC_CORE select.c) list(APPEND SRC_CORE select.c)
@ -644,10 +654,14 @@ endif()
if (NOT EVENT__DISABLE_OPENSSL) if (NOT EVENT__DISABLE_OPENSSL)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
set(EVENT__HAVE_OPENSSL 1) set(EVENT__HAVE_OPENSSL 1)
message(STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}") message(STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}") message(STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}")
include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND SRC_CORE bufferevent_openssl.c) list(APPEND SRC_CORE bufferevent_openssl.c)
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h) list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
list(APPEND LIB_APPS ${OPENSSL_LIBRARIES}) list(APPEND LIB_APPS ${OPENSSL_LIBRARIES})
@ -659,8 +673,10 @@ if (NOT EVENT__DISABLE_THREAD_SUPPORT)
else() else()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT) if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to turn off thread support") message(FATAL_ERROR
"Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to disable")
endif() endif()
set(EVENT__HAVE_PTHREADS 1) set(EVENT__HAVE_PTHREADS 1)
list(APPEND SRC_CORE evthread_pthread.c) list(APPEND SRC_CORE evthread_pthread.c)
list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT}) list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT})
@ -672,9 +688,10 @@ if (NOT EVENT__DISABLE_TESTS)
find_package(ZLIB) find_package(ZLIB)
if (ZLIB_LIBRARY) if (ZLIB_LIBRARY)
include_directories(${ZLIB_INCLUDE_DIRS})
set(EVENT__HAVE_ZLIB 1) set(EVENT__HAVE_ZLIB 1)
set(EVENT__HAVE_ZLIB_H) set(EVENT__HAVE_ZLIB_H)
include_directories(${ZLIB_INCLUDE_DIRS})
list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) list(APPEND LIB_APPS ${ZLIB_LIBRARIES})
endif() endif()
endif() endif()
@ -683,8 +700,7 @@ set(SRC_EXTRA
event_tagging.c event_tagging.c
http.c http.c
evdns.c evdns.c
evrpc.c evrpc.c)
)
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
@ -700,14 +716,16 @@ if(WIN32)
bufferevent_async.c bufferevent_async.c
event_iocp.c event_iocp.c
evthread_win32.c evthread_win32.c
win32select.c win32select.c)
)
list(APPEND HDR_PRIVATE WIN32-Code/getopt.h) list(APPEND HDR_PRIVATE WIN32-Code/getopt.h)
set(EVENT__DNS_USE_FTIME_FOR_ID 1) set(EVENT__DNS_USE_FTIME_FOR_ID 1)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
set(LIB_PLATFORM ws2_32) set(LIB_PLATFORM ws2_32)
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(./WIN32-Code) include_directories(./WIN32-Code)
endif() endif()
@ -728,15 +746,13 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include)
if (EVENT__BUILD_SHARED_LIBRARIES) if (EVENT__BUILD_SHARED_LIBRARIES)
set(EVENT__LIBRARY_TYPE SHARED) set(EVENT__LIBRARY_TYPE SHARED)
if (CMAKE_COMPILER_IS_GNUCC) if ((CMAKE_COMPILER_IS_GNUCC) OR (${CMAKE_C_COMPILER_ID} STREQUAL "Clang"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") add_compiler_flags(-fvisibility=hidden)
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro") elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xldscope=hidden") add_compiler_flags(-xldscope=hidden)
endif () endif()
set(EVENT__NEED_DLLIMPORT 1)
set(EVENT__NEED_DLLIMPORT 1)
else (EVENT__BUILD_SHARED_LIBRARIES) else (EVENT__BUILD_SHARED_LIBRARIES)
set(EVENT__LIBRARY_TYPE STATIC) set(EVENT__LIBRARY_TYPE STATIC)
endif (EVENT__BUILD_SHARED_LIBRARIES) endif (EVENT__BUILD_SHARED_LIBRARIES)
@ -744,7 +760,7 @@ endif (EVENT__BUILD_SHARED_LIBRARIES)
configure_file( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/event2/event-config.h ${CMAKE_CURRENT_BINARY_DIR}/include/event2/event-config.h
NEWLINE_STYLE UNIX) NEWLINE_STYLE UNIX)
configure_file( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/evconfig-private.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/evconfig-private.h.cmake
@ -759,16 +775,14 @@ add_library(event_core ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE} ${HDR_PRIVATE}
${HDR_COMPAT} ${HDR_COMPAT}
${HDR_PUBLIC} ${HDR_PUBLIC}
${SRC_CORE} ${SRC_CORE})
)
add_library(event_extra ${EVENT__LIBRARY_TYPE} add_library(event_extra ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE} ${HDR_PRIVATE}
${HDR_COMPAT} ${HDR_COMPAT}
${HDR_PUBLIC} ${HDR_PUBLIC}
${SRC_CORE} ${SRC_CORE}
${SRC_EXTRA} ${SRC_EXTRA})
)
# library exists for historical reasons; it contains the contents of # library exists for historical reasons; it contains the contents of
# both libevent_core and libevent_extra. You shouldnt use it; it may # both libevent_core and libevent_extra. You shouldnt use it; it may
@ -778,8 +792,7 @@ add_library(event ${EVENT__LIBRARY_TYPE}
${HDR_COMPAT} ${HDR_COMPAT}
${HDR_PUBLIC} ${HDR_PUBLIC}
${SRC_CORE} ${SRC_CORE}
${SRC_EXTRA} ${SRC_EXTRA})
)
if (EVENT__BUILD_SHARED_LIBRARIES) if (EVENT__BUILD_SHARED_LIBRARIES)
# Prepare static library to be linked to tests that need hidden symbols # Prepare static library to be linked to tests that need hidden symbols
@ -788,8 +801,8 @@ if (EVENT__BUILD_SHARED_LIBRARIES)
${HDR_COMPAT} ${HDR_COMPAT}
${HDR_PUBLIC} ${HDR_PUBLIC}
${SRC_CORE} ${SRC_CORE}
${SRC_EXTRA} ${SRC_EXTRA})
)
set(EVENT_EXTRA_FOR_TEST event_extra_static) set(EVENT_EXTRA_FOR_TEST event_extra_static)
target_link_libraries(event_core ${OPENSSL_LIBRARIES} target_link_libraries(event_core ${OPENSSL_LIBRARIES}
@ -804,9 +817,17 @@ if (EVENT__BUILD_SHARED_LIBRARIES)
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${LIB_PLATFORM}) ${LIB_PLATFORM})
set_target_properties(event PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION}) set_target_properties(event
set_target_properties(event_core PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION}) PROPERTIES SOVERSION
set_target_properties(event_extra PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION}) ${EVENT_ABI_LIBVERSION})
set_target_properties(event_core
PROPERTIES SOVERSION
${EVENT_ABI_LIBVERSION})
set_target_properties(event_extra
PROPERTIES SOVERSION
${EVENT_ABI_LIBVERSION})
else (EVENT__BUILD_SHARED_LIBRARIES) else (EVENT__BUILD_SHARED_LIBRARIES)
set(EVENT_EXTRA_FOR_TEST event_extra) set(EVENT_EXTRA_FOR_TEST event_extra)
@ -836,7 +857,12 @@ if (NOT EVENT__DISABLE_SAMPLES)
sample/https-client.c sample/https-client.c
sample/openssl_hostname_validation.c sample/openssl_hostname_validation.c
sample/hostcheck.c) sample/hostcheck.c)
target_link_libraries(https-client event_extra ${LIB_APPS} ${LIB_PLATFORM})
target_link_libraries(https-client
event_extra
${LIB_APPS}
${LIB_PLATFORM})
add_dependencies(https-client event_extra) add_dependencies(https-client event_extra)
# Requires OpenSSL. # Requires OpenSSL.
@ -844,8 +870,14 @@ if (NOT EVENT__DISABLE_SAMPLES)
endif() endif()
foreach(SAMPLE ${SAMPLES}) foreach(SAMPLE ${SAMPLES})
add_executable(${SAMPLE} sample/${SAMPLE}.c) add_executable(${SAMPLE}
target_link_libraries(${SAMPLE} event_extra ${LIB_APPS} ${LIB_PLATFORM}) sample/${SAMPLE}.c)
target_link_libraries(${SAMPLE}
event_extra
${LIB_APPS}
${LIB_PLATFORM})
add_dependencies(${SAMPLE} event_extra) add_dependencies(${SAMPLE} event_extra)
endforeach() endforeach()
endif() endif()
@ -855,11 +887,17 @@ if (NOT EVENT__DISABLE_BENCHMARK)
set(BENCH_SRC test/${BENCHMARK}.c) set(BENCH_SRC test/${BENCHMARK}.c)
if (WIN32) if (WIN32)
list(APPEND BENCH_SRC WIN32-Code/getopt.c WIN32-Code/getopt_long.c) list(APPEND BENCH_SRC
WIN32-Code/getopt.c
WIN32-Code/getopt_long.c)
endif() endif()
add_executable(${BENCHMARK} ${BENCH_SRC}) add_executable(${BENCHMARK} ${BENCH_SRC})
target_link_libraries(${BENCHMARK} event_extra ${LIB_PLATFORM})
target_link_libraries(${BENCHMARK}
event_extra
${LIB_PLATFORM})
add_dependencies(${BENCHMARK} event_extra) add_dependencies(${BENCHMARK} event_extra)
endforeach() endforeach()
endif() endif()
@ -872,13 +910,16 @@ if (NOT EVENT__DISABLE_TESTS)
# (We require python to generate the regress tests) # (We require python to generate the regress tests)
find_package(PythonInterp) find_package(PythonInterp)
if (PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0") if (PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0")
set(__FOUND_USABLE_PYTHON 1) set(__FOUND_USABLE_PYTHON 1)
endif() endif()
if (__FOUND_USABLE_PYTHON) if (__FOUND_USABLE_PYTHON)
message(STATUS "Generating regress tests...") message(STATUS "Generating regress tests...")
add_definitions(-DTINYTEST_LOCAL) add_definitions(-DTINYTEST_LOCAL)
add_custom_command( add_custom_command(
OUTPUT OUTPUT
${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c
@ -887,8 +928,7 @@ if (NOT EVENT__DISABLE_TESTS)
event_rpcgen.py event_rpcgen.py
test/regress.rpc test/regress.rpc
COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
)
list(APPEND SRC_REGRESS list(APPEND SRC_REGRESS
test/regress.c test/regress.c
@ -909,8 +949,7 @@ if (NOT EVENT__DISABLE_TESTS)
test/regress_util.c test/regress_util.c
test/tinytest.c test/tinytest.c
${SRC_CORE} ${SRC_CORE}
${SRC_EXTRA} ${SRC_EXTRA})
)
if (WIN32) if (WIN32)
list(APPEND SRC_REGRESS test/regress_iocp.c) list(APPEND SRC_REGRESS test/regress_iocp.c)
@ -930,14 +969,18 @@ if (NOT EVENT__DISABLE_TESTS)
endif() endif()
add_executable(regress ${SRC_REGRESS}) add_executable(regress ${SRC_REGRESS})
# While building the test suite we don't want the visibility # While building the test suite we don't want the visibility
# header trying to "dllimport" the symbols on windows (it # header trying to "dllimport" the symbols on windows (it
# generates a ton of warnings due to different link # generates a ton of warnings due to different link
# attributes for all of the symbols) # attributes for all of the symbols)
SET_TARGET_PROPERTIES(regress PROPERTIES COMPILE_DEFINITIONS SET_TARGET_PROPERTIES(regress
"EVENT_BUILDING_REGRESS_TEST=1") PROPERTIES COMPILE_DEFINITIONS
"EVENT_BUILDING_REGRESS_TEST=1")
target_link_libraries(regress ${LIB_APPS} ${LIB_PLATFORM}) target_link_libraries(regress
${LIB_APPS}
${LIB_PLATFORM})
else() else()
message(WARNING "No suitable Python interpreter found, cannot generate regress tests!") message(WARNING "No suitable Python interpreter found, cannot generate regress tests!")
endif() endif()
@ -946,20 +989,20 @@ if (NOT EVENT__DISABLE_TESTS)
# #
# Test programs. # Test programs.
# #
# all of these, including the cmakelists.txt should be moved # all of these, including the cmakelists.txt should be moved
# into the dirctory 'tests' first. # into the dirctory 'tests' first.
# #
# doing this, we can remove all the DISABLE_TESTS stuff, and simply # doing this, we can remove all the DISABLE_TESTS stuff, and simply
# do something like: # do something like:
# #
# add_custom_targets(tests) # add_custom_targets(tests)
# add_executable(... EXCLUDE_FROM_ALL ...c) # add_executable(... EXCLUDE_FROM_ALL ...c)
# add_dependencis(tests testa testb testc) # add_dependencis(tests testa testb testc)
# add_test(....) # add_test(....)
# #
# then you can just run 'make tests' instead of them all # then you can just run 'make tests' instead of them all
# auto-compile|running # auto-compile|running
# - ellzey # - ellzey
set(TESTPROGS test-changelist set(TESTPROGS test-changelist
test-eof test-eof
test-fdleak test-fdleak
@ -967,13 +1010,22 @@ if (NOT EVENT__DISABLE_TESTS)
test-time test-time
test-weof) test-weof)
set(ALL_TESTPROGS ${TESTPROGS} test-dumpevents test-ratelim) set(ALL_TESTPROGS
${TESTPROGS}
test-dumpevents
test-ratelim)
# Create test program executables. # Create test program executables.
foreach (TESTPROG ${ALL_TESTPROGS}) foreach (TESTPROG ${ALL_TESTPROGS})
add_executable(${TESTPROG} test/${TESTPROG}.c) add_executable(${TESTPROG}
target_link_libraries(${TESTPROG} ${EVENT_EXTRA_FOR_TEST} ${LIB_PLATFORM}) test/${TESTPROG}.c)
add_dependencies(${TESTPROG} ${EVENT_EXTRA_FOR_TEST})
target_link_libraries(${TESTPROG}
${EVENT_EXTRA_FOR_TEST}
${LIB_PLATFORM})
add_dependencies(${TESTPROG}
${EVENT_EXTRA_FOR_TEST})
endforeach() endforeach()
# #
@ -1026,31 +1078,53 @@ if (NOT EVENT__DISABLE_TESTS)
foreach (TESTPROG ${TESTPROGS}) foreach (TESTPROG ${TESTPROGS})
set(TEST_NAME ${TESTPROG}__${BACKEND_TEST_NAME}) set(TEST_NAME ${TESTPROG}__${BACKEND_TEST_NAME})
add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG})
add_test(${TEST_NAME}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG})
list(APPEND TEST_NAMES ${TEST_NAME}) list(APPEND TEST_NAMES ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}")
set_tests_properties(${TEST_NAME}
PROPERTIES ENVIRONMENT "${ENV_VARS}")
endforeach() endforeach()
# Dump events test. # Dump events test.
if (__FOUND_USABLE_PYTHON) if (__FOUND_USABLE_PYTHON)
set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}) 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}") 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}")
else() else()
message(WARNING "test-dumpevents will be run without output check since python was not found!") message(WARNING "test-dumpevents will be run without output check since python was not found!")
set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}_no_check) set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}_no_check)
add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents)
set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") add_test(${TEST_NAME}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents)
set_tests_properties(${TEST_NAME}
PROPERTIES ENVIRONMENT "${ENV_VARS}")
endif() endif()
# Regress tests. # Regress tests.
if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON) if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON)
set(TEST_NAME regress__${BACKEND_TEST_NAME}) 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}")
add_test(${TEST_NAME}_debug ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) add_test(${TEST_NAME}
set_tests_properties(${TEST_NAME}_debug PROPERTIES ENVIRONMENT "${ENV_VARS};EVENT_DEBUG_MODE=1") ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
set_tests_properties(${TEST_NAME}
PROPERTIES ENVIRONMENT "${ENV_VARS}")
add_test(${TEST_NAME}_debug
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
set_tests_properties(${TEST_NAME}_debug
PROPERTIES ENVIRONMENT "${ENV_VARS};EVENT_DEBUG_MODE=1")
endif() endif()
endmacro() endmacro()
@ -1062,9 +1136,14 @@ if (NOT EVENT__DISABLE_TESTS)
# Epoll has some extra settings. # Epoll has some extra settings.
if (${BACKEND} STREQUAL "EPOLL") if (${BACKEND} STREQUAL "EPOLL")
add_backend_test(timerfd_${BACKEND} "${BACKEND_ENV_VARS};EVENT_PRECISE_TIMER=1") add_backend_test(timerfd_${BACKEND}
add_backend_test(changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes") "${BACKEND_ENV_VARS};EVENT_PRECISE_TIMER=1")
add_backend_test(timerfd_changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes;EVENT_PRECISE_TIMER=1")
add_backend_test(changelist_${BACKEND}
"${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes")
add_backend_test(timerfd_changelist_${BACKEND}
"${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes;EVENT_PRECISE_TIMER=1")
else() else()
add_backend_test(${BACKEND} "${BACKEND_ENV_VARS}") add_backend_test(${BACKEND} "${BACKEND_ENV_VARS}")
endif() endif()
@ -1075,16 +1154,47 @@ if (NOT EVENT__DISABLE_TESTS)
# #
# Group limits, no connection limit. # Group limits, no connection limit.
add_test(test-ratelim__group_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-stddev 100) set(RL_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim)
add_test(test-ratelim__group_lim
${RL_BIN}
-g 30000
-n 30
-t 100
--check-grouplimit 1000
--check-stddev 100)
# Connection limit, no group limit. # 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) add_test(test-ratelim__con_lim
${RL_BIN}
-c 1000
-n 30
-t 100
--check-connlimit 50
--check-stddev 50)
# Connection limit and group limit. # 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) add_test(test-ratelim__group_con_lim
${RL_BIN}
-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. # 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_test(test-ratelim__group_con_lim_drain
${RL_BIN}
-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. # 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.
@ -1102,11 +1212,20 @@ if (NOT EVENT__DISABLE_TESTS)
") ")
message(STATUS "${WINDOWS_CTEST_COMMAND}") message(STATUS "${WINDOWS_CTEST_COMMAND}")
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/verify_tests.bat" VERIFY_PATH) file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat
DESTINATION
${CMAKE_CURRENT_BINARY_DIR}
FILE_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
file(TO_NATIVE_PATH
"${CMAKE_CURRENT_BINARY_DIR}/verify_tests.bat" VERIFY_PATH)
add_custom_target(verify COMMAND "${VERIFY_PATH}" add_custom_target(verify COMMAND "${VERIFY_PATH}"
DEPENDS event ${ALL_TESTPROGS}) DEPENDS event ${ALL_TESTPROGS})
@ -1124,11 +1243,22 @@ if (NOT EVENT__DISABLE_TESTS)
# Then we copy the file (this allows us to set execute permission on it) # Then we copy the file (this allows us to set execute permission on it)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) FILE_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE)
# Create the target that runs the script. # Create the target that runs the script.
add_custom_target(verify COMMAND ${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh add_custom_target(verify
DEPENDS event ${ALL_TESTPROGS}) COMMAND
${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh
DEPENDS
event
${ALL_TESTPROGS})
endif() endif()
if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON) if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON)
@ -1184,7 +1314,11 @@ export(PACKAGE libevent)
set(EVENT__INCLUDE_DIRS set(EVENT__INCLUDE_DIRS
"${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include") "${PROJECT_BINARY_DIR}/include")
set(LIBEVENT_INCLUDE_DIRS ${EVENT__INCLUDE_DIRS} CACHE PATH "Libevent include directories")
set(LIBEVENT_INCLUDE_DIRS
${EVENT__INCLUDE_DIRS}
CACHE PATH "Libevent include directories")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigBuildTree.cmake.in configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigBuildTree.cmake.in
${PROJECT_BINARY_DIR}/LibeventConfig.cmake ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
@ONLY) @ONLY)
@ -1201,6 +1335,7 @@ file(RELATIVE_PATH
# config file is located. # config file is located.
set(EVENT__INCLUDE_DIRS set(EVENT__INCLUDE_DIRS
"\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}") "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in 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) @ONLY)
@ -1223,23 +1358,32 @@ install(TARGETS event event_core event_extra
LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE 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) PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev)
# Install compat headers # Install compat headers
install(FILES ${HDR_COMPAT} install(FILES ${HDR_COMPAT}
DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}" DESTINATION
"${EVENT_INSTALL_INCLUDE_DIR}"
COMPONENT dev) COMPONENT dev)
# Install the configs. # Install the configs.
install(FILES install(FILES
${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) DESTINATION
"${EVENT_INSTALL_CMAKE_DIR}"
COMPONENT dev)
# Install exports for the install-tree. # Install exports for the install-tree.
install(EXPORT LibeventTargets install(EXPORT LibeventTargets
DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) DESTINATION
"${EVENT_INSTALL_CMAKE_DIR}"
COMPONENT dev)
set(LIBEVENT_LIBRARIES event event_core event_extra CACHE STRING "Libevent libraries") set(LIBEVENT_LIBRARIES
event
event_core
event_extra
CACHE STRING "Libevent libraries")
message("") message("")
message(" ---( Libevent " ${EVENT_VERSION} " )---") message(" ---( Libevent " ${EVENT_VERSION} " )---")
@ -1266,3 +1410,4 @@ message(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )
message(STATUS "CMAKE_AR: " ${CMAKE_AR} ) message(STATUS "CMAKE_AR: " ${CMAKE_AR} )
message(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB} ) message(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB} )
message("") message("")

View File

@ -0,0 +1,15 @@
include(CheckCCompilerFlag)
macro(add_compiler_flags _flags)
foreach(flag ${_flags})
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()

45
cmake/FindGit.cmake Normal file
View File

@ -0,0 +1,45 @@
# The module defines the following variables:
# GIT_EXECUTABLE - path to git command line client
# GIT_FOUND - true if the command line client was found
# Example usage:
# find_package(Git)
# if(GIT_FOUND)
# message("git found: ${GIT_EXECUTABLE}")
# endif()
#=============================================================================
# Copyright 2010 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
# Look for 'git' or 'eg' (easy git)
set(git_names git eg)
# Prefer .cmd variants on Windows unless running in a Makefile
# in the MSYS shell.
if(WIN32)
if(NOT CMAKE_GENERATOR MATCHES "MSYS")
set(git_names git.cmd git eg.cmd eg)
endif()
endif()
find_program(GIT_EXECUTABLE
NAMES ${git_names}
DOC "git command line client")
mark_as_advanced(GIT_EXECUTABLE)
# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)

53
cmake/VersionViaGit.cmake Normal file
View File

@ -0,0 +1,53 @@
# 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
#
# Usful for auto-versionin in ou CMakeLists
#
# EVENT_GIT___VERSION_FOUND - Version variables foud
# 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()
# if (EVENT_GIT___VERSION_FOUND)
# 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(EVENT_GIT___VERSION_FOUND FALSE)
# set our defaults.
set(EVENT_GIT___VERSION_MAJOR 2)
set(EVENT_GIT___VERSION_MINOR 1)
set(EVENT_GIT___VERSION_PATCH 5)
set(EVENT_GIT___VERSION_STAGE "beta")
find_package(Git)
if (GIT_FOUND)
execute_process(
COMMAND
${GIT_EXECUTABLE} describe --abbrev=0
WORKING_DIRECTORY
${PROJECT_SOURCE_DIR}
RESULT_VARIABLE
GITRET
OUTPUT_VARIABLE
GITVERSION)
if (GITRET EQUAL 0)
string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)$" "\\1" EVENT_GIT___VERSION_MAJOR ${GITVERSION})
string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)$" "\\2" EVENT_GIT___VERSION_MINOR ${GITVERSION})
string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)$" "\\3" EVENT_GIT___VERSION_PATCH ${GITVERSION})
string(REGEX REPLACE "^release-([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.*)$" "\\4" EVENT_GIT___VERSION_STAGE ${GITVERSION})
endif()
endif()
endmacro()