2013-12-09 18:05:32 +01:00
#
# Libevent CMake project
#
2014-09-02 18:25:52 +04:00
# Based on initial work by:
2013-12-09 18:05:32 +01:00
# Alexey Ozeritsky
#
# Additional changes:
# Brodie Thiesfield
2014-09-02 18:25:52 +04:00
# Joakim Soderberg
2014-02-19 06:31:27 +01:00
# Trond Norbye
2014-09-02 18:25:52 +04:00
# Sergei Nikulov
2013-12-09 18:05:32 +01:00
#
# Build example:
#
# cd libevent
# md build
# cd build
# cmake -G "Visual Studio 10" ..
# start libevent.sln
#
2017-02-21 12:54:02 +01:00
if ( WIN32 OR APPLE )
2016-03-10 01:50:12 +03:00
cmake_minimum_required ( VERSION 3.1 FATAL_ERROR )
else ( )
cmake_minimum_required ( VERSION 2.8.0 FATAL_ERROR )
endif ( )
2013-12-09 18:05:32 +01:00
2015-12-19 01:47:49 -08:00
if ( NOT CMAKE_BUILD_TYPE )
2015-12-20 00:43:46 -08:00
set ( CMAKE_BUILD_TYPE Release
C A C H E S T R I N G " S e t b u i l d t y p e t o D e b u g o Release ( default Release ) " F O R C E )
2015-12-19 01:47:49 -08:00
endif ( )
2016-11-01 23:33:11 +03:00
string ( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER )
2015-12-19 01:47:49 -08:00
2013-12-09 18:05:32 +01:00
# get rid of the extra default configurations
2015-12-19 01:47:49 -08:00
# what? why would you get id of other useful build types? - Ellzey
2013-12-09 18:05:32 +01:00
set ( CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configurations" FORCE )
2013-12-19 10:54:52 +01:00
project ( libevent C )
2013-12-09 18:05:32 +01:00
2015-12-20 00:43:46 -08:00
set ( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/" )
2016-08-10 00:16:48 +03:00
string ( REGEX MATCH "SunOS" SOLARIS "${CMAKE_SYSTEM_NAME}" )
2015-12-20 00:43:46 -08:00
2015-12-21 04:36:24 -08:00
include ( CheckTypeSize )
2015-12-20 00:43:46 -08:00
include ( CheckFunctionExistsEx )
include ( CheckFileOffsetBits )
include ( CheckFunctionExists )
include ( CheckIncludeFile )
include ( CheckIncludeFiles )
include ( CheckVariableExists )
include ( CheckSymbolExists )
include ( CheckStructHasMember )
include ( CheckCSourceCompiles )
include ( CheckPrototypeDefinition )
include ( CheckFunctionKeywords )
2017-01-30 03:17:41 +03:00
include ( CheckConstExists )
2015-12-20 00:43:46 -08:00
include ( AddCompilerFlags )
include ( VersionViaGit )
2014-02-19 06:31:27 +01:00
2015-12-20 00:43:46 -08:00
event_fuzzy_version_from_git ( )
2015-12-19 01:47:49 -08:00
2015-12-20 00:43:46 -08:00
set ( EVENT_VERSION_MAJOR ${ EVENT_GIT___VERSION_MAJOR } )
set ( EVENT_VERSION_MINOR ${ EVENT_GIT___VERSION_MINOR } )
set ( EVENT_VERSION_PATCH ${ EVENT_GIT___VERSION_PATCH } )
2015-12-20 21:44:04 -08:00
set ( EVENT_VERSION_STAGE ${ EVENT_GIT___VERSION_STAGE } )
2015-12-19 01:47:49 -08:00
2014-02-19 06:31:27 +01:00
2015-12-20 00:43:46 -08:00
set ( EVENT_ABI_MAJOR ${ EVENT_VERSION_MAJOR } )
set ( EVENT_ABI_MINOR ${ EVENT_VERSION_MINOR } )
set ( EVENT_ABI_PATCH ${ EVENT_VERSION_PATCH } )
2015-12-19 01:47:49 -08:00
2015-12-20 00:43:46 -08:00
set ( EVENT_ABI_LIBVERSION
" $ { E V E N T _ A B I _ M A J O R } . $ { E V E N T _ A B I _ M I N O R } . $ { E V E N T _ A B I _ P A T C H } " )
2015-12-19 01:47:49 -08:00
2015-12-20 00:43:46 -08:00
set ( EVENT_PACKAGE_VERSION
" $ { E V E N T _ V E R S I O N _ M A J O R } . $ { E V E N T _ V E R S I O N _ M I N O R } . $ { E V E N T _ V E R S I O N _ P A T C H } " )
2017-01-29 18:13:07 +03:00
set ( EVENT_NUMERIC_VERSION 0x02020001 )
2015-12-19 01:47:49 -08:00
# only a subset of names can be used, defaults to "beta"
2017-01-29 20:19:06 +03:00
set ( EVENT_STAGE_NAME ${ EVENT_VERSION_STAGE } )
2015-12-19 01:47:49 -08:00
# a list that defines what can set for EVENT_STAGE_VERSION
set ( EVENT__ALLOWED_STAGE_NAMES
2017-01-29 20:19:06 +03:00
r c
b e t a
a l p h a
a l p h a - d e v
r e l e a s e
s t a b l e
)
list (
F I N D E V E N T _ _ A L L O W E D _ S T A G E _ N A M E S
" $ { E V E N T _ S T A G E _ N A M E } "
E V E N T _ _ S T A G E _ R E T
)
if ( EVENT__STAGE_RET EQUAL -1 )
message ( WARNING
" s t a g e $ { E V E N T _ S T A G E _ N A M E } i s n o t a l l o w e d , r e s e t t o b e t a " )
2015-12-21 17:43:00 -08:00
set ( EVENT_STAGE_NAME beta )
2015-12-19 01:47:49 -08:00
endif ( )
2015-12-20 00:43:46 -08:00
set ( EVENT_VERSION
2015-12-20 21:44:04 -08:00
" $ { E V E N T _ V E R S I O N _ M A J O R } . $ { E V E N T _ V E R S I O N _ M I N O R } . $ { E V E N T _ V E R S I O N _ P A T C H } - $ { E V E N T _ S T A G E _ N A M E } " )
2015-12-20 00:43:46 -08:00
option ( EVENT__BUILD_SHARED_LIBRARIES
" D e f i n e i f l i b e v e n t s h o u l d b e b u i l t w i t h s h a r e d l i b r a r i e s i n s t e a d o f a r c h i v e s " O F F )
option ( EVENT__DISABLE_DEBUG_MODE
" D e f i n e i f l i b e v e n t s h o u l d b u i l d w i t h o u t s u p p o r t f o r a d e b u g m o d e " O F F )
option ( EVENT__ENABLE_VERBOSE_DEBUG
" E n a b l e s v e r b o s e d e b u g g i n g " O F F )
option ( EVENT__DISABLE_MM_REPLACEMENT
" D e f i n e i f l i b e v e n t s h o u l d n o t a l l o w r e p l a c i n g t h e m m f u n c t i o n s " O F F )
option ( EVENT__DISABLE_THREAD_SUPPORT
" D e f i n e i f l i b e v e n t s h o u l d n o t b e c o m p i l e d w i t h t h r e a d s u p p o r t " O F F )
option ( EVENT__DISABLE_OPENSSL
" D e f i n e i f l i b e v e n t s h o u l d b u i l d w i t h o u t s u p p o r t f o r O p e n S S L e n c r p y t i o n " O F F )
option ( EVENT__DISABLE_BENCHMARK
" D e f i n e s i f l i b e v e n t s h o u l d b u i l d w i t h o u t t h e b e n c h m a r k e x e c t u a b l e s " O F F )
option ( EVENT__DISABLE_TESTS
" I f t e s t s s h o u l d b e c o m p i l e d o r n o t " O F F )
option ( EVENT__DISABLE_REGRESS
" D i s a b l e t h e r e g r e s s t e s t s " O F F )
option ( EVENT__DISABLE_SAMPLES
" D i s a b l e s a m p l e f i l e s " O F F )
2016-10-03 03:17:18 +03:00
option ( EVENT__DISABLE_CLOCK_GETTIME
" D o n o t u s e c l o c k _ g e t t i m e e v e n i f i t i s a v a i l a b l e " O F F )
2015-12-20 00:43:46 -08:00
option ( EVENT__FORCE_KQUEUE_CHECK
" W h e n c r o s s c o m p i l i n g f o r c e s r u n n i n g a t e s t p r o g r a m t h a t v e r i f i e s t h a t K q u e u e w o r k s w i t h p i p e s . N o t e t h a t t h i s r e q u i r e s y o u t o m a n u a l l y r u n t h e t e s t p r o g r a m o n t h e t h e c r o s s c o m p i l a t i o n t a r g e t t o v e r i f y t h a t i t w o r k s . S e e c m a k e d o c u m e n t a t i o n f o r t r y _ r u n f o r m o r e d e t a i l s " O F F )
2013-12-13 17:00:23 +01:00
# TODO: Add --disable-largefile omit support for large files
2015-12-20 00:43:46 -08:00
option ( EVENT__COVERAGE
" E n a b l e r u n n i n g g c o v t o g e t a t e s t c o v e r a g e report ( only works with GCC/CLang ) . M a k e s u r e t o e n a b l e - D C M A K E _ B U I L D _ T Y P E = D e b u g a s w e l l . " O F F )
2013-12-09 18:05:32 +01:00
# Put the libaries and binaries that get built into directories at the
2014-09-02 18:25:52 +04:00
# top of the build tree rather than in hard-to-find leaf directories.
2013-12-09 18:05:32 +01:00
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 )
2014-01-14 17:37:58 +01:00
if ( EVENT__ENABLE_VERBOSE_DEBUG )
2016-08-07 23:46:26 +03:00
add_definitions ( -DUSE_DEBUG=1 )
2014-01-14 17:37:58 +01:00
endif ( )
2013-12-17 15:17:29 +00:00
# Setup compiler flags for coverage.
if ( EVENT__COVERAGE )
2016-11-01 23:33:11 +03:00
if ( NOT "${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "debug" )
2015-12-20 00:43:46 -08:00
message ( FATAL_ERROR "Coverage requires -DCMAKE_BUILD_TYPE=Debug" )
2013-12-17 15:17:29 +00:00
endif ( )
2014-09-02 18:25:52 +04:00
2015-12-19 01:47:49 -08:00
message ( STATUS "Setting coverage compiler flags" )
2016-11-01 23:33:11 +03:00
set ( CMAKE_REQUIRED_LIBRARIES "--coverage" )
add_compiler_flags ( -g -O0 --coverage )
set ( CMAKE_REQUIRED_LIBRARIES "" )
2013-12-17 15:17:29 +00:00
endif ( )
2013-12-19 12:03:49 +00:00
# GCC specific options.
2013-12-13 17:00:23 +01:00
if ( CMAKE_COMPILER_IS_GNUCC )
option ( EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF )
2015-12-19 01:47:49 -08:00
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_WARNINGS "Make all GCC warnings into errors" OFF )
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS -Wall -Wswitch )
2015-12-19 01:47:49 -08:00
2013-12-13 17:00:23 +01:00
if ( EVENT__DISABLE_GCC_WARNINGS )
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS -w )
2013-12-13 17:00:23 +01:00
endif ( )
if ( EVENT__ENABLE_GCC_HARDENING )
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS
- f s t a c k - p r o t e c t o r - a l l
- f w r a p v
- f P I E
- W s t a c k - p r o t e c t o r
" - - p a r a m s s p - b u f f e r - s i z e = 1 " )
add_definitions ( -D_FORTIFY_SOURCE=2 )
2013-12-13 17:00:23 +01:00
endif ( )
if ( EVENT__ENABLE_GCC_FUNCTION_SECTIONS )
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS -ffunction-sections )
2013-12-13 17:00:23 +01:00
# TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works.
endif ( )
2013-12-19 12:03:49 +00:00
if ( EVENT__ENABLE_GCC_WARNINGS )
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS -Werror )
2013-12-19 12:03:49 +00:00
endif ( )
2013-12-13 17:00:23 +01:00
# We need to test for at least gcc 2.95 here, because older versions don't
# have -fno-strict-aliasing
2016-03-10 00:33:04 +03:00
list ( APPEND __FLAGS -fno-strict-aliasing )
2015-12-19 01:47:49 -08:00
2016-03-10 00:33:04 +03:00
add_compiler_flags ( ${ __FLAGS } )
2013-12-13 17:00:23 +01:00
endif ( )
2013-12-17 13:28:23 +01:00
if ( APPLE )
# Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater.
2016-03-10 00:33:04 +03:00
add_compiler_flags (
- W n o - e r r o r = d e p r e c a t e d - d e c l a r a t i o n s
- Q u n u s e d - a r g u m e n t s
)
2013-12-17 13:28:23 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
# Winsock.
if ( WIN32 )
set ( CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h )
set ( CMAKE_REQUIRED_LIBRARIES ws2_32.lib )
set ( CMAKE_REQUIRED_DEFINITIONS -FIwinsock2.h -FIws2tcpip.h )
endif ( )
2016-08-10 00:27:59 +03:00
if ( SOLARIS )
set ( CMAKE_REQUIRED_LIBRARIES socket nsl )
endif ( )
2013-12-09 18:05:32 +01:00
# Check if _GNU_SOURCE is available.
CHECK_SYMBOL_EXISTS ( __GNU_LIBRARY__ "features.h" _GNU_SOURCE )
if ( _GNU_SOURCE )
add_definitions ( -D_GNU_SOURCE )
endif ( )
CHECK_INCLUDE_FILE ( sys/types.h EVENT__HAVE_SYS_TYPES_H )
if ( EVENT__HAVE_SYS_TYPES_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES sys/types.h )
endif ( )
CHECK_INCLUDE_FILE ( sys/socket.h EVENT__HAVE_SYS_SOCKET_H )
if ( EVENT__HAVE_SYS_SOCKET_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES sys/socket.h )
endif ( )
CHECK_INCLUDE_FILE ( netinet/in.h EVENT__HAVE_NETINET_IN_H )
if ( EVENT__HAVE_NETINET_IN_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in.h )
endif ( )
CHECK_INCLUDE_FILE ( netinet/in6.h EVENT__HAVE_NETINET_IN6_H )
if ( EVENT__HAVE_NETINET_IN6_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in6.h )
endif ( )
CHECK_INCLUDE_FILE ( unistd.h EVENT__HAVE_UNISTD_H )
CHECK_INCLUDE_FILE ( netdb.h EVENT__HAVE_NETDB_H )
CHECK_INCLUDE_FILE ( dlfcn.h EVENT__HAVE_DLFCN_H )
CHECK_INCLUDE_FILE ( arpa/inet.h EVENT__HAVE_ARPA_INET_H )
CHECK_INCLUDE_FILE ( fcntl.h EVENT__HAVE_FCNTL_H )
if ( EVENT__HAVE_FCNTL_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES fcntl.h )
endif ( )
CHECK_INCLUDE_FILE ( inttypes.h EVENT__HAVE_INTTYPES_H )
CHECK_INCLUDE_FILE ( memory.h EVENT__HAVE_MEMORY_H )
CHECK_INCLUDE_FILE ( poll.h EVENT__HAVE_POLL_H )
CHECK_INCLUDE_FILE ( port.h EVENT__HAVE_PORT_H )
if ( EVENT__HAVE_PORT_H )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES port.h )
endif ( )
CHECK_INCLUDE_FILE ( signal.h EVENT__HAVE_SIGNAL_H )
CHECK_INCLUDE_FILE ( stdarg.h EVENT__HAVE_STDARG_H )
CHECK_INCLUDE_FILE ( stddef.h EVENT__HAVE_STDDEF_H )
CHECK_INCLUDE_FILE ( stdint.h EVENT__HAVE_STDINT_H )
CHECK_INCLUDE_FILE ( stdlib.h EVENT__HAVE_STDLIB_H )
CHECK_INCLUDE_FILE ( strings.h EVENT__HAVE_STRINGS_H )
CHECK_INCLUDE_FILE ( string.h EVENT__HAVE_STRING_H )
CHECK_INCLUDE_FILE ( sys/devpoll.h EVENT__HAVE_SYS_DEVPOLL_H )
CHECK_INCLUDE_FILE ( sys/epoll.h EVENT__HAVE_SYS_EPOLL_H )
CHECK_INCLUDE_FILE ( sys/eventfd.h EVENT__HAVE_SYS_EVENTFD_H )
CHECK_INCLUDE_FILE ( sys/event.h EVENT__HAVE_SYS_EVENT_H )
CHECK_INCLUDE_FILE ( sys/ioctl.h EVENT__HAVE_SYS_IOCTL_H )
CHECK_INCLUDE_FILE ( sys/mman.h EVENT__HAVE_SYS_MMAN_H )
CHECK_INCLUDE_FILE ( sys/param.h EVENT__HAVE_SYS_PARAM_H )
CHECK_INCLUDE_FILE ( sys/queue.h EVENT__HAVE_SYS_QUEUE_H )
CHECK_INCLUDE_FILE ( sys/select.h EVENT__HAVE_SYS_SELECT_H )
CHECK_INCLUDE_FILE ( sys/sendfile.h EVENT__HAVE_SYS_SENDFILE_H )
CHECK_INCLUDE_FILE ( sys/stat.h EVENT__HAVE_SYS_STAT_H )
CHECK_INCLUDE_FILE ( sys/time.h EVENT__HAVE_SYS_TIME_H )
if ( EVENT__HAVE_SYS_TIME_H )
2013-12-16 18:10:32 +01:00
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES sys/time.h )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_INCLUDE_FILE ( sys/uio.h EVENT__HAVE_SYS_UIO_H )
CHECK_INCLUDE_FILES ( "sys/types.h;ifaddrs.h" EVENT__HAVE_IFADDRS_H )
CHECK_INCLUDE_FILE ( mach/mach_time.h EVENT__HAVE_MACH_MACH_TIME_H )
CHECK_INCLUDE_FILE ( netinet/tcp.h EVENT__HAVE_NETINET_TCP_H )
CHECK_INCLUDE_FILE ( sys/wait.h EVENT__HAVE_SYS_WAIT_H )
CHECK_INCLUDE_FILE ( sys/resource.h EVENT__HAVE_SYS_RESOURCE_H )
CHECK_INCLUDE_FILE ( sys/sysctl.h EVENT__HAVE_SYS_SYSCTL_H )
CHECK_INCLUDE_FILE ( sys/timerfd.h EVENT__HAVE_SYS_TIMERFD_H )
2016-06-28 10:37:24 -07:00
CHECK_INCLUDE_FILE ( errno.h EVENT__HAVE_ERRNO_H )
2013-12-09 18:05:32 +01:00
CHECK_FUNCTION_EXISTS_EX ( epoll_create EVENT__HAVE_EPOLL )
CHECK_FUNCTION_EXISTS_EX ( epoll_ctl EVENT__HAVE_EPOLL_CTL )
CHECK_FUNCTION_EXISTS_EX ( eventfd EVENT__HAVE_EVENTFD )
2016-10-03 03:17:18 +03:00
if ( NOT EVENT__DISABLE_CLOCK_GETTIME )
CHECK_FUNCTION_EXISTS_EX ( clock_gettime EVENT__HAVE_CLOCK_GETTIME )
endif ( )
2013-12-09 18:05:32 +01:00
CHECK_FUNCTION_EXISTS_EX ( fcntl EVENT__HAVE_FCNTL )
CHECK_FUNCTION_EXISTS_EX ( getaddrinfo EVENT__HAVE_GETADDRINFO )
CHECK_FUNCTION_EXISTS_EX ( getnameinfo EVENT__HAVE_GETNAMEINFO )
CHECK_FUNCTION_EXISTS_EX ( gettimeofday EVENT__HAVE_GETTIMEOFDAY )
CHECK_FUNCTION_EXISTS_EX ( getprotobynumber EVENT__HAVE_GETPROTOBYNUMBER )
CHECK_FUNCTION_EXISTS_EX ( getservbyname EVENT__HAVE_GETSERVBYNAME )
CHECK_FUNCTION_EXISTS_EX ( inet_ntop EVENT__HAVE_INET_NTOP )
CHECK_FUNCTION_EXISTS_EX ( inet_pton EVENT__HAVE_INET_PTON )
CHECK_FUNCTION_EXISTS_EX ( kqueue EVENT__HAVE_KQUEUE )
CHECK_FUNCTION_EXISTS_EX ( mmap EVENT__HAVE_MMAP )
CHECK_FUNCTION_EXISTS_EX ( pipe EVENT__HAVE_PIPE )
CHECK_FUNCTION_EXISTS_EX ( pipe2 EVENT__HAVE_PIPE2 )
CHECK_FUNCTION_EXISTS_EX ( poll EVENT__HAVE_POLL )
CHECK_FUNCTION_EXISTS_EX ( port_create EVENT__HAVE_PORT_CREATE )
CHECK_FUNCTION_EXISTS_EX ( sendfile EVENT__HAVE_SENDFILE )
CHECK_FUNCTION_EXISTS_EX ( sigaction EVENT__HAVE_SIGACTION )
CHECK_FUNCTION_EXISTS_EX ( signal EVENT__HAVE_SIGNAL )
CHECK_FUNCTION_EXISTS_EX ( splice EVENT__HAVE_SPLICE )
CHECK_FUNCTION_EXISTS_EX ( strlcpy EVENT__HAVE_STRLCPY )
CHECK_FUNCTION_EXISTS_EX ( strsep EVENT__HAVE_STRSEP )
CHECK_FUNCTION_EXISTS_EX ( strtok_r EVENT__HAVE_STRTOK_R )
CHECK_FUNCTION_EXISTS_EX ( strtoll EVENT__HAVE_STRTOLL )
CHECK_FUNCTION_EXISTS_EX ( vasprintf EVENT__HAVE_VASPRINTF )
CHECK_FUNCTION_EXISTS_EX ( sysctl EVENT__HAVE_SYSCTL )
CHECK_FUNCTION_EXISTS_EX ( accept4 EVENT__HAVE_ACCEPT4 )
CHECK_FUNCTION_EXISTS_EX ( arc4random EVENT__HAVE_ARC4RANDOM )
CHECK_FUNCTION_EXISTS_EX ( arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF )
CHECK_FUNCTION_EXISTS_EX ( epoll_create1 EVENT__HAVE_EPOLL_CREATE1 )
CHECK_FUNCTION_EXISTS_EX ( getegid EVENT__HAVE_GETEGID )
CHECK_FUNCTION_EXISTS_EX ( geteuid EVENT__HAVE_GETEUID )
CHECK_FUNCTION_EXISTS_EX ( getifaddrs EVENT__HAVE_GETIFADDRS )
CHECK_FUNCTION_EXISTS_EX ( issetugid EVENT__HAVE_ISSETUGID )
CHECK_FUNCTION_EXISTS_EX ( mach_absolute_time EVENT__HAVE_MACH_ABSOLUTE_TIME )
CHECK_FUNCTION_EXISTS_EX ( nanosleep EVENT__HAVE_NANOSLEEP )
CHECK_FUNCTION_EXISTS_EX ( usleep EVENT__HAVE_USLEEP )
CHECK_FUNCTION_EXISTS_EX ( timeradd EVENT__HAVE_TIMERADD )
CHECK_FUNCTION_EXISTS_EX ( timerclear EVENT__HAVE_TIMERCLEAR )
CHECK_FUNCTION_EXISTS_EX ( timercmp EVENT__HAVE_TIMERCMP )
CHECK_FUNCTION_EXISTS_EX ( timerfd_create HAVE_TIMERFD_CREATE )
CHECK_FUNCTION_EXISTS_EX ( timerisset EVENT__HAVE_TIMERISSET )
CHECK_FUNCTION_EXISTS_EX ( putenv EVENT__HAVE_PUTENV )
CHECK_FUNCTION_EXISTS_EX ( setenv EVENT__HAVE_SETENV )
CHECK_FUNCTION_EXISTS_EX ( setrlimit EVENT__HAVE_SETRLIMIT )
CHECK_FUNCTION_EXISTS_EX ( umask EVENT__HAVE_UMASK )
CHECK_FUNCTION_EXISTS_EX ( unsetenv EVENT__HAVE_UNSETENV )
# Get the gethostbyname_r prototype.
CHECK_FUNCTION_EXISTS_EX ( gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R )
if ( EVENT__HAVE_GETHOSTBYNAME_R )
2014-09-02 18:25:52 +04:00
CHECK_PROTOTYPE_DEFINITION ( gethostbyname_r
2013-12-09 18:05:32 +01:00
" i n t gethostbyname_r ( const char *name, struct hostent *hp, struct hostent_data *hdata ) "
" 0 "
" n e t d b . h "
E V E N T _ _ H A V E _ G E T H O S T B Y N A M E _ R _ 3 _ A R G )
2014-09-02 18:25:52 +04:00
CHECK_PROTOTYPE_DEFINITION ( gethostbyname_r
2013-12-09 18:05:32 +01:00
" s t r u c t h o s t e n t * gethostbyname_r ( const char *name, struct hostent *hp, char *buf, size_t buflen, int *herr ) "
" N U L L "
" n e t d b . h "
E V E N T _ _ H A V E _ G E T H O S T B Y N A M E _ R _ 5 _ A R G )
2014-09-02 18:25:52 +04:00
CHECK_PROTOTYPE_DEFINITION ( gethostbyname_r
2013-12-09 18:05:32 +01:00
" i n t gethostbyname_r ( const char *name, struct hostent *hp, char *buf, size_t buflen, struct hostent **result, int *herr ) "
" 0 "
" n e t d b . h "
E V E N T _ _ H A V E _ G E T H O S T B Y N A M E _ R _ 6 _ A R G )
endif ( )
if ( HAVE_PORT_H AND HAVE_PORT_CREATE )
set ( EVENT__HAVE_EVENT_PORTS 1 )
endif ( )
if ( NOT WIN32 )
2013-12-16 18:10:32 +01:00
CHECK_FUNCTION_EXISTS_EX ( select EVENT__HAVE_SELECT )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_TYPE_SIZE ( "uint8_t" EVENT__HAVE_UINT8_T )
CHECK_TYPE_SIZE ( "uint16_t" EVENT__HAVE_UINT16_T )
CHECK_TYPE_SIZE ( "uint32_t" EVENT__HAVE_UINT32_T )
CHECK_TYPE_SIZE ( "uint64_t" EVENT__HAVE_UINT64_T )
CHECK_TYPE_SIZE ( "short" EVENT__SIZEOF_SHORT BUILTIN_TYPES_ONLY )
CHECK_TYPE_SIZE ( "int" EVENT__SIZEOF_INT BUILTIN_TYPES_ONLY )
CHECK_TYPE_SIZE ( "unsigned" EVENT__SIZEOF_UNSIGNED BUILTIN_TYPES_ONLY )
CHECK_TYPE_SIZE ( "unsigned int" EVENT__SIZEOF_UNSIGNED_INT BUILTIN_TYPES_ONLY )
CHECK_TYPE_SIZE ( "long" EVENT__SIZEOF_LONG BUILTIN_TYPES_ONLY )
CHECK_TYPE_SIZE ( "long long" EVENT__SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY )
if ( WIN32 )
2013-12-16 18:10:32 +01:00
# These aren't available until Windows Vista.
# But you can still link them. They just won't be found when running the exe.
set ( EVENT__HAVE_INET_NTOP 0 )
set ( EVENT__HAVE_INET_PTON 0 )
2013-12-09 18:05:32 +01:00
endif ( )
# Check for different inline keyword versions.
2015-12-19 01:47:49 -08:00
check_function_keywords ( "inline" "__inline" "__inline__" )
if ( HAVE_INLINE )
2015-12-20 00:43:46 -08:00
set ( EVENT__inline inline )
2015-12-19 01:47:49 -08:00
elseif ( HAVE___INLINE )
2015-12-20 00:43:46 -08:00
set ( EVENT__inline __inline )
2015-12-19 01:47:49 -08:00
elseif ( HAVE___INLINE__ )
2015-12-20 00:43:46 -08:00
set ( EVENT__inline __inline__ )
2015-12-19 01:47:49 -08:00
else ( )
2015-12-20 00:43:46 -08:00
set ( EVENT__inline )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_SYMBOL_EXISTS ( TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH )
2017-01-30 03:17:41 +03:00
CHECK_CONST_EXISTS ( CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN )
CHECK_CONST_EXISTS ( KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND )
CHECK_CONST_EXISTS ( KERN_RANDOM sys/sysctl.h EVENT__HAVE_DECL_KERN_RANDOM )
CHECK_CONST_EXISTS ( RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID )
2013-12-09 18:05:32 +01:00
CHECK_SYMBOL_EXISTS ( F_SETFD fcntl.h EVENT__HAVE_SETFD )
CHECK_TYPE_SIZE ( fd_mask EVENT__HAVE_FD_MASK )
2015-12-19 01:47:49 -08:00
2015-12-21 04:36:24 -08:00
CHECK_TYPE_SIZE ( size_t EVENT__SIZEOF_SIZEE_T )
2013-12-09 18:05:32 +01:00
if ( NOT EVENT__SIZEOF_SIZE_T )
2015-12-20 21:44:04 -08:00
set ( EVENT__size_t "unsigned" )
2013-12-09 18:05:32 +01:00
set ( EVENT__SIZEOF_SIZE_T ${ EVENT__SIZEOF_UNSIGNED } )
2015-12-19 01:47:49 -08:00
else ( )
2015-12-20 21:44:04 -08:00
set ( EVENT__size_t size_t )
2013-12-09 18:05:32 +01:00
endif ( )
2015-12-21 04:36:24 -08:00
CHECK_TYPE_SIZE ( "off_t" EVENT__SIZEOF_OFF_T LANGUAGE C )
2013-12-09 18:05:32 +01:00
2015-12-21 04:36:24 -08:00
# XXX we should functionalize these size and type sets. --elley
# Winssck.
2016-01-07 17:51:40 +03:00
if ( _MSC_VER )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES BaseTsd.h )
endif ( )
CHECK_TYPE_SIZE ( "ssize_t" EVENT__SIZEOF_SSIZE_T_LOWER LANGUAGE C )
CHECK_TYPE_SIZE ( "SSIZE_T" EVENT__SIZEOF_SSIZE_T_UPPER LANGUAGE C )
if ( EVENT__SIZEOF_SSIZE_T_LOWER )
set ( EVENT__ssize_t "ssize_t" )
2016-08-24 16:19:01 +08:00
set ( EVENT__SIZEOF_SSIZE_T ${ EVENT__SIZEOF_SSIZE_T_LOWER } )
2016-01-07 17:51:40 +03:00
elseif ( EVENT__SIZEOF_SSIZE_T_UPPER )
set ( EVENT__ssize_t "SSIZE_T" )
2016-08-24 16:19:01 +08:00
set ( EVENT__SIZEOF_SSIZE_T ${ EVENT__SIZEOF_SSIZE_T_UPPER } )
2016-01-07 17:51:40 +03:00
else ( )
set ( EVENT__ssize_t "int" )
set ( EVENT__SIZEOF_SSIZE_T ${ EVENT__SIZEOF_INT } )
2013-12-09 18:05:32 +01:00
endif ( )
2015-12-21 04:36:24 -08:00
2013-12-09 18:05:32 +01:00
CHECK_TYPE_SIZE ( socklen_t EVENT__SIZEOF_SOCKLEN_T )
if ( NOT EVENT__SIZEOF_SOCKLEN_T )
set ( EVENT__socklen_t "unsigned int" )
set ( EVENT__SIZEOF_SOCKLEN_T ${ EVENT__SIZEOF_UNSIGNED_INT } )
2015-12-19 01:47:49 -08:00
else ( )
2015-12-20 00:43:46 -08:00
set ( EVENT__socklen_t "socklen_t" )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_TYPE_SIZE ( pid_t EVENT__SIZEOF_PID_T )
if ( NOT EVENT__SIZEOF_PID_T )
2015-12-20 21:44:04 -08:00
set ( EVENT__pid_t "int" )
2013-12-09 18:05:32 +01:00
set ( EVENT__SIZEOF_PID_T ${ EVENT__SIZEOF_INT } )
2015-12-20 21:44:04 -08:00
else ( )
set ( EVENT__pid_t "pid_t" )
set ( EVENT__SIZEOF_PID_T EVENT__SIZEOF_PID_T )
2013-12-09 18:05:32 +01:00
endif ( )
2015-12-19 01:47:49 -08:00
if ( NOT EVENT__DISABLE_THREAD_SUPPORT )
2017-03-05 22:07:23 +03:00
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES pthread.h )
2015-12-20 00:43:46 -08:00
CHECK_TYPE_SIZE ( pthread_t EVENT__SIZEOF_PTHREAD_T )
2015-12-19 01:47:49 -08:00
endif ( )
2013-12-09 18:05:32 +01:00
if ( EVENT__HAVE_CLOCK_GETTIME )
set ( EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1 )
endif ( )
2015-12-21 04:36:24 -08:00
# we're just getting lazy now.
2013-12-09 18:05:32 +01:00
CHECK_TYPE_SIZE ( "uintptr_t" EVENT__HAVE_UINTPTR_T )
CHECK_TYPE_SIZE ( "void *" EVENT__SIZEOF_VOID_P )
# Tests file offset bits.
# TODO: Add AIX test for if -D_LARGE_FILES is needed.
2015-12-19 01:47:49 -08:00
# XXX: Why is this here? we don't even use it. Well, we don't even use it
# on top of that, why is it set in the config.h?! IT_MAKES_NO_SENSE
# I'm commenting it out for now.
# - ellzey
#CHECK_FILE_OFFSET_BITS()
#set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS)
2013-12-09 18:05:32 +01:00
2013-12-17 14:01:21 +01:00
# Verify kqueue works with pipes.
2013-12-17 13:29:04 +01:00
if ( EVENT__HAVE_KQUEUE )
2013-12-17 14:01:21 +01:00
if ( CMAKE_CROSSCOMPILING AND NOT EVENT__FORCE_KQUEUE_CHECK )
message ( WARNING "Cannot check if kqueue works with pipes when crosscompiling, use EVENT__FORCE_KQUEUE_CHECK to be sure (this requires manually running a test program on the cross compilation target)" )
set ( EVENT__HAVE_WORKING_KQUEUE 1 )
else ( )
2015-12-19 01:47:49 -08:00
message ( STATUS "Checking if kqueue works with pipes..." )
2013-12-17 14:01:21 +01:00
include ( CheckWorkingKqueue )
endif ( )
2013-12-17 13:29:04 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
CHECK_SYMBOL_EXISTS ( _MINIX "stdio.h" EVENT___MINIX )
CHECK_SYMBOL_EXISTS ( _POSIX_1_SOURCE "stdio.h" EVENT___POSIX_1_SOURCE )
CHECK_SYMBOL_EXISTS ( _POSIX_SOURCE "stdio.h" EVENT___POSIX_SOURCE )
if ( EVENT__HAVE_NETDB_H )
2013-12-16 18:10:32 +01:00
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES netdb.h )
CHECK_TYPE_SIZE ( "struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO )
2013-12-09 18:05:32 +01:00
elseif ( WIN32 )
2013-12-16 18:10:32 +01:00
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h )
CHECK_TYPE_SIZE ( "struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO )
2013-12-09 18:05:32 +01:00
endif ( )
# Check for sockaddr structure sizes.
set ( SOCKADDR_HEADERS )
if ( WIN32 )
set ( CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN" )
if ( _MSC_VER LESS 1300 )
set ( SOCKADDR_HEADERS winsock.h )
else ( )
set ( SOCKADDR_HEADERS winsock2.h ws2tcpip.h )
endif ( )
else ( )
if ( EVENT__HAVE_NETINET_IN_H )
set ( SOCKADDR_HEADERS ${ SOCKADDR_HEADERS } netinet/in.h )
endif ( )
if ( EVENT__HAVE_NETINET_IN6_H )
set ( SOCKADDR_HEADERS ${ SOCKADDR_HEADERS } netinet/in6.h )
endif ( )
if ( EVENT__HAVE_SYS_SOCKET_H )
set ( SOCKADDR_HEADERS ${ SOCKADDR_HEADERS } sys/socket.h )
endif ( )
if ( EVENT__HAVE_NETDB_H )
set ( SOCKADDR_HEADERS ${ SOCKADDR_HEADERS } netdb.h )
endif ( )
endif ( )
CHECK_TYPE_SIZE ( "struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR )
if ( EVENT__HAVE_STRUCT_IN6_ADDR )
2015-12-20 00:43:46 -08:00
CHECK_STRUCT_HAS_MEMBER ( "struct in6_addr"
s 6 _ a d d r 1 6 " $ { S O C K A D D R _ H E A D E R S } "
E V E N T _ _ H A V E _ S T R U C T _ I N 6 _ A D D R _ S 6 _ A D D R 1 6 )
CHECK_STRUCT_HAS_MEMBER ( "struct in6_addr"
s 6 _ a d d r 3 2 " $ { S O C K A D D R _ H E A D E R S } "
E V E N T _ _ H A V E _ S T R U C T _ I N 6 _ A D D R _ S 6 _ A D D R 3 2 )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_TYPE_SIZE ( "sa_family_t" EVENT__HAVE_SA_FAMILY_T )
CHECK_TYPE_SIZE ( "struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6 )
2015-12-20 00:43:46 -08:00
2013-12-09 18:05:32 +01:00
if ( EVENT__HAVE_STRUCT_SOCKADDR_IN6 )
2015-12-20 00:43:46 -08:00
CHECK_STRUCT_HAS_MEMBER ( "struct sockaddr_in6"
s i n 6 _ l e n " $ { S O C K A D D R _ H E A D E R S } "
E V E N T _ _ H A V E _ S T R U C T _ S O C K A D D R _ I N 6 _ S I N 6 _ L E N )
CHECK_STRUCT_HAS_MEMBER ( "struct sockaddr_in6"
s i n _ l e n " $ { S O C K A D D R _ H E A D E R S } "
E V E N T _ _ H A V E _ S T R U C T _ S O C K A D D R _ I N _ S I N _ L E N )
2013-12-09 18:05:32 +01:00
endif ( )
CHECK_TYPE_SIZE ( "struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE )
if ( EVENT__HAVE_STRUCT_SOCKADDR_STORAGE )
2015-12-20 00:43:46 -08:00
CHECK_STRUCT_HAS_MEMBER ( "struct sockaddr_storage"
s s _ f a m i l y " $ { S O C K A D D R _ H E A D E R S } "
E V E N T _ _ H A V E _ S T R U C T _ S O C K A D D R _ S T O R A G E _ S S _ F A M I L Y )
CHECK_STRUCT_HAS_MEMBER ( "struct sockaddr_storage"
_ _ s s _ f a m i l y " $ { S O C K A D D R _ H E A D E R S } " E V E N T _ _ H A V E _ S T R U C T _ S O C K A D D R _ S T O R A G E _ _ _ S S _ F A M I L Y )
2013-12-09 18:05:32 +01:00
endif ( )
2017-01-29 23:05:18 +03:00
CHECK_TYPE_SIZE ( "struct linger" EVENT__HAVE_STRUCT_LINGER )
2013-12-09 18:05:32 +01:00
# Group the source files.
set ( HDR_PRIVATE
b u f f e r e v e n t - i n t e r n a l . h
c h a n g e l i s t - i n t e r n a l . h
d e f e r - i n t e r n a l . h
2014-01-21 15:47:44 -05:00
e p o l l t a b l e - i n t e r n a l . h
2013-12-09 18:05:32 +01:00
e v b u f f e r - i n t e r n a l . h
e v e n t - i n t e r n a l . h
e v m a p - i n t e r n a l . h
e v r p c - i n t e r n a l . h
e v s i g n a l - i n t e r n a l . h
e v t h r e a d - i n t e r n a l . h
h t - i n t e r n a l . h
h t t p - i n t e r n a l . h
i o c p - i n t e r n a l . h
i p v 6 - i n t e r n a l . h
l o g - i n t e r n a l . h
m i n h e a p - i n t e r n a l . h
m m - i n t e r n a l . h
r a t e l i m - i n t e r n a l . h
s t r l c p y - i n t e r n a l . h
u t i l - i n t e r n a l . h
e v c o n f i g - p r i v a t e . h
2015-12-20 00:43:46 -08:00
c o m p a t / s y s / q u e u e . h )
2014-09-02 18:25:52 +04:00
set ( HDR_COMPAT
i n c l u d e / e v d n s . h
i n c l u d e / e v r p c . h
i n c l u d e / e v e n t . h
i n c l u d e / e v h t t p . h
2015-12-20 00:43:46 -08:00
i n c l u d e / e v u t i l . h )
2014-09-02 18:25:52 +04:00
2013-12-09 18:05:32 +01:00
set ( HDR_PUBLIC
i n c l u d e / e v e n t 2 / b u f f e r . h
i n c l u d e / e v e n t 2 / b u f f e r e v e n t . h
i n c l u d e / e v e n t 2 / b u f f e r e v e n t _ c o m p a t . h
i n c l u d e / e v e n t 2 / b u f f e r e v e n t _ s t r u c t . h
i n c l u d e / e v e n t 2 / b u f f e r _ c o m p a t . h
i n c l u d e / e v e n t 2 / d n s . h
i n c l u d e / e v e n t 2 / d n s _ c o m p a t . h
i n c l u d e / e v e n t 2 / d n s _ s t r u c t . h
i n c l u d e / e v e n t 2 / e v e n t . h
i n c l u d e / e v e n t 2 / e v e n t _ c o m p a t . h
i n c l u d e / e v e n t 2 / e v e n t _ s t r u c t . h
i n c l u d e / e v e n t 2 / h t t p . h
i n c l u d e / e v e n t 2 / h t t p _ c o m p a t . h
i n c l u d e / e v e n t 2 / h t t p _ s t r u c t . h
2014-03-24 15:01:02 +01:00
i n c l u d e / e v e n t 2 / k e y v a l q _ s t r u c t . h
2013-12-09 18:05:32 +01:00
i n c l u d e / e v e n t 2 / l i s t e n e r . h
i n c l u d e / e v e n t 2 / r p c . h
i n c l u d e / e v e n t 2 / r p c _ c o m p a t . h
i n c l u d e / e v e n t 2 / r p c _ s t r u c t . h
i n c l u d e / e v e n t 2 / t a g . h
i n c l u d e / e v e n t 2 / t a g _ c o m p a t . h
i n c l u d e / e v e n t 2 / t h r e a d . h
i n c l u d e / e v e n t 2 / u t i l . h
2014-03-21 12:12:10 +01:00
i n c l u d e / e v e n t 2 / v i s i b i l i t y . h
2015-12-20 00:43:46 -08:00
$ { P R O J E C T _ B I N A R Y _ D I R } / i n c l u d e / e v e n t 2 / e v e n t - c o n f i g . h )
2013-12-09 18:05:32 +01:00
set ( SRC_CORE
2014-09-02 18:25:52 +04:00
b u f f e r . c
b u f f e r e v e n t . c
b u f f e r e v e n t _ f i l t e r . c
b u f f e r e v e n t _ p a i r . c
b u f f e r e v e n t _ r a t e l i m . c
b u f f e r e v e n t _ s o c k . c
e v e n t . c
e v m a p . c
e v t h r e a d . c
e v u t i l . c
2013-12-09 18:05:32 +01:00
e v u t i l _ r a n d . c
2013-12-16 18:10:32 +01:00
e v u t i l _ t i m e . c
2014-09-02 18:25:52 +04:00
l i s t e n e r . c
l o g . c
s i g n a l . c
2015-12-20 00:43:46 -08:00
s t r l c p y . c )
2013-12-09 18:05:32 +01:00
if ( EVENT__HAVE_SELECT )
list ( APPEND SRC_CORE select.c )
endif ( )
if ( EVENT__HAVE_POLL )
list ( APPEND SRC_CORE poll.c )
endif ( )
if ( EVENT__HAVE_KQUEUE )
list ( APPEND SRC_CORE kqueue.c )
endif ( )
if ( EVENT__HAVE_DEVPOLL )
list ( APPEND SRC_CORE devpoll.c )
endif ( )
if ( EVENT__HAVE_EPOLL )
list ( APPEND SRC_CORE epoll_sub.c epoll.c )
endif ( )
if ( EVENT__HAVE_EVENT_PORTS )
list ( APPEND SRC_CORE evport.c )
endif ( )
if ( NOT EVENT__DISABLE_OPENSSL )
find_package ( OpenSSL REQUIRED )
2015-12-20 00:43:46 -08:00
2013-12-12 16:33:20 +01:00
set ( EVENT__HAVE_OPENSSL 1 )
2015-12-20 00:43:46 -08:00
2015-12-19 01:47:49 -08:00
message ( STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}" )
message ( STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}" )
2015-12-20 00:43:46 -08:00
2013-12-12 16:33:20 +01:00
include_directories ( ${ OPENSSL_INCLUDE_DIR } )
2015-12-20 00:43:46 -08:00
2013-12-12 16:33:20 +01:00
list ( APPEND SRC_CORE bufferevent_openssl.c )
list ( APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h )
2013-12-13 17:00:23 +01:00
list ( APPEND LIB_APPS ${ OPENSSL_LIBRARIES } )
2013-12-09 18:05:32 +01:00
endif ( )
2013-12-12 16:33:20 +01:00
if ( NOT EVENT__DISABLE_THREAD_SUPPORT )
if ( WIN32 )
list ( APPEND SRC_CORE evthread_win32.c )
else ( )
find_package ( Threads REQUIRED )
if ( NOT CMAKE_USE_PTHREADS_INIT )
2015-12-20 00:43:46 -08:00
message ( FATAL_ERROR
" F a i l e d t o f i n d P t h r e a d s , s e t E V E N T _ _ D I S A B L E _ T H R E A D _ S U P P O R T t o d i s a b l e " )
2013-12-12 16:33:20 +01:00
endif ( )
2015-12-20 00:43:46 -08:00
2013-12-12 16:33:20 +01:00
set ( EVENT__HAVE_PTHREADS 1 )
list ( APPEND SRC_CORE evthread_pthread.c )
2013-12-13 17:00:23 +01:00
list ( APPEND LIB_APPS ${ CMAKE_THREAD_LIBS_INIT } )
2013-12-12 16:33:20 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
endif ( )
2013-12-19 10:46:04 +00:00
if ( NOT EVENT__DISABLE_TESTS )
# Zlib is only used for testing.
find_package ( ZLIB )
2016-08-09 10:56:34 +03:00
if ( ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR )
2015-12-20 00:43:46 -08:00
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
2016-08-24 16:19:01 +08:00
set ( EVENT__HAVE_LIBZ 1 )
2013-12-19 10:46:04 +00:00
list ( APPEND LIB_APPS ${ ZLIB_LIBRARIES } )
endif ( )
2013-12-09 18:05:32 +01:00
endif ( )
set ( SRC_EXTRA
2014-09-02 18:25:52 +04:00
e v e n t _ t a g g i n g . c
h t t p . c
e v d n s . c
2015-12-20 00:43:46 -08:00
e v r p c . c )
2013-12-09 18:05:32 +01:00
add_definitions ( -DHAVE_CONFIG_H )
2014-01-21 11:19:02 +01:00
# We use BEFORE here so we don't accidentally look in system directories
# first for some previous versions of the headers that are installed.
include_directories ( BEFORE ${ PROJECT_SOURCE_DIR }
$ { P R O J E C T _ S O U R C E _ D I R } / c o m p a t
$ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e )
2013-12-09 18:05:32 +01:00
if ( WIN32 )
2014-09-02 18:25:52 +04:00
list ( APPEND SRC_CORE
b u f f e r _ i o c p . c
2013-12-09 18:05:32 +01:00
b u f f e r e v e n t _ a s y n c . c
2014-09-02 18:25:52 +04:00
e v e n t _ i o c p . c
2015-12-20 00:43:46 -08:00
w i n 3 2 s e l e c t . c )
2014-09-02 18:25:52 +04:00
2013-12-12 16:33:20 +01:00
list ( APPEND HDR_PRIVATE WIN32-Code/getopt.h )
2013-12-09 18:05:32 +01:00
set ( EVENT__DNS_USE_FTIME_FOR_ID 1 )
set ( LIB_PLATFORM ws2_32 )
2015-12-20 00:43:46 -08:00
add_definitions (
- D _ C R T _ S E C U R E _ N O _ W A R N I N G S
- D _ C R T _ N O N S T D C _ N O _ D E P R E C A T E )
2013-12-13 12:39:50 +00:00
include_directories ( ./WIN32-Code )
endif ( )
if ( UNIX )
list ( APPEND LIB_PLATFORM m )
2013-12-09 18:05:32 +01:00
endif ( )
2016-08-10 00:16:48 +03:00
if ( SOLARIS )
list ( APPEND LIB_PLATFORM socket nsl )
endif ( )
2013-12-09 18:05:32 +01:00
source_group ( "Headers Private" FILES ${ HDR_PRIVATE } )
2014-09-02 18:25:52 +04:00
source_group ( "Header Compat" FILES ${ HDR_COMPAT } )
2013-12-09 18:05:32 +01:00
source_group ( "Headers Public" FILES ${ HDR_PUBLIC } )
source_group ( "Source Core" FILES ${ SRC_CORE } )
source_group ( "Source Extra" FILES ${ SRC_EXTRA } )
2013-12-13 11:34:22 +01:00
# Generate the configure headers.
# (Place them in the build dir so we don't polute the source tree with generated files).
2014-01-21 11:19:02 +01:00
include_directories ( BEFORE ${ CMAKE_CURRENT_BINARY_DIR } /include )
2013-12-13 11:34:22 +01:00
2014-02-19 06:31:27 +01:00
if ( EVENT__BUILD_SHARED_LIBRARIES )
set ( EVENT__LIBRARY_TYPE SHARED )
2015-12-20 00:43:46 -08:00
if ( ( CMAKE_COMPILER_IS_GNUCC ) OR ( ${ CMAKE_C_COMPILER_ID } STREQUAL "Clang" ) )
add_compiler_flags ( -fvisibility=hidden )
2014-02-19 06:31:27 +01:00
elseif ( "${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro" )
2015-12-20 00:43:46 -08:00
add_compiler_flags ( -xldscope=hidden )
endif ( )
2014-02-19 06:31:27 +01:00
2015-12-20 00:43:46 -08:00
set ( EVENT__NEED_DLLIMPORT 1 )
2014-02-19 06:31:27 +01:00
else ( EVENT__BUILD_SHARED_LIBRARIES )
set ( EVENT__LIBRARY_TYPE STATIC )
endif ( EVENT__BUILD_SHARED_LIBRARIES )
2013-12-09 18:05:32 +01:00
configure_file (
2014-02-19 06:31:27 +01:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / e v e n t - c o n f i g . h . c m a k e
2015-12-19 01:47:49 -08:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / e v e n t 2 / e v e n t - c o n f i g . h
2015-12-20 00:43:46 -08:00
N E W L I N E _ S T Y L E UNIX )
2013-12-13 11:34:22 +01:00
configure_file (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / e v c o n f i g - p r i v a t e . h . c m a k e
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / e v c o n f i g - p r i v a t e . h )
2013-12-09 18:05:32 +01:00
2014-01-09 13:44:38 +01:00
#
# Create the libraries.
#
2013-12-12 16:33:20 +01:00
# TODO: Add dynamic versions of the libraries as well.
2014-02-19 06:31:27 +01:00
add_library ( event_core ${ EVENT__LIBRARY_TYPE }
2013-12-09 18:05:32 +01:00
$ { H D R _ P R I V A T E }
2014-09-02 18:25:52 +04:00
$ { H D R _ C O M P A T }
2013-12-09 18:05:32 +01:00
$ { H D R _ P U B L I C }
2015-12-20 00:43:46 -08:00
$ { S R C _ C O R E } )
2014-02-19 06:31:27 +01:00
add_library ( event_extra ${ EVENT__LIBRARY_TYPE }
2014-02-19 06:29:58 +01:00
$ { H D R _ P R I V A T E }
2014-09-02 18:25:52 +04:00
$ { H D R _ C O M P A T }
2014-02-19 06:29:58 +01:00
$ { H D R _ P U B L I C }
$ { S R C _ C O R E }
2015-12-20 00:43:46 -08:00
$ { S R C _ E X T R A } )
2013-12-12 16:33:20 +01:00
2014-02-19 06:29:58 +01:00
# library exists for historical reasons; it contains the contents of
# both libevent_core and libevent_extra. You shouldn’ t use it; it may
# go away in a future version of Libevent.
2014-02-19 06:31:27 +01:00
add_library ( event ${ EVENT__LIBRARY_TYPE }
2013-12-09 18:05:32 +01:00
$ { H D R _ P R I V A T E }
2014-09-02 18:25:52 +04:00
$ { H D R _ C O M P A T }
2013-12-09 18:05:32 +01:00
$ { H D R _ P U B L I C }
$ { S R C _ C O R E }
2015-12-20 00:43:46 -08:00
$ { S R C _ E X T R A } )
2013-12-09 18:05:32 +01:00
2015-01-03 02:22:31 +09:00
if ( EVENT__BUILD_SHARED_LIBRARIES )
# Prepare static library to be linked to tests that need hidden symbols
add_library ( event_extra_static STATIC
$ { H D R _ P R I V A T E }
$ { H D R _ C O M P A T }
$ { H D R _ P U B L I C }
$ { S R C _ C O R E }
2015-12-20 00:43:46 -08:00
$ { S R C _ E X T R A } )
2015-01-03 02:22:31 +09:00
set ( EVENT_EXTRA_FOR_TEST event_extra_static )
2014-02-19 06:31:27 +01:00
target_link_libraries ( event_core ${ OPENSSL_LIBRARIES }
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
$ { L I B _ P L A T F O R M } )
target_link_libraries ( event ${ OPENSSL_LIBRARIES }
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
$ { L I B _ P L A T F O R M } )
target_link_libraries ( event_extra ${ OPENSSL_LIBRARIES }
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
$ { L I B _ P L A T F O R M } )
2015-12-20 00:43:46 -08:00
set_target_properties ( event
P R O P E R T I E S S O V E R S I O N
$ { E V E N T _ A B I _ L I B V E R S I O N } )
set_target_properties ( event_core
P R O P E R T I E S S O V E R S I O N
$ { E V E N T _ A B I _ L I B V E R S I O N } )
set_target_properties ( event_extra
P R O P E R T I E S S O V E R S I O N
$ { E V E N T _ A B I _ L I B V E R S I O N } )
2014-02-19 06:31:27 +01:00
2015-01-03 02:22:31 +09:00
else ( EVENT__BUILD_SHARED_LIBRARIES )
set ( EVENT_EXTRA_FOR_TEST event_extra )
2014-02-19 06:31:27 +01:00
endif ( EVENT__BUILD_SHARED_LIBRARIES )
2014-01-09 13:44:38 +01:00
#
# Samples.
#
2013-12-12 16:33:20 +01:00
if ( NOT EVENT__DISABLE_SAMPLES )
2013-12-13 17:00:23 +01:00
set ( SAMPLES
d n s - e x a m p l e
e v e n t - r e a d - f i f o
h e l l o - w o r l d
s i g n a l - t e s t
h t t p - s e r v e r
2015-08-18 12:18:31 +03:00
h t t p - c o n n e c t
2013-12-13 17:00:23 +01:00
t i m e - t e s t )
2014-01-22 00:03:37 +01:00
if ( NOT EVENT__DISABLE_OPENSSL AND OPENSSL_LIBRARIES )
2015-11-23 18:44:03 +03:00
# Special sample with more than one file.
2013-12-13 17:00:23 +01:00
add_executable ( https-client
s a m p l e / h t t p s - c l i e n t . c
s a m p l e / o p e n s s l _ h o s t n a m e _ v a l i d a t i o n . c
s a m p l e / h o s t c h e c k . c )
2015-12-20 00:43:46 -08:00
target_link_libraries ( https-client
e v e n t _ e x t r a
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M } )
2014-02-19 06:29:58 +01:00
add_dependencies ( https-client event_extra )
2014-01-22 00:03:37 +01:00
# Requires OpenSSL.
list ( APPEND SAMPLES le-proxy )
2013-12-13 17:00:23 +01:00
endif ( )
foreach ( SAMPLE ${ SAMPLES } )
2015-12-20 00:43:46 -08:00
add_executable ( ${ SAMPLE }
s a m p l e / $ { S A M P L E } . c )
target_link_libraries ( ${ SAMPLE }
e v e n t _ e x t r a
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M } )
2014-02-19 06:29:58 +01:00
add_dependencies ( ${ SAMPLE } event_extra )
2013-12-13 17:00:23 +01:00
endforeach ( )
2016-01-12 01:57:07 +03:00
if ( WIN32 )
target_sources ( dns-example PUBLIC
WIN32 - C o d e / g e t o p t . c
WIN32 - C o d e / g e t o p t _ l o n g . c )
endif ( )
2013-12-12 16:33:20 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
if ( NOT EVENT__DISABLE_BENCHMARK )
2013-12-12 16:33:20 +01:00
foreach ( BENCHMARK bench bench_cascade bench_http bench_httpclient )
2013-12-16 11:34:14 +01:00
set ( BENCH_SRC test/ ${ BENCHMARK } .c )
2014-02-19 06:29:58 +01:00
2013-12-16 11:34:14 +01:00
if ( WIN32 )
2015-12-20 00:43:46 -08:00
list ( APPEND BENCH_SRC
WIN32 - C o d e / g e t o p t . c
WIN32 - C o d e / g e t o p t _ l o n g . c )
2013-12-16 11:34:14 +01:00
endif ( )
add_executable ( ${ BENCHMARK } ${ BENCH_SRC } )
2015-12-20 00:43:46 -08:00
target_link_libraries ( ${ BENCHMARK }
e v e n t _ e x t r a
$ { L I B _ P L A T F O R M } )
2014-02-19 06:29:58 +01:00
add_dependencies ( ${ BENCHMARK } event_extra )
2013-12-12 16:33:20 +01:00
endforeach ( )
2013-12-09 18:05:32 +01:00
endif ( )
if ( NOT EVENT__DISABLE_TESTS )
2013-12-12 16:33:20 +01:00
#
2013-12-12 18:21:11 +01:00
# Generate Regress tests.
2013-12-12 16:33:20 +01:00
#
2014-01-22 00:06:21 +01:00
if ( NOT EVENT__DISABLE_REGRESS )
2014-09-02 18:25:52 +04:00
2016-10-30 11:19:43 +03:00
# (We require python2 to generate the regress tests)
foreach ( PY python2.6 python2.7 python2 )
unset ( FIND_PYTHON2 CACHE )
find_program ( FIND_PYTHON2 ${ PY } )
if ( FIND_PYTHON2 )
set ( PYTHON_EXECUTABLE "${PY}" )
break ( )
endif ( )
endforeach ( )
2014-09-02 18:25:52 +04:00
find_package ( PythonInterp )
2015-12-20 00:43:46 -08:00
2016-10-30 11:19:43 +03:00
if ( PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0.0" )
2014-09-02 18:25:52 +04:00
set ( __FOUND_USABLE_PYTHON 1 )
endif ( )
if ( __FOUND_USABLE_PYTHON )
2015-12-19 01:47:49 -08:00
message ( STATUS "Generating regress tests..." )
2015-12-20 00:43:46 -08:00
2014-01-22 00:06:21 +01:00
add_definitions ( -DTINYTEST_LOCAL )
2015-12-20 00:43:46 -08:00
2014-01-22 00:06:21 +01:00
add_custom_command (
2014-09-02 18:25:52 +04:00
O U T P U T
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t e s t / r e g r e s s . g e n . c
2014-01-22 00:06:21 +01:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t e s t / r e g r e s s . g e n . h
2014-09-02 18:25:52 +04:00
D E P E N D S
2014-01-22 00:06:21 +01:00
e v e n t _ r p c g e n . p y
2014-09-02 18:25:52 +04:00
t e s t / r e g r e s s . r p c
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } . . / e v e n t _ r p c g e n . p y r e g r e s s . r p c
2015-12-20 00:43:46 -08:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t e s t )
2014-01-22 00:06:21 +01:00
2014-09-02 18:25:52 +04:00
list ( APPEND SRC_REGRESS
2014-01-22 00:06:21 +01:00
t e s t / r e g r e s s . c
t e s t / r e g r e s s . g e n . c
t e s t / r e g r e s s . g e n . h
t e s t / r e g r e s s _ b u f f e r . c
t e s t / r e g r e s s _ b u f f e r e v e n t . c
t e s t / r e g r e s s _ d n s . c
t e s t / r e g r e s s _ e t . c
t e s t / r e g r e s s _ f i n a l i z e . c
2014-09-02 18:25:52 +04:00
t e s t / r e g r e s s _ h t t p . c
t e s t / r e g r e s s _ l i s t e n e r . c
2014-01-22 00:06:21 +01:00
t e s t / r e g r e s s _ m a i n . c
t e s t / r e g r e s s _ m i n h e a p . c
t e s t / r e g r e s s _ r p c . c
t e s t / r e g r e s s _ t e s t u t i l s . c
t e s t / r e g r e s s _ t e s t u t i l s . h
2014-09-02 18:25:52 +04:00
t e s t / r e g r e s s _ u t i l . c
2014-01-22 00:06:21 +01:00
t e s t / t i n y t e s t . c
2014-02-19 06:31:27 +01:00
$ { S R C _ C O R E }
2015-12-20 00:43:46 -08:00
$ { S R C _ E X T R A } )
2014-01-22 00:06:21 +01:00
if ( WIN32 )
list ( APPEND SRC_REGRESS test/regress_iocp.c )
2016-08-08 15:50:46 +03:00
if ( NOT EVENT__DISABLE_THREAD_SUPPORT )
list ( APPEND SRC_REGRESS test/regress_thread.c )
endif ( )
2014-01-22 00:06:21 +01:00
endif ( )
if ( CMAKE_USE_PTHREADS_INIT )
list ( APPEND SRC_REGRESS test/regress_thread.c )
endif ( )
2016-08-09 10:56:34 +03:00
if ( ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR )
2014-01-22 00:06:21 +01:00
list ( APPEND SRC_REGRESS test/regress_zlib.c )
endif ( )
if ( OPENSSL_LIBRARIES )
list ( APPEND SRC_REGRESS test/regress_ssl.c )
endif ( )
add_executable ( regress ${ SRC_REGRESS } )
2015-12-20 00:43:46 -08:00
2014-02-19 06:31:27 +01:00
# While building the test suite we don't want the visibility
# header trying to "dllimport" the symbols on windows (it
# generates a ton of warnings due to different link
# attributes for all of the symbols)
2015-12-20 00:43:46 -08:00
SET_TARGET_PROPERTIES ( regress
P R O P E R T I E S C O M P I L E _ D E F I N I T I O N S
" E V E N T _ B U I L D I N G _ R E G R E S S _ T E S T = 1 " )
2014-02-19 06:31:27 +01:00
2015-12-20 00:43:46 -08:00
target_link_libraries ( regress
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M } )
2014-01-22 00:06:21 +01:00
else ( )
2014-09-02 18:25:52 +04:00
message ( WARNING "No suitable Python interpreter found, cannot generate regress tests!" )
2013-12-12 16:33:20 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
endif ( )
2013-12-12 18:21:11 +01:00
#
# Test programs.
#
2015-12-20 00:43:46 -08:00
# all of these, including the cmakelists.txt should be moved
# into the dirctory 'tests' first.
#
# doing this, we can remove all the DISABLE_TESTS stuff, and simply
# do something like:
#
# add_custom_targets(tests)
# add_executable(... EXCLUDE_FROM_ALL ...c)
# add_dependencis(tests testa testb testc)
# add_test(....)
#
# then you can just run 'make tests' instead of them all
# auto-compile|running
# - ellzey
2013-12-12 18:21:11 +01:00
set ( TESTPROGS test-changelist
t e s t - e o f
t e s t - f d l e a k
t e s t - i n i t
t e s t - t i m e
t e s t - w e o f )
2015-12-20 00:43:46 -08:00
set ( ALL_TESTPROGS
$ { T E S T P R O G S }
t e s t - d u m p e v e n t s
t e s t - r a t e l i m )
2013-12-16 18:10:32 +01:00
2013-12-12 18:21:11 +01:00
# Create test program executables.
2013-12-16 18:10:32 +01:00
foreach ( TESTPROG ${ ALL_TESTPROGS } )
2015-12-20 00:43:46 -08:00
add_executable ( ${ TESTPROG }
t e s t / $ { T E S T P R O G } . c )
target_link_libraries ( ${ TESTPROG }
$ { E V E N T _ E X T R A _ F O R _ T E S T }
$ { L I B _ P L A T F O R M } )
add_dependencies ( ${ TESTPROG }
$ { E V E N T _ E X T R A _ F O R _ T E S T } )
2013-12-12 18:21:11 +01:00
endforeach ( )
#
# We run all tests with the different backends turned on one at a time.
#
2013-12-16 16:37:51 +01:00
# Add event backends based on system introspection result.
set ( BACKENDS "" )
if ( EVENT__HAVE_EPOLL )
list ( APPEND BACKENDS EPOLL )
endif ( )
if ( EVENT__HAVE_SELECT )
list ( APPEND BACKENDS SELECT )
endif ( )
if ( EVENT__HAVE_POLL )
list ( APPEND BACKENDS POLL )
endif ( )
if ( EVENT__HAVE_KQUEUE )
list ( APPEND BACKENDS KQUEUE )
endif ( )
if ( EVENT__HAVE_EVENT_PORTS )
list ( APPEND BACKENDS EVPORT )
endif ( )
if ( EVENT__HAVE_DEVPOLL )
list ( APPEND BACKENDS DEVPOLL )
endif ( )
if ( WIN32 )
list ( APPEND BACKENDS WIN32 )
endif ( )
2013-12-12 18:21:11 +01:00
# Default environment variables turns off all event systems,
# then we enable each one, one at a time when creating the tests.
2013-12-16 16:37:51 +01:00
set ( DEFAULT_TEST_ENV_VARS "EVENT_SHOW_METHOD=1;" )
2013-12-12 18:21:11 +01:00
foreach ( BACKEND ${ BACKENDS } )
2013-12-16 16:44:13 +00:00
set ( BACKEND_ENV_VAR "EVENT_NO${BACKEND}=1" )
list ( APPEND DEFAULT_TEST_ENV_VARS "${BACKEND_ENV_VAR}" )
2013-12-12 18:21:11 +01:00
endforeach ( )
# Macro that creates the ctest test for a backend.
macro ( add_backend_test BACKEND_TEST_NAME ENV_VARS )
2013-12-16 16:37:51 +01:00
set ( TEST_NAMES "" )
2013-12-12 18:21:11 +01:00
foreach ( TESTPROG ${ TESTPROGS } )
2013-12-16 16:44:13 +00:00
set ( TEST_NAME ${ TESTPROG } __ ${ BACKEND_TEST_NAME } )
2015-12-20 00:43:46 -08:00
add_test ( ${ TEST_NAME }
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / $ { T E S T P R O G } )
2013-12-16 16:37:51 +01:00
list ( APPEND TEST_NAMES ${ TEST_NAME } )
2015-12-20 00:43:46 -08:00
set_tests_properties ( ${ TEST_NAME }
P R O P E R T I E S E N V I R O N M E N T " $ { E N V _ V A R S } " )
2013-12-12 18:21:11 +01:00
endforeach ( )
# Dump events test.
2014-09-02 18:25:52 +04:00
if ( __FOUND_USABLE_PYTHON )
2013-12-16 16:44:13 +00:00
set ( TEST_NAME test-dumpevents__ ${ BACKEND_TEST_NAME } )
2015-12-20 00:43:46 -08:00
add_test ( ${ TEST_NAME }
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / t e s t - d u m p e v e n t s |
$ { P Y T H O N _ E X E C U T A B L E }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t e s t / c h e c k - d u m p e v e n t s . p y )
set_tests_properties ( ${ TEST_NAME }
P R O P E R T I E S E N V I R O N M E N T " $ { E N V _ V A R S } " )
2013-12-12 18:21:11 +01:00
else ( )
message ( WARNING "test-dumpevents will be run without output check since python was not found!" )
2013-12-16 16:44:13 +00:00
set ( TEST_NAME test-dumpevents__ ${ BACKEND_TEST_NAME } _no_check )
2015-12-20 00:43:46 -08:00
add_test ( ${ TEST_NAME }
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / t e s t - d u m p e v e n t s )
set_tests_properties ( ${ TEST_NAME }
P R O P E R T I E S E N V I R O N M E N T " $ { E N V _ V A R S } " )
2013-12-12 18:21:11 +01:00
endif ( )
# Regress tests.
2014-09-02 18:25:52 +04:00
if ( NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON )
2013-12-16 16:44:13 +00:00
set ( TEST_NAME regress__ ${ BACKEND_TEST_NAME } )
2015-09-02 11:51:00 +03:00
2015-12-20 00:43:46 -08:00
add_test ( ${ TEST_NAME }
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / r e g r e s s )
set_tests_properties ( ${ TEST_NAME }
P R O P E R T I E S E N V I R O N M E N T " $ { E N V _ V A R S } " )
add_test ( ${ TEST_NAME } _debug
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / r e g r e s s )
set_tests_properties ( ${ TEST_NAME } _debug
P R O P E R T I E S E N V I R O N M E N T " $ { E N V _ V A R S } ; E V E N T _ D E B U G _ M O D E = 1 " )
2013-12-12 18:21:11 +01:00
endif ( )
endmacro ( )
# Add the tests for each backend.
foreach ( BACKEND ${ BACKENDS } )
# Enable this backend only.
set ( BACKEND_ENV_VARS ${ DEFAULT_TEST_ENV_VARS } )
2013-12-13 17:00:23 +01:00
list ( REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO ${ BACKEND } =1 )
2013-12-12 18:21:11 +01:00
# Epoll has some extra settings.
if ( ${ BACKEND } STREQUAL "EPOLL" )
2015-12-20 00:43:46 -08:00
add_backend_test ( timerfd_ ${ BACKEND }
" $ { B A C K E N D _ E N V _ V A R S } ; E V E N T _ P R E C I S E _ T I M E R = 1 " )
add_backend_test ( changelist_ ${ BACKEND }
" $ { B A C K E N D _ E N V _ V A R S } ; E V E N T _ E P O L L _ U S E _ C H A N G E L I S T = y e s " )
add_backend_test ( timerfd_changelist_ ${ BACKEND }
" $ { B A C K E N D _ E N V _ V A R S } ; E V E N T _ E P O L L _ U S E _ C H A N G E L I S T = y e s ; E V E N T _ P R E C I S E _ T I M E R = 1 " )
2013-12-12 18:21:11 +01:00
else ( )
2013-12-16 16:37:51 +01:00
add_backend_test ( ${ BACKEND } "${BACKEND_ENV_VARS}" )
2013-12-12 18:21:11 +01:00
endif ( )
endforeach ( )
#
# Rate limiter tests.
#
# Group limits, no connection limit.
2015-12-20 00:43:46 -08:00
set ( RL_BIN ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } /test-ratelim )
add_test ( test-ratelim__group_lim
$ { R L _ B I N }
- g 3 0 0 0 0
- n 3 0
- t 1 0 0
- - c h e c k - g r o u p l i m i t 1 0 0 0
- - c h e c k - s t d d e v 1 0 0 )
2013-12-12 18:21:11 +01:00
# Connection limit, no group limit.
2015-12-20 00:43:46 -08:00
add_test ( test-ratelim__con_lim
$ { R L _ B I N }
- c 1 0 0 0
- n 3 0
- t 1 0 0
- - c h e c k - c o n n l i m i t 5 0
- - c h e c k - s t d d e v 5 0 )
2014-09-02 18:25:52 +04:00
2013-12-12 18:21:11 +01:00
# Connection limit and group limit.
2015-12-20 00:43:46 -08:00
add_test ( test-ratelim__group_con_lim
$ { R L _ B I N }
- c 1 0 0 0
- g 3 0 0 0 0
- n 3 0
- t 1 0 0
- - c h e c k - g r o u p l i m i t 1 0 0 0
- - c h e c k - c o n n l i m i t 5 0
- - c h e c k - s t d d e v 5 0 )
2014-09-02 18:25:52 +04:00
2013-12-12 18:21:11 +01:00
# Connection limit and group limit with independent drain.
2015-12-20 00:43:46 -08:00
add_test ( test-ratelim__group_con_lim_drain
$ { R L _ B I N }
- c 1 0 0 0
- g 3 5 0 0 0
- n 3 0
- t 1 0 0
- G 5 0 0
- - c h e c k - g r o u p l i m i t 1 0 0 0
- - c h e c k - c o n n l i m i t 5 0
- - c h e c k - s t d d e v 5 0 )
2013-12-12 18:21:11 +01:00
2013-12-16 16:44:13 +00:00
# Add a "make verify" target, same as for autoconf.
2014-09-02 18:25:52 +04:00
# (Important! This will unset all EVENT_NO* environment variables.
2013-12-16 16:44:13 +00:00
# If they are set in the shell the tests are running using simply "ctest" or "make test" will fail)
2013-12-16 18:10:32 +01:00
if ( WIN32 )
2014-01-22 12:12:51 +01:00
# Windows doesn't have "unset". But you can use "set VAR=" instead.
# We need to guard against the possibility taht EVENT_NOWIN32 is set, and all test failing
# since no event backend being available.
file ( TO_NATIVE_PATH ${ CMAKE_CTEST_COMMAND } WINDOWS_CTEST_COMMAND )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /tmp/verify_tests.bat
"
s e t E V E N T _ N O W I N 3 2 =
\ " $ { W I N D O W S _ C T E S T _ C O M M A N D } \ "
" )
2015-12-19 01:47:49 -08:00
message ( STATUS "${WINDOWS_CTEST_COMMAND}" )
2014-01-22 12:12:51 +01:00
2015-12-20 00:43:46 -08:00
file ( COPY ${ CMAKE_CURRENT_BINARY_DIR } /tmp/verify_tests.bat
D E S T I N A T I O N
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
F I L E _ P E R M I S S I O N S
O W N E R _ R E A D
O W N E R _ W R I T E
O W N E R _ E X E C U T E
G R O U P _ R E A D
G R O U P _ E X E C U T E
W O R L D _ R E A D W O R L D _ E X E C U T E )
file ( TO_NATIVE_PATH
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / v e r i f y _ t e s t s . b a t " V E R I F Y _ P A T H )
2014-01-22 12:12:51 +01:00
add_custom_target ( verify COMMAND "${VERIFY_PATH}"
2013-12-16 18:10:32 +01:00
D E P E N D S e v e n t $ { A L L _ T E S T P R O G S } )
else ( )
2013-12-19 10:54:52 +01:00
# On some platforms doing exec(unset) as CMake does won't work, so make sure
# we run the unset command in a shell instead.
# First we write the script contents.
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /tmp/verify_tests.sh
"
#!/bin/bash
u n s e t E V E N T _ N O E P O L L ; u n s e t E V E N T _ N O P O L L ; u n s e t E V E N T _ N O S E L E C T ; u n s e t E V E N T _ N O W I N 3 2 ; u n s e t E V E N T _ N O E V P O R T ; u n s e t E V E N T _ N O K Q U E U E ; u n s e t E V E N T _ N O D E V P O L L
$ { C M A K E _ C T E S T _ C O M M A N D }
" )
# Then we copy the file (this allows us to set execute permission on it)
file ( COPY ${ CMAKE_CURRENT_BINARY_DIR } /tmp/verify_tests.sh
D E S T I N A T I O N $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
2015-12-20 00:43:46 -08:00
F I L E _ P E R M I S S I O N S
O W N E R _ R E A D
O W N E R _ W R I T E
O W N E R _ E X E C U T E
G R O U P _ R E A D
G R O U P _ E X E C U T E
W O R L D _ R E A D
W O R L D _ E X E C U T E )
2013-12-19 10:54:52 +01:00
# Create the target that runs the script.
2015-12-20 00:43:46 -08:00
add_custom_target ( verify
C O M M A N D
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / v e r i f y _ t e s t s . s h
D E P E N D S
e v e n t
$ { A L L _ T E S T P R O G S } )
2013-12-16 18:10:32 +01:00
endif ( )
2013-12-16 16:44:13 +00:00
2014-09-02 18:25:52 +04:00
if ( NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON )
2013-12-16 16:44:13 +00:00
add_dependencies ( verify regress )
endif ( )
2013-12-17 15:17:29 +00:00
if ( EVENT__COVERAGE )
include ( CodeCoverage )
setup_target_for_coverage (
v e r i f y _ c o v e r a g e # Coverage target name "make verify_coverage"
m a k e # Test runner.
c o v e r a g e # Output directory.
v e r i f y ) # Arguments passed to test runner. "make verify"
endif ( )
2013-12-09 18:05:32 +01:00
enable_testing ( )
include ( CTest )
endif ( )
2014-01-09 13:44:38 +01:00
#
# Installation preparation.
#
# Allow the user to override installation directories.
set ( EVENT_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries" )
set ( EVENT_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables" )
set ( EVENT_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files" )
if ( WIN32 AND NOT CYGWIN )
set ( DEF_INSTALL_CMAKE_DIR cmake )
else ( )
set ( DEF_INSTALL_CMAKE_DIR lib/cmake/libevent )
endif ( )
set ( EVENT_INSTALL_CMAKE_DIR ${ DEF_INSTALL_CMAKE_DIR } CACHE PATH "Installation directory for CMake files" )
# Make sure the paths are absolute.
foreach ( p LIB BIN INCLUDE CMAKE )
set ( var EVENT_INSTALL_ ${ p } _DIR )
if ( NOT IS_ABSOLUTE "${${var}}" )
set ( ${ var } "${CMAKE_INSTALL_PREFIX}/${${var}}" )
endif ( )
endforeach ( )
# Export targets (This is used for other CMake projects to easily find the libraries and include files).
2014-02-19 06:29:58 +01:00
export ( TARGETS event event_extra event_core
2014-01-09 13:44:38 +01:00
F I L E " $ { P R O J E C T _ B I N A R Y _ D I R } / L i b e v e n t T a r g e t s . c m a k e " )
export ( PACKAGE libevent )
# Generate the config file for the build-tree.
2014-09-02 18:25:52 +04:00
set ( EVENT__INCLUDE_DIRS
2014-01-09 13:44:38 +01:00
" $ { P R O J E C T _ S O U R C E _ D I R } / i n c l u d e "
" $ { P R O J E C T _ B I N A R Y _ D I R } / i n c l u d e " )
2015-12-20 00:43:46 -08:00
set ( LIBEVENT_INCLUDE_DIRS
$ { E V E N T _ _ I N C L U D E _ D I R S }
C A C H E P A T H " L i b e v e n t i n c l u d e d i r e c t o r i e s " )
2015-02-05 00:56:58 +01:00
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/LibeventConfigBuildTree.cmake.in
2014-09-02 18:25:52 +04:00
$ { P R O J E C T _ B I N A R Y _ D I R } / L i b e v e n t C o n f i g . c m a k e
2014-01-09 13:44:38 +01:00
@ O N L Y )
# Generate the config file for the installation tree.
2014-09-02 18:25:52 +04:00
file ( RELATIVE_PATH
R E L _ I N C L U D E _ D I R
2014-01-09 13:44:38 +01:00
" $ { E V E N T _ I N S T A L L _ C M A K E _ D I R } "
" $ { E V E N T _ I N S T A L L _ I N C L U D E _ D I R } " ) # Calculate the relative directory from the Cmake dir.
2014-09-02 18:25:52 +04:00
# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in,
2014-01-09 13:44:38 +01:00
# we escape it here so it's evaluated when it is included instead
2014-09-02 18:25:52 +04:00
# so that the include dirs are givenrelative to where the
2014-01-09 13:44:38 +01:00
# config file is located.
2014-09-02 18:25:52 +04:00
set ( EVENT__INCLUDE_DIRS
2014-01-14 13:01:31 +00:00
" \ $ { E V E N T _ C M A K E _ D I R } / $ { R E L _ I N C L U D E _ D I R } " )
2015-12-20 00:43:46 -08:00
2014-01-09 13:44:38 +01:00
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/LibeventConfig.cmake.in
2014-09-02 18:25:52 +04:00
$ { P R O J E C T _ B I N A R Y _ D I R } $ { C M A K E _ F I L E S _ D I R E C T O R Y } / L i b e v e n t C o n f i g . c m a k e
2014-01-09 13:44:38 +01:00
@ O N L Y )
# Generate version info for both build-tree and install-tree.
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/LibeventConfigVersion.cmake.in
2014-09-02 18:25:52 +04:00
$ { P R O J E C T _ B I N A R Y _ D I R } / L i b e v e n t C o n f i g V e r s i o n . c m a k e
2014-01-09 13:44:38 +01:00
@ O N L Y )
# Define the public headers.
2014-02-19 06:29:58 +01:00
set_target_properties ( event event_core event_extra
2014-01-22 00:03:37 +01:00
P R O P E R T I E S P U B L I C _ H E A D E R " $ { H D R _ P U B L I C } " )
2014-01-09 13:44:38 +01:00
#
# Install targets.
#
2014-02-19 06:29:58 +01:00
install ( TARGETS event event_core event_extra
2014-01-09 13:44:38 +01:00
E X P O R T L i b e v e n t T a r g e t s
2014-03-21 12:12:10 +01:00
R U N T I M E D E S T I N A T I O N " $ { E V E N T _ I N S T A L L _ B I N _ D I R } " C O M P O N E N T b i n
2014-01-09 13:44:38 +01:00
L I B R A R Y D E S T I N A T I O N " $ { E V E N T _ I N S T A L L _ L I B _ D I R } " C O M P O N E N T l i b
A R C H I V E D E S T I N A T I O N " $ { E V E N T _ I N S T A L L _ L I B _ D I R } " C O M P O N E N T l i b
P U B L I C _ H E A D E R D E S T I N A T I O N " $ { E V E N T _ I N S T A L L _ I N C L U D E _ D I R } / e v e n t 2 " C O M P O N E N T d e v )
2015-12-20 00:43:46 -08:00
2014-09-02 18:25:52 +04:00
# Install compat headers
install ( FILES ${ HDR_COMPAT }
2015-12-20 00:43:46 -08:00
D E S T I N A T I O N
" $ { E V E N T _ I N S T A L L _ I N C L U D E _ D I R } "
2014-09-02 18:25:52 +04:00
C O M P O N E N T d e v )
2014-01-09 13:44:38 +01:00
# Install the configs.
install ( FILES
$ { P R O J E C T _ B I N A R Y _ D I R } / $ { C M A K E _ F I L E S _ D I R E C T O R Y } / L i b e v e n t C o n f i g . c m a k e
2014-01-10 17:58:42 +01:00
$ { P R O J E C T _ B I N A R Y _ D I R } / L i b e v e n t C o n f i g V e r s i o n . c m a k e
2015-12-20 00:43:46 -08:00
D E S T I N A T I O N
" $ { E V E N T _ I N S T A L L _ C M A K E _ D I R } "
C O M P O N E N T d e v )
2014-01-09 13:44:38 +01:00
# Install exports for the install-tree.
2014-02-19 06:29:58 +01:00
install ( EXPORT LibeventTargets
2015-12-20 00:43:46 -08:00
D E S T I N A T I O N
" $ { E V E N T _ I N S T A L L _ C M A K E _ D I R } "
C O M P O N E N T d e v )
2014-01-14 13:01:31 +00:00
2015-12-20 00:43:46 -08:00
set ( LIBEVENT_LIBRARIES
e v e n t
e v e n t _ c o r e
e v e n t _ e x t r a
C A C H E S T R I N G " L i b e v e n t l i b r a r i e s " )
2015-12-19 01:47:49 -08:00
2016-08-07 23:07:44 +03:00
message ( STATUS "" )
message ( STATUS " ---( Libevent " ${ EVENT_VERSION } " )---" )
message ( STATUS "" )
2015-12-19 01:47:49 -08:00
message ( STATUS "Available event backends: ${BACKENDS}" )
message ( STATUS "CMAKE_BINARY_DIR: " ${ CMAKE_BINARY_DIR } )
message ( STATUS "CMAKE_CURRENT_BINARY_DIR: " ${ CMAKE_CURRENT_BINARY_DIR } )
message ( STATUS "CMAKE_SOURCE_DIR: " ${ CMAKE_SOURCE_DIR } )
message ( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${ CMAKE_CURRENT_SOURCE_DIR } )
message ( STATUS "PROJECT_BINARY_DIR: " ${ PROJECT_BINARY_DIR } )
message ( STATUS "PROJECT_SOURCE_DIR: " ${ PROJECT_SOURCE_DIR } )
message ( STATUS "CMAKE_MODULE_PATH: " ${ CMAKE_MODULE_PATH } )
message ( STATUS "CMAKE_COMMAND: " ${ CMAKE_COMMAND } )
message ( STATUS "CMAKE_ROOT: " ${ CMAKE_ROOT } )
message ( STATUS "CMAKE_SYSTEM: " ${ CMAKE_SYSTEM } )
message ( STATUS "CMAKE_SYSTEM_NAME: " ${ CMAKE_SYSTEM_NAME } )
message ( STATUS "CMAKE_SYSTEM_VERSION: " ${ CMAKE_SYSTEM_VERSION } )
message ( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${ CMAKE_SYSTEM_PROCESSOR } )
message ( STATUS "CMAKE_SKIP_RPATH: " ${ CMAKE_SKIP_RPATH } )
message ( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${ CMAKE_VERBOSE_MAKEFILE } )
message ( STATUS "CMAKE_C_FLAGS: " ${ CMAKE_C_FLAGS } )
message ( STATUS "CMAKE_BUILD_TYPE: " ${ CMAKE_BUILD_TYPE } )
message ( STATUS "CMAKE_C_COMPILER: " ${ CMAKE_C_COMPILER } )
message ( STATUS "CMAKE_AR: " ${ CMAKE_AR } )
message ( STATUS "CMAKE_RANLIB: " ${ CMAKE_RANLIB } )
2016-08-07 23:07:44 +03:00
message ( STATUS "" )
2015-12-20 00:43:46 -08:00