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
#
2018-11-22 23:00:11 +03:00
2019-06-26 00:59:41 +03:00
cmake_minimum_required ( VERSION 3.1.2 FATAL_ERROR )
2017-11-02 14:58:17 +08:00
if ( POLICY CMP0054 )
cmake_policy ( SET CMP0054 NEW )
endif ( )
2018-11-05 18:23:31 +03:00
if ( POLICY CMP0074 )
cmake_policy ( SET CMP0074 NEW )
endif ( )
2018-11-05 18:30:38 +03:00
if ( POLICY CMP0075 )
cmake_policy ( SET CMP0075 NEW )
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
2019-09-02 11:11:58 +03:00
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 r 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
2022-12-16 00:34:25 -08:00
if ( NOT DEFINED CMAKE_DEBUG_POSTFIX )
set ( CMAKE_DEBUG_POSTFIX d )
endif ( )
2022-07-29 20:49:35 +08:00
2018-11-22 23:00:11 +03:00
set ( EVENT__LIBRARY_TYPE DEFAULT CACHE STRING
2018-11-23 00:29:55 +03:00
" S e t l i b r a r y t y p e t o S H A R E D / S T A T I C / BOTH ( default SHARED for MSVC, otherwise BOTH ) " )
2018-11-22 23:00:11 +03:00
2013-12-19 10:54:52 +01:00
project ( libevent C )
2013-12-09 18:05:32 +01:00
2019-10-21 10:36:49 -07:00
list ( APPEND 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 ( CheckFileOffsetBits )
2020-03-20 17:49:37 +08:00
include ( Macros )
2015-12-20 00:43:46 -08:00
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 } " )
2019-07-10 00:30:12 +08:00
# equals to VERSION_INFO in Makefile.am
set ( EVENT_ABI_LIBVERSION_CURRENT 1 )
set ( EVENT_ABI_LIBVERSION_REVISION 0 )
set ( EVENT_ABI_LIBVERSION_AGE 0 )
# equals to RELEASE in Makefile.am
set ( EVENT_PACKAGE_RELEASE 2.2 )
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__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
2018-12-15 12:54:31 +01:00
" 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 y p t i o n " O F F )
2015-12-20 00:43:46 -08:00
2020-01-14 12:18:27 +08:00
option ( EVENT__DISABLE_MBEDTLS
" 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 m b e d T L S e n c r y p t i o n " O F F )
2015-12-20 00:43:46 -08:00
option ( EVENT__DISABLE_BENCHMARK
2018-12-15 12:54:31 +01:00
" 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 u t a b l e s " O F F )
2015-12-20 00:43:46 -08:00
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
2018-12-15 12:54:31 +01:00
" 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 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 )
2015-12-20 00:43:46 -08:00
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.
2019-11-30 15:48:36 +03:00
#
# But only if this variables are not defined yet
# (i.e. libevent is used via add_subdirectory())
if ( NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR } /bin )
endif ( )
if ( NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR } /lib )
endif ( )
if ( NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY )
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR } /lib )
endif ( )
2013-12-09 18:05:32 +01:00
2022-01-15 22:06:58 +03:00
# The RPATH to be used when installing, but only if it's not a system directory
#
# Refs: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
macro ( Configure_RPATH )
# NOTE: that CMAKE_INSTALL_PREFIX not always normalized correctly, i.e.:
# - "///" -> "/"
# - "/////usr///" -> "//usr"
# So it should be normalized again.
2022-08-13 19:10:10 +02:00
get_filename_component ( CMAKE_INSTALL_PREFIX_NORMALIZED "${CMAKE_INSTALL_PREFIX}" REALPATH )
2022-01-15 22:06:58 +03:00
list ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX_NORMALIZED}/lib" isSystemDir )
if ( "${isSystemDir}" STREQUAL "-1" )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX_NORMALIZED}/lib" )
endif ( )
endmacro ( )
Configure_RPATH ( )
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 ( )
2018-10-17 11:14:48 +03:00
# make it colorful under ninja-build
if ( "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
add_compiler_flags ( -fdiagnostics-color=always )
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
2020-08-29 01:15:20 +03:00
list ( APPEND CMAKE_REQUIRED_LIBRARIES "--coverage" )
2016-11-01 23:33:11 +03:00
add_compiler_flags ( -g -O0 --coverage )
2020-08-29 01:15:20 +03:00
list ( REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "--coverage" )
2013-12-17 15:17:29 +00:00
endif ( )
2018-10-27 14:58:30 +03:00
set ( GNUC 0 )
set ( CLANG 0 )
2018-11-23 00:29:55 +03:00
set ( MSVC 0 )
2018-10-27 14:58:30 +03:00
if ( ( "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ) OR
( " $ { C M A K E _ C _ C O M P I L E R _ I D } " S T R E Q U A L " A p p l e C l a n g " ) )
set ( CLANG 1 )
endif ( )
2018-11-23 00:29:55 +03:00
if ( ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" ) OR ( ${ CLANG } ) )
2018-10-27 14:58:30 +03:00
set ( GNUC 1 )
endif ( )
2019-05-28 12:45:59 +00:00
if ( ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" ) OR ( "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" ) )
2018-11-23 00:29:55 +03:00
set ( MSVC 1 )
endif ( )
2018-10-27 14:58:30 +03:00
2018-11-22 23:00:11 +03:00
# Detect library type
set ( EVENT_LIBRARY_TYPE )
if ( "${EVENT__LIBRARY_TYPE}" STREQUAL "DEFAULT" )
2018-11-23 00:29:55 +03:00
if ( ${ MSVC } )
set ( EVENT_LIBRARY_TYPE SHARED )
else ( )
set ( EVENT_LIBRARY_TYPE BOTH )
endif ( )
2018-11-22 23:00:11 +03:00
else ( )
string ( TOUPPER "${EVENT__LIBRARY_TYPE}" EVENT_LIBRARY_TYPE )
endif ( )
2018-11-23 00:29:55 +03:00
if ( ( ${ MSVC } ) AND ( "${EVENT_LIBRARY_TYPE}" STREQUAL "BOTH" ) )
message ( WARNING
" B u i l d i n g S H A R E D a n d S T A T I C i s n o t s u p p o r t e d f o r MSVC "
" ( d u e t o c o n f l i c t s i n l i b r a r y n a m e "
" b e t w e e n S T A T I C l i b r a r y a n d I M P O R T E D l i b r a r y f o r S H A R E D l i b r a r i e s ) " )
endif ( )
2018-11-22 23:00:11 +03:00
set ( EVENT_LIBRARY_STATIC OFF )
set ( EVENT_LIBRARY_SHARED OFF )
if ( "${EVENT_LIBRARY_TYPE}" STREQUAL "BOTH" )
set ( EVENT_LIBRARY_STATIC ON )
set ( EVENT_LIBRARY_SHARED ON )
elseif ( "${EVENT_LIBRARY_TYPE}" STREQUAL "STATIC" )
set ( EVENT_LIBRARY_STATIC ON )
elseif ( "${EVENT_LIBRARY_TYPE}" STREQUAL "SHARED" )
set ( EVENT_LIBRARY_SHARED ON )
else ( )
message ( FATAL_ERROR "${EVENT_LIBRARY_TYPE} is not supported" )
endif ( )
2020-11-01 01:39:02 +03:00
# brew support
if ( APPLE )
find_program ( BREW brew )
endif ( )
2018-12-17 21:31:54 +03:00
if ( ${ MSVC } )
set ( msvc_static_runtime OFF )
if ( "${EVENT_LIBRARY_TYPE}" STREQUAL "STATIC" )
set ( msvc_static_runtime ON )
endif ( )
# For more info:
# - https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2017
# - https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime
option ( EVENT__MSVC_STATIC_RUNTIME
" L i n k s t a t i c r u n t i m e l i b r a r i e s "
$ { m s v c _ s t a t i c _ r u n t i m e } )
if ( EVENT__MSVC_STATIC_RUNTIME )
foreach ( flag_var
C M A K E _ C _ F L A G S _ D E B U G
C M A K E _ C _ F L A G S _ R E L E A S E
C M A K E _ C _ F L A G S _ M I N S I Z E R E L
C M A K E _ C _ F L A G S _ R E L W I T H D E B I N F O
)
if ( ${ flag_var } MATCHES "/MD" )
string ( REGEX REPLACE "/MD" "/MT" ${ flag_var } "${${flag_var}}" )
endif ( )
endforeach ( )
endif ( )
endif ( )
2018-10-27 14:58:30 +03:00
# GNUC specific options.
if ( ${ GNUC } )
2013-12-13 17:00:23 +01:00
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 )
2018-10-27 14:58:30 +03:00
list ( APPEND __FLAGS
2019-03-13 00:02:39 +03:00
- W a l l - W e x t r a - W n o - u n u s e d - p a r a m e t e r - W s t r i c t - a l i a s i n g - W s t r i c t - p r o t o t y p e s
2022-07-09 14:22:38 +03:00
- W u n d e f
2018-10-27 14:58:30 +03:00
- f n o - s t r i c t - a l i a s i n g # gcc 2.9.5+
2019-05-25 17:28:53 +03:00
- W m i s s i n g - p r o t o t y p e s
2018-10-27 14:58:30 +03:00
# gcc 4
- W i n i t - s e l f
- W m i s s i n g - f i e l d - i n i t i a l i z e r s
- W d e c l a r a t i o n - a f t e r - s t a t e m e n t
# gcc 4.2
- W a d d r e s s
- W n o r m a l i z e d = i d
- W o v e r r i d e - i n i t
# gcc 4.5
- W l o g i c a l - o p
2019-03-13 00:02:39 +03:00
2019-05-25 17:28:53 +03:00
- W w r i t e - s t r i n g s
2022-07-09 17:08:21 +03:00
2022-11-12 18:56:03 +01:00
# Disable unused-function warnings. These trigger for minheap-internal.h.
- W n o - u n u s e d - f u n c t i o n
2022-11-12 18:56:25 +01:00
- W n o - p r a g m a s
2018-10-27 14:58:30 +03:00
)
2015-12-19 01:47:49 -08:00
2019-03-13 00:02:39 +03:00
if ( ${ CLANG } )
2022-06-23 13:38:14 +01:00
list ( APPEND __FLAGS
2022-11-12 18:56:03 +01:00
# we use this hack in tests
- W n o - v o i d - p o i n t e r - t o - e n u m - c a s t )
2019-03-13 00:02:39 +03:00
endif ( )
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 " )
2023-02-13 16:05:58 +00:00
add_definitions ( -D_FORTIFY_SOURCE=3 )
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 ( )
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 )
2020-07-04 15:55:22 -04:00
# Clang on macOS emits warnings for each directory specified which isn't used
2016-03-10 00:33:04 +03:00
add_compiler_flags (
- 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 ( )
2020-03-20 17:49:37 +08:00
if ( MINGW OR CYGWIN )
set ( WIN32 TRUE )
endif ( )
2013-12-09 18:05:32 +01:00
# Winsock.
if ( WIN32 )
2020-08-29 01:15:20 +03:00
list ( APPEND CMAKE_REQUIRED_LIBRARIES
w s 2 _ 3 2
s h e l l 3 2
a d v a p i 3 2
b c r y p t
)
2020-03-16 20:11:06 +08:00
set ( CMAKE_REQUIRED_DEFINITIONS -FIwinsock2.h -FIws2tcpip.h -D_WIN32_WINNT=0x0600 )
2013-12-09 18:05:32 +01:00
endif ( )
2016-08-10 00:27:59 +03:00
if ( SOLARIS )
2020-08-29 01:15:20 +03:00
list ( APPEND CMAKE_REQUIRED_LIBRARIES
s o c k e t
n s l
)
2016-08-10 00:27:59 +03:00
endif ( )
2013-12-09 18:05:32 +01:00
# Check if _GNU_SOURCE is available.
2018-11-04 19:48:11 +03:00
if ( NOT DEFINED _GNU_SOURCE )
2017-03-06 00:30:21 +03:00
CHECK_SYMBOL_EXISTS ( __GNU_LIBRARY__ "features.h" _GNU_SOURCE )
if ( NOT _GNU_SOURCE )
unset ( _GNU_SOURCE CACHE )
CHECK_SYMBOL_EXISTS ( _GNU_SOURCE "features.h" _GNU_SOURCE )
endif ( )
2019-07-08 14:06:55 -07:00
if ( ANDROID )
set ( _GNU_SOURCE TRUE )
endif ( )
2017-03-06 00:30:21 +03:00
endif ( )
2013-12-09 18:05:32 +01:00
if ( _GNU_SOURCE )
2020-03-20 17:49:37 +08:00
set ( CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE )
endif ( )
# Check if header files exist
list ( APPEND FILES_TO_CHECK
f c n t l . h
i n t t y p e s . h
m e m o r y . h
s i g n a l . h
s t d a r g . h
s t d d e f . h
s t d i n t . h
s t d l i b . h
s t r i n g . h
e r r n o . h
u n i s t d . h
t i m e . h
s y s / t y p e s . h
s y s / s t a t . h
s y s / t i m e . h
s y s / p a r a m . h
)
if ( WIN32 )
list ( APPEND FILES_TO_CHECK
i o . h
w i n s o c k 2 . h
w s 2 t c p i p . h
a f u n i x . h
)
else ( )
list ( APPEND FILES_TO_CHECK
n e t d b . h
d l f c n . h
a r p a / i n e t . h
p o l l . h
p o r t . h
s y s / s o c k e t . h
s y s / r a n d o m . h
s y s / u n . h
s y s / d e v p o l l . h
s y s / e p o l l . h
s y s / e v e n t f d . h
s y s / e v e n t . h
s y s / i o c t l . h
s y s / m m a n . h
s y s / q u e u e . h
s y s / s e l e c t . h
s y s / s e n d f i l e . h
s y s / u i o . h
s y s / w a i t . h
s y s / r e s o u r c e . h
s y s / t i m e r f d . h
2022-10-25 11:30:34 +03:00
s y s / s i g n a l f d . h
2020-03-20 17:49:37 +08:00
n e t i n e t / i n . h
n e t i n e t / i n 6 . h
n e t i n e t / t c p . h
i f a d d r s . h
)
2013-12-09 18:05:32 +01:00
endif ( )
2020-03-20 17:49:37 +08:00
if ( NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux" )
list ( APPEND FILES_TO_CHECK sys/sysctl.h )
2019-05-12 16:12:06 +03:00
endif ( )
2020-03-20 17:49:37 +08:00
if ( APPLE )
list ( APPEND FILES_TO_CHECK
m a c h / m a c h _ t i m e . h
m a c h / m a c h . h
)
2019-05-12 16:12:06 +03:00
endif ( )
2020-08-29 01:15:20 +03:00
if ( NOT EVENT__DISABLE_THREAD_SUPPORT AND NOT WIN32 )
list ( APPEND FILES_TO_CHECK pthread.h )
# (Only `CHECK_TYPE_SIZE()' will use `CMAKE_EXTRA_INCLUDE_FILES')
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES pthread.h )
endif ( )
# Fills EVENT_INCLUDES
2020-03-20 17:49:37 +08:00
foreach ( FILE ${ FILES_TO_CHECK } )
CHECK_INCLUDE_FILE_CONCAT ( ${ FILE } "EVENT" )
endforeach ( )
unset ( FILES_TO_CHECK )
2013-12-09 18:05:32 +01:00
2020-03-20 17:49:37 +08:00
# Check if functions exist
2020-03-16 20:11:06 +08:00
list ( APPEND SYMBOLS_TO_CHECK
g e t a d d r i n f o
g e t n a m e i n f o
g e t p r o t o b y n u m b e r
2020-03-20 17:49:37 +08:00
g e t s e r v b y n a m e
g e t h o s t b y n a m e
2020-03-16 20:11:06 +08:00
i n e t _ n t o p
i n e t _ p t o n
2020-03-20 17:49:37 +08:00
g e t t i m e o f d a y
s i g n a l
2020-03-16 20:11:06 +08:00
s t r t o l l
2020-03-20 17:49:37 +08:00
s t r l c p y
s t r s e p
s t r t o k _ r
2020-03-16 20:11:06 +08:00
t i m e r c l e a r
t i m e r c m p
t i m e r i s s e t
2020-03-20 17:49:37 +08:00
t i m e r a d d
n a n o s l e e p
2020-03-16 20:11:06 +08:00
p u t e n v
2020-03-20 17:49:37 +08:00
u m a s k
2020-03-16 20:11:06 +08:00
)
2020-03-20 17:49:37 +08:00
if ( NOT EVENT__DISABLE_CLOCK_GETTIME )
list ( APPEND SYMBOLS_TO_CHECK clock_gettime )
endif ( )
2013-12-09 18:05:32 +01:00
2020-03-20 17:49:37 +08:00
if ( WIN32 )
list ( APPEND SYMBOLS_TO_CHECK
_ g m t i m e 6 4 _ s
_ g m t i m e 6 4
)
else ( )
list ( APPEND SYMBOLS_TO_CHECK
g e t i f a d d r s
s e l e c t
e p o l l _ c r e a t e
e p o l l _ c r e a t e 1
2022-09-15 14:06:50 +03:00
e p o l l _ p w a i t 2
2020-03-20 17:49:37 +08:00
e p o l l _ c t l
e v e n t f d
p o l l
p o r t _ c r e a t e
k q u e u e
f c n t l
m m a p
p i p e
p i p e 2
2023-01-02 17:06:48 +03:00
p r e a d
2020-03-20 17:49:37 +08:00
s e n d f i l e
s i g a c t i o n
s t r s i g n a l
s y s c t l
a c c e p t 4
a r c 4 r a n d o m
a r c 4 r a n d o m _ b u f
a r c 4 r a n d o m _ a d d r a n d o m
g e t r a n d o m
g e t e g i d
g e t e u i d
i s s e t u g i d
u s l e e p
t i m e r f d _ c r e a t e
s e t e n v
u n s e t e n v
s e t r l i m i t
g e t h o s t b y n a m e _ r
2022-08-07 13:51:48 +03:00
m m a p 6 4
2020-03-20 17:49:37 +08:00
)
if ( APPLE )
list ( APPEND SYMBOLS_TO_CHECK mach_absolute_time )
endif ( )
endif ( )
2013-12-09 18:05:32 +01:00
2023-01-28 13:28:52 +01:00
set ( PTHREADS_AVAILABLE OFF )
2020-08-29 01:15:20 +03:00
if ( NOT EVENT__DISABLE_THREAD_SUPPORT )
if ( WIN32 )
list ( APPEND SRC_CORE evthread_win32.c )
2022-10-03 09:31:10 -05:00
elseif ( ANDROID )
# pthreads is built in to bionic
set ( EVENT__HAVE_PTHREADS 1 )
CHECK_TYPE_SIZE ( pthread_t EVENT__SIZEOF_PTHREAD_T )
list ( APPEND SYMBOLS_TO_CHECK pthread_mutexattr_setprotocol )
2023-01-28 13:28:52 +01:00
set ( PTHREADS_AVAILABLE ON )
2020-08-29 01:15:20 +03:00
else ( )
find_package ( Threads REQUIRED )
if ( NOT CMAKE_USE_PTHREADS_INIT )
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 " )
endif ( )
2023-01-28 13:28:52 +01:00
set ( PTHREADS_AVAILABLE ON )
2020-08-29 01:15:20 +03:00
set ( EVENT__HAVE_PTHREADS 1 )
list ( APPEND LIB_APPS ${ CMAKE_THREAD_LIBS_INIT } )
# for CHECK_SYMBOLS_EXIST()
list ( APPEND CMAKE_REQUIRED_LIBRARIES ${ CMAKE_THREAD_LIBS_INIT } )
CHECK_TYPE_SIZE ( pthread_t EVENT__SIZEOF_PTHREAD_T )
list ( APPEND SYMBOLS_TO_CHECK pthread_mutexattr_setprotocol )
endif ( )
endif ( )
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES ${ EVENT_INCLUDES } stdio.h )
CHECK_SYMBOLS_EXIST ( "${SYMBOLS_TO_CHECK}" "${CMAKE_EXTRA_INCLUDE_FILES}" "EVENT" )
2020-03-20 17:49:37 +08:00
unset ( SYMBOLS_TO_CHECK )
set ( EVENT__HAVE_EPOLL ${ EVENT__HAVE_EPOLL_CREATE } )
2022-10-25 11:30:34 +03:00
set ( EVENT__HAVE_SIGNALFD ${ EVENT__HAVE_SYS_SIGNALFD_H } )
2020-04-22 19:44:45 -07:00
if ( WIN32 AND NOT CYGWIN )
set ( EVENT__HAVE_WEPOLL 1 )
endif ( )
2013-12-09 18:05:32 +01:00
2020-03-20 17:49:37 +08:00
# Get the gethostbyname_r prototype.
2013-12-09 18:05:32 +01:00
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 ( )
2020-03-20 17:49:37 +08:00
CHECK_TYPE_SIZE ( "struct sockaddr_un" EVENT__HAVE_STRUCT_SOCKADDR_UN )
2013-12-09 18:05:32 +01:00
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 )
2018-06-19 10:15:08 +03: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 ( )
2018-06-19 10:15:08 +03:00
# __func__/__FUNCTION__ is not a macros in general
CHECK_SYMBOL_EXISTS ( "__func__" "" EVENT__HAVE___func__ )
CHECK_SYMBOL_EXISTS ( "__FUNCTION__" "" EVENT__HAVE___FUNCTION__ )
2013-12-09 18:05:32 +01:00
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 )
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
2017-12-16 23:28:41 +03:00
CHECK_TYPE_SIZE ( size_t EVENT__SIZEOF_SIZE_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 ( )
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 )
set ( EVENT__SIZEOF_PID_T ${ EVENT__SIZEOF_INT } )
2015-12-20 21:44:04 -08:00
else ( )
set ( EVENT__SIZEOF_PID_T EVENT__SIZEOF_PID_T )
2013-12-09 18:05:32 +01:00
endif ( )
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 )
2017-09-01 15:50:36 -07:00
CHECK_TYPE_SIZE ( "time_t" EVENT__SIZEOF_TIME_T )
2013-12-09 18:05:32 +01:00
# 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()
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 )
2019-07-02 10:47:47 -07:00
if ( ( CMAKE_CROSSCOMPILING OR APPLE ) AND NOT EVENT__FORCE_KQUEUE_CHECK )
2013-12-17 14:01:21 +01:00
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
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
2022-09-11 22:08:32 +02:00
o p e n s s l - c o m p a t . h
2013-12-09 18:05:32 +01:00
e v c o n f i g - p r i v a t e . h
2022-09-12 22:16:56 +03:00
s h a 1 . 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
2019-03-26 13:33:57 -04:00
i n c l u d e / e v e n t 2 / w a t c h . h
2013-12-09 18:05:32 +01:00
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
2022-09-12 22:16:56 +03:00
i n c l u d e / e v e n t 2 / w s . 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
2020-09-01 01:08:16 +03:00
list ( APPEND 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
2019-03-26 13:33:57 -04:00
w a t c h . 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 )
2017-03-08 23:15:33 +03:00
list ( APPEND SRC_CORE epoll.c )
2013-12-09 18:05:32 +01:00
endif ( )
2022-10-25 11:30:34 +03:00
if ( EVENT__HAVE_SIGNALFD )
list ( APPEND SRC_CORE signalfd.c )
endif ( )
2020-04-22 19:44:45 -07:00
if ( EVENT__HAVE_WEPOLL )
list ( APPEND SRC_CORE
e p o l l . c
w e p o l l . c )
endif ( )
2013-12-09 18:05:32 +01:00
if ( EVENT__HAVE_EVENT_PORTS )
list ( APPEND SRC_CORE evport.c )
endif ( )
if ( NOT EVENT__DISABLE_OPENSSL )
2020-11-01 01:39:02 +03:00
# only if OPENSSL_ROOT_DIR is not set yet
if ( BREW AND NOT OPENSSL_ROOT_DIR AND NOT "$ENV{OPENSSL_ROOT_DIR}" )
execute_process ( COMMAND ${ BREW } --prefix openssl
O U T P U T _ V A R I A B L E B R E W _ O P E N S S L _ P R E F I X
R E S U L T _ V A R I A B L E B R E W _ O P E N S S L _ R E S U L T
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
if ( BREW_OPENSSL_RESULT EQUAL 0 )
message ( STATUS "Set OPENSSL_ROOT_DIR=${BREW_OPENSSL_PREFIX} (from brew)" )
set ( OPENSSL_ROOT_DIR "${BREW_OPENSSL_PREFIX}" CACHE PATH "" )
endif ( )
endif ( )
2013-12-09 18:05:32 +01:00
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
2020-07-07 17:26:46 +08:00
list ( APPEND SRC_OPENSSL bufferevent_openssl.c bufferevent_ssl.c )
2013-12-12 16:33:20 +01:00
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 ( )
2020-01-14 12:18:27 +08:00
if ( NOT EVENT__DISABLE_MBEDTLS )
2023-03-05 23:58:22 +08:00
# only if MBEDTLS_ROOT_DIR is not set yet
if ( BREW AND NOT MBEDTLS_ROOT_DIR AND NOT "$ENV{MBEDTLS_ROOT_DIR}" )
execute_process ( COMMAND ${ BREW } --prefix mbedtls
O U T P U T _ V A R I A B L E B R E W _ M B E D T L S _ P R E F I X
R E S U L T _ V A R I A B L E B R E W _ M B E D T L S _ R E S U L T
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
if ( BREW_MBEDTLS_RESULT EQUAL 0 )
message ( STATUS "Set MBEDTLS_ROOT_DIR=${BREW_MBEDTLS_PREFIX} (from brew)" )
set ( MBEDTLS_ROOT_DIR "${BREW_MBEDTLS_PREFIX}" CACHE PATH "" )
endif ( )
endif ( )
2020-01-14 12:18:27 +08:00
find_package ( MbedTLS REQUIRED )
set ( EVENT__HAVE_MBEDTLS 1 )
message ( STATUS "mbed TLS include: ${MBEDTLS_INCLUDE_DIR}" )
message ( STATUS "mbed TLS lib: ${MBEDTLS_LIBRARIES}" )
include_directories ( ${ MBEDTLS_INCLUDE_DIR } )
2020-07-07 17:26:46 +08:00
list ( APPEND SRC_MBEDTLS bufferevent_mbedtls.c bufferevent_ssl.c )
2020-01-14 12:18:27 +08:00
list ( APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h )
list ( APPEND LIB_APPS ${ MBEDTLS_LIBRARIES } )
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
2022-09-12 22:16:56 +03:00
w s . c
s h a 1 . c
2015-12-20 00:43:46 -08:00
e v r p c . c )
2013-12-09 18:05:32 +01:00
2022-09-26 11:54:14 +03:00
if ( "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 3.20 )
include ( TestBigEndian )
TEST_BIG_ENDIAN ( IS_BIG_ENDIAN )
if ( IS_BIG_ENDIAN )
set ( CMAKE_C_BYTE_ORDER BIG_ENDIAN )
else ( )
set ( CMAKE_C_BYTE_ORDER LITTLE_ENDIAN )
endif ( )
endif ( )
2022-09-12 22:16:56 +03:00
set_source_files_properties ( sha1.c PROPERTIES COMPILE_FLAGS
- D $ { C M A K E _ C _ B Y T E _ O R D E R } = 1 )
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 )
2020-08-01 16:10:48 +01:00
set ( LIB_PLATFORM ws2_32 shell32 advapi32 bcrypt )
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 ( )
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
2018-10-27 14:58:30 +03:00
if ( ${ GNUC } )
2017-03-12 23:31:59 +03:00
set ( EVENT_SHARED_FLAGS -fvisibility=hidden )
elseif ( "${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro" )
set ( EVENT_SHARED_FLAGS -xldscope=hidden )
endif ( )
2014-02-19 06:31:27 +01:00
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.
#
2017-03-12 23:31:59 +03:00
include ( AddEventLibrary )
add_event_library ( event_core SOURCES ${ SRC_CORE } )
2017-03-13 15:49:11 +03:00
add_event_library ( event_extra
2019-11-07 18:26:47 +08:00
I N N E R _ L I B R A R I E S e v e n t _ c o r e
2017-03-13 15:49:11 +03:00
S O U R C E S $ { S R C _ E X T R A } )
2016-11-07 00:46:45 +03:00
if ( NOT EVENT__DISABLE_OPENSSL )
2017-03-12 23:31:59 +03:00
add_event_library ( event_openssl
2019-11-07 18:26:47 +08:00
I N N E R _ L I B R A R I E S e v e n t _ c o r e
O U T E R _ I N C L U D E S $ { O P E N S S L _ I N C L U D E _ D I R }
L I B R A R I E S $ { O P E N S S L _ L I B R A R I E S }
2017-03-12 23:31:59 +03:00
S O U R C E S $ { S R C _ O P E N S S L } )
2016-11-07 00:46:45 +03:00
endif ( )
2020-01-14 12:18:27 +08:00
if ( NOT EVENT__DISABLE_MBEDTLS )
add_event_library ( event_mbedtls
2020-05-28 17:14:46 +08:00
I N N E R _ L I B R A R I E S e v e n t _ c o r e
O U T E R _ I N C L U D E S $ { M B E D T L S _ I N C L U D E _ D I R }
L I B R A R I E S $ { M B E D T L S _ L I B R A R I E S }
2020-01-14 12:18:27 +08:00
S O U R C E S $ { S R C _ M B E D T L S } )
endif ( )
2020-06-18 15:47:14 +00:00
if ( EVENT__HAVE_PTHREADS )
2016-11-07 00:46:45 +03:00
set ( SRC_PTHREADS evthread_pthread.c )
2017-03-13 15:49:11 +03:00
add_event_library ( event_pthreads
2019-11-07 18:26:47 +08:00
I N N E R _ L I B R A R I E S e v e n t _ c o r e
2017-03-13 15:49:11 +03:00
S O U R C E S $ { S R C _ P T H R E A D S } )
2016-11-07 00:46:45 +03:00
endif ( )
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.
2017-03-12 23:31:59 +03:00
add_event_library ( event SOURCES ${ SRC_CORE } ${ SRC_EXTRA } )
2014-02-19 06:31:27 +01:00
2017-05-29 16:32:30 +03:00
set ( WIN32_GETOPT )
if ( WIN32 )
2019-10-29 15:48:53 +01:00
set ( _TMPLIBS )
if ( ${ EVENT_LIBRARY_STATIC } )
list ( APPEND _TMPLIBS event_core_static event_static )
endif ( )
if ( ${ EVENT_LIBRARY_SHARED } )
list ( APPEND _TMPLIBS event_core_shared event_shared )
endif ( )
foreach ( lib ${ _TMPLIBS } )
target_link_libraries ( ${ lib } iphlpapi )
endforeach ( )
unset ( _TMPLIBS )
2017-05-29 16:32:30 +03:00
list ( APPEND WIN32_GETOPT
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 ( )
2014-01-09 13:44:38 +01:00
#
# Samples.
#
2016-11-07 00:46:45 +03:00
macro ( add_sample_prog ssl name )
2017-03-12 23:31:59 +03:00
add_executable ( ${ name } ${ ARGN } )
target_link_libraries ( ${ name }
2018-11-22 23:00:11 +03:00
e v e n t _ e x t r a
e v e n t _ c o r e
2017-03-12 23:31:59 +03:00
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M } )
2020-05-28 17:14:46 +08:00
if ( TARGET ${ ssl } )
target_link_libraries ( ${ name } ${ ssl } )
2019-09-15 21:45:26 +08:00
if ( WIN32 )
target_link_libraries ( ${ name } crypt32 )
endif ( )
2017-03-12 23:31:59 +03:00
endif ( )
2016-11-07 00:46:45 +03:00
endmacro ( )
2013-12-12 16:33:20 +01:00
if ( NOT EVENT__DISABLE_SAMPLES )
2013-12-13 17:00:23 +01:00
set ( SAMPLES
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
2015-08-18 12:18:31 +03:00
h t t p - c o n n e c t
2019-03-26 13:33:57 -04:00
t i m e - t e s t
w a t c h - t i m i n g )
2013-12-13 17:00:23 +01:00
foreach ( SAMPLE ${ SAMPLES } )
2016-11-07 00:46:45 +03:00
add_sample_prog ( OFF ${ SAMPLE } sample/ ${ SAMPLE } .c )
2013-12-13 17:00:23 +01:00
endforeach ( )
2019-03-26 13:33:57 -04:00
if ( NOT WIN32 )
target_link_libraries ( watch-timing m )
endif ( )
2016-01-12 01:57:07 +03:00
2016-11-07 00:46:45 +03:00
if ( NOT EVENT__DISABLE_OPENSSL )
2020-05-28 17:14:46 +08:00
add_sample_prog ( event_openssl https-client
2016-11-07 00:46:45 +03:00
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 )
2020-05-28 17:14:46 +08:00
add_sample_prog ( event_openssl le-proxy
2016-11-07 00:46:45 +03:00
s a m p l e / l e - p r o x y . c )
2020-05-28 17:14:46 +08:00
add_sample_prog ( event_openssl becat sample/becat.c ${ WIN32_GETOPT } )
endif ( )
if ( NOT EVENT__DISABLE_MBEDTLS )
2020-09-16 11:31:33 +08:00
add_sample_prog ( event_mbedtls https-client-mbedtls
s a m p l e / h t t p s - c l i e n t . c )
target_compile_definitions ( https-client-mbedtls PRIVATE USE_MBEDTLS )
2020-05-28 17:14:46 +08:00
add_sample_prog ( event_mbedtls ssl-client-mbedtls
s a m p l e / s s l - c l i e n t - m b e d t l s . c )
2016-11-07 00:46:45 +03:00
endif ( )
2018-11-13 10:48:41 +03:00
set ( SAMPLES_WOPT
d n s - e x a m p l e
2022-09-12 22:16:56 +03:00
w s - c h a t - s e r v e r
2018-11-13 10:48:41 +03:00
h t t p - s e r v e r
)
foreach ( SAMPLE ${ SAMPLES_WOPT } )
add_sample_prog ( OFF ${ SAMPLE } sample/ ${ SAMPLE } .c ${ WIN32_GETOPT } )
endforeach ( )
2013-12-12 16:33:20 +01:00
endif ( )
2013-12-09 18:05:32 +01:00
2016-11-07 00:46:45 +03:00
#
# Benchmarks
#
macro ( add_bench_prog prog )
2017-05-29 16:36:24 +03:00
add_executable ( ${ prog } ${ ARGN } )
target_link_libraries ( ${ prog }
2018-11-22 23:00:11 +03:00
e v e n t _ e x t r a
e v e n t _ c o r e
2016-11-07 00:46:45 +03:00
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M } )
endmacro ( )
2013-12-09 18:05:32 +01:00
if ( NOT EVENT__DISABLE_BENCHMARK )
2017-05-29 16:36:24 +03:00
foreach ( BENCHMARK bench_http bench_httpclient )
add_bench_prog ( ${ BENCHMARK } test/ ${ BENCHMARK } .c )
2013-12-12 16:33:20 +01:00
endforeach ( )
2017-05-29 16:36:24 +03:00
add_bench_prog ( bench test/bench.c ${ WIN32_GETOPT } )
add_bench_prog ( bench_cascade test/bench_cascade.c ${ WIN32_GETOPT } )
2013-12-09 18:05:32 +01:00
endif ( )
2016-11-07 00:46:45 +03:00
#
# Tests
#
macro ( add_test_prog prog )
add_executable ( ${ prog } test/ ${ prog } .c )
target_link_libraries ( ${ prog }
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M }
2018-11-22 23:00:11 +03:00
e v e n t _ c o r e
e v e n t _ e x t r a
2016-11-07 00:46:45 +03:00
$ { A R G N } )
endmacro ( )
2013-12-09 18:05:32 +01:00
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 )
2017-09-14 17:39:20 -05:00
# (We require python to generate the regress tests)
find_package ( PythonInterp 3 )
2015-12-20 00:43:46 -08:00
2017-09-14 17:39:20 -05:00
if ( PYTHONINTERP_FOUND )
2014-09-02 18:25:52 +04:00
set ( __FOUND_USABLE_PYTHON 1 )
2017-09-14 17:39:20 -05:00
else ( )
find_package ( PythonInterp 2 )
if ( PYTHONINTERP_FOUND )
set ( __FOUND_USABLE_PYTHON 1 )
else ( )
message ( ERROR "No suitable Python version found, bailing..." )
endif ( )
2014-09-02 18:25:52 +04:00
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
2020-05-05 14:20:09 +03:00
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 - - q u i e t 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
2016-11-07 00:46:45 +03: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
t e s t / r e g r e s s _ h t t p . c
2022-09-12 22:16:56 +03:00
t e s t / r e g r e s s _ h t t p . h
2016-11-07 00:46:45 +03:00
t e s t / r e g r e s s _ l i s t e n e r . c
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
t e s t / r e g r e s s _ u t i l . c
2019-03-26 13:33:57 -04:00
t e s t / r e g r e s s _ w a t c h . c
2022-09-12 22:16:56 +03:00
t e s t / r e g r e s s _ w s . c
t e s t / r e g r e s s _ w s . h
2016-11-07 00:46:45 +03:00
t e s t / t i n y t e s t . c )
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 ( )
2020-06-18 15:47:14 +00:00
elseif ( EVENT__HAVE_PTHREADS )
2014-01-22 00:06:21 +01:00
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 ( )
2016-11-07 00:46:45 +03:00
if ( NOT EVENT__DISABLE_OPENSSL )
2020-05-28 17:14:46 +08:00
list ( APPEND SRC_REGRESS test/regress_openssl.c )
endif ( )
if ( NOT EVENT__DISABLE_MBEDTLS )
list ( APPEND SRC_REGRESS test/regress_mbedtls.c )
2014-01-22 00:06:21 +01:00
endif ( )
add_executable ( regress ${ SRC_REGRESS } )
2015-12-20 00:43:46 -08:00
target_link_libraries ( regress
2016-11-07 00:46:45 +03:00
$ { L I B _ A P P S }
$ { L I B _ P L A T F O R M }
2018-11-22 23:00:11 +03:00
e v e n t _ c o r e
e v e n t _ e x t r a )
2017-03-12 23:31:59 +03:00
if ( NOT EVENT__DISABLE_OPENSSL )
2018-11-22 23:00:11 +03:00
target_link_libraries ( regress event_openssl )
2017-03-12 23:31:59 +03:00
endif ( )
2020-05-28 17:14:46 +08:00
if ( NOT EVENT__DISABLE_MBEDTLS )
target_link_libraries ( regress event_mbedtls )
endif ( )
2023-01-28 13:28:52 +01:00
if ( PTHREADS_AVAILABLE )
2018-11-22 23:00:11 +03:00
target_link_libraries ( regress event_pthreads )
2017-03-12 23:31:59 +03:00
endif ( )
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.
#
2016-11-07 00:46:45 +03: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
set ( TESTPROGS test-changelist
t e s t - e o f
2020-04-08 00:29:40 +03:00
t e s t - c l o s e d
2016-11-07 00:46:45 +03:00
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 )
foreach ( TESTPROG ${ TESTPROGS } test-dumpevents )
add_test_prog ( ${ TESTPROG } )
endforeach ( )
if ( UNIX )
add_test_prog ( test-ratelim m )
else ( )
add_test_prog ( test-ratelim )
endif ( )
2013-12-12 18:21:11 +01:00
2015-12-20 00:43:46 -08:00
set ( ALL_TESTPROGS
2016-11-07 00:46:45 +03:00
$ { 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-12 18:21:11 +01:00
#
# 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 ( )
2020-04-22 19:44:45 -07:00
if ( EVENT__HAVE_WEPOLL )
list ( APPEND BACKENDS WEPOLL )
endif ( )
2013-12-16 16:37:51 +01:00
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.
2020-01-13 22:24:54 +03:00
set ( DEFAULT_TEST_ENV_VARS )
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 }
2016-11-07 00:46:45 +03:00
$ { 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 } )
2015-12-20 00:43:46 -08:00
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 }
2016-11-07 00:46:45 +03:00
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 }
2016-11-07 00:46:45 +03:00
$ { 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 )
2015-12-20 00:43:46 -08:00
set_tests_properties ( ${ TEST_NAME }
2016-11-07 00:46:45 +03:00
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 }
2016-11-07 00:46:45 +03:00
$ { 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 )
2015-12-20 00:43:46 -08:00
set_tests_properties ( ${ TEST_NAME }
2016-11-07 00:46:45 +03:00
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 }
2020-01-13 22:24:54 +03:00
$ { 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 - - q u i e t )
2015-12-20 00:43:46 -08:00
set_tests_properties ( ${ TEST_NAME }
2016-11-07 00:46:45 +03:00
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 } " )
2015-12-20 00:43:46 -08:00
add_test ( ${ TEST_NAME } _debug
2020-01-13 22:24:54 +03:00
$ { 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 - - q u i e t )
2015-12-20 00:43:46 -08:00
set_tests_properties ( ${ TEST_NAME } _debug
2016-11-07 00:46:45 +03:00
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.
2016-11-07 00:46:45 +03:00
set ( RL_BIN ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } /test-ratelim )
2015-12-20 00:43:46 -08:00
add_test ( test-ratelim__group_lim
2016-11-07 00:46:45 +03:00
$ { 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
2016-11-07 00:46:45 +03:00
$ { 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
2016-11-07 00:46:45 +03:00
$ { 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
2016-11-07 00:46:45 +03:00
$ { 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.
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 =
2020-04-22 19:44:45 -07:00
s e t E V E N T _ N O W E P O L L =
2014-01-22 12:12:51 +01:00
\ " $ { 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
2016-11-07 00:46:45 +03:00
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 )
2015-12-20 00:43:46 -08:00
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}"
2016-11-07 00:46:45 +03: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 } )
2013-12-16 18:10:32 +01:00
else ( )
2020-04-22 19:44:45 -07:00
# On some platforms doing exec(unset) as CMake doesn't work, so make sure
2013-12-19 10:54:52 +01:00
# 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
2016-11-07 00:46:45 +03:00
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 )
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
2016-11-07 00:46:45 +03:00
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.
#
2017-03-13 03:18:02 +03:00
set ( EVENT_INSTALL_CMAKE_DIR
2019-11-07 18:26:47 +08:00
" $ { C M A K E _ I N S T A L L _ P R E F I X } / l i b / c m a k e / l i b e v e n t " )
2014-01-09 13:44:38 +01:00
export ( PACKAGE libevent )
2019-11-07 18:26:47 +08:00
function ( gen_package_config forinstall )
if ( ${ forinstall } )
set ( CONFIG_FOR_INSTALL_TREE 1 )
set ( dir "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" )
else ( )
set ( CONFIG_FOR_INSTALL_TREE 0 )
set ( dir "${PROJECT_BINARY_DIR}" )
endif ( )
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/LibeventConfig.cmake.in
" $ { d i r } / L i b e v e n t C o n f i g . c m a k e "
@ O N L Y )
endfunction ( )
2014-01-09 13:44:38 +01:00
# 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 " )
2019-11-07 18:26:47 +08:00
gen_package_config ( 0 )
2014-01-09 13:44:38 +01:00
# Generate the config file for the installation tree.
2019-11-07 18:26:47 +08:00
gen_package_config ( 1 )
2014-01-09 13:44:38 +01:00
# Generate version info for both build-tree and install-tree.
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/LibeventConfigVersion.cmake.in
2017-03-13 03:18:02 +03: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
@ O N L Y )
2014-01-09 13:44:38 +01:00
2014-09-02 18:25:52 +04:00
# Install compat headers
install ( FILES ${ HDR_COMPAT }
2017-03-13 03:18:02 +03:00
D E S T I N A T I O N " i n c l u d e "
2016-11-07 00:46:45 +03:00
C O M P O N E N T d e v )
2014-01-09 13:44:38 +01:00
2019-10-25 21:54:13 +08:00
# Install public headers
install ( FILES ${ HDR_PUBLIC }
D E S T I N A T I O N " i n c l u d e / e v e n t 2 "
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
2016-11-07 00:46:45 +03: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
$ { 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
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 } "
2015-12-20 00:43:46 -08:00
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.
2019-11-07 18:26:47 +08:00
macro ( install_export type )
install ( EXPORT LibeventTargets- ${ type }
N A M E S P A C E $ { P R O J E C T _ N A 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 _ C M A K E _ D I R } "
2016-11-07 00:46:45 +03:00
C O M P O N E N T d e v )
2019-11-07 18:26:47 +08:00
endmacro ( )
if ( ${ EVENT_LIBRARY_STATIC } )
install_export ( static )
endif ( )
if ( ${ EVENT_LIBRARY_SHARED } )
install_export ( shared )
endif ( )
2015-12-19 01:47:49 -08:00
2019-06-09 20:15:37 +08:00
# Install the scripts.
install ( PROGRAMS
$ { 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 _ r p c g e n . p y
D E S T I N A T I O N " b i n "
C O M P O N E N T r u n t i m e )
# Create documents with doxygen.
2019-08-23 21:48:05 +08:00
option ( EVENT__DOXYGEN
" E n a b l e s d o x y g e n d o c u m e n t a t i o n " O F F )
if ( EVENT__DOXYGEN )
include ( UseDoxygen )
UseDoxygen ( )
2019-06-09 20:15:37 +08:00
endif ( )
2020-01-08 20:37:16 +02:00
if ( NOT TARGET uninstall )
# Create the uninstall target.
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
configure_file ( ${ PROJECT_SOURCE_DIR } /cmake/Uninstall.cmake.in
$ { P R O J E C T _ B I N A R Y _ D I R } / U n i n s t a l l . c m a k e
@ O N L Y )
2019-06-09 20:15:37 +08:00
2020-01-08 20:37:16 +02:00
add_custom_target ( uninstall
C O M M A N D $ { C M A K E _ C O M M A N D } - P $ { P R O J E C T _ B I N A R Y _ D I R } / U n i n s t a l l . c m a k e )
endif ( )
2019-06-09 20:15:37 +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}" )
2018-10-27 14:58:30 +03:00
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}" )
2022-03-10 23:11:14 +03:00
message ( STATUS "CMAKE_SKIP_INSTALL_RPATH: ${CMAKE_SKIP_INSTALL_RPATH}" )
2022-01-15 22:06:58 +03:00
message ( STATUS "CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}" )
2018-10-27 14:58:30 +03:00
message ( STATUS "CMAKE_VERBOSE_MAKEFILE: ${CMAKE_VERBOSE_MAKEFILE}" )
message ( STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}" )
message ( STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
2022-07-09 15:45:34 +03:00
message ( STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER} (id ${CMAKE_C_COMPILER_ID}, clang ${CLANG}, GNUC ${GNUC}, version ${CMAKE_C_COMPILER_VERSION})" )
2018-10-27 14:58:30 +03:00
message ( STATUS "CMAKE_AR: ${CMAKE_AR}" )
message ( STATUS "CMAKE_RANLIB: ${CMAKE_RANLIB}" )
2022-01-15 22:06:58 +03:00
message ( STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}" )
2016-08-07 23:07:44 +03:00
message ( STATUS "" )
2015-12-20 00:43:46 -08:00