set(EVENT_VERSION "2.1.4-beta")
set(EVENT_PACKAGE_VERSION "")
-option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" 0)
-option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" 0)
-option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" 0)
-option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" 0)
-option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" 0)
-option(EVENT__DISABLE_TESTS "If tests should be compiled or not" 0)
-option(EVENT__DISABLE_REGRESS "Disable the regress tests" 0)
+option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" OFF)
+option(EVENT__ENABLE_VERBOSE_DEBUG "Enables verbose debugging" OFF)
+option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" OFF)
+option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" OFF)
+option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" OFF)
+option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" OFF)
+option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF)
+option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF)
+# TODO: Add --enable-verbose-debug, verbose debug logging
+# TODO: Add --disable-largefile omit support for large files
# Put the libaries and binaries that get built into directories at the
# top of the build tree rather than in hard-to-find leaf directories.
include(FindZLIB) # -> HAVE_LIBZ
+if (CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+
+ option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF)
+ if (EVENT__DISABLE_GCC_WARNINGS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
+ endif()
+
+ option(EVENT__ENABLE_GCC_HARDENING "Enable compiler security checks" OFF)
+ if (EVENT__ENABLE_GCC_HARDENING)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIE -Wstack-protector --param ssp-buffer-size=1")
+ endif()
+
+ option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF)
+ if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections")
+ # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works.
+ endif()
+
+ # We need to test for at least gcc 2.95 here, because older versions don't
+ # have -fno-strict-aliasing
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ if (GCC_VERSION VERSION_GREATER 2.95)
+ message(STATUS "GCC Version >= 2.95 enabling no-strict-aliasing")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
+ endif()
+endif()
+
# Winsock.
if(WIN32)
set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h)
include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND SRC_CORE bufferevent_openssl.c)
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
- list(APPEND LIB_REGRESS ${OPENSSL_LIBRARIES})
+ list(APPEND LIB_APPS ${OPENSSL_LIBRARIES})
endif()
if (NOT EVENT__DISABLE_THREAD_SUPPORT)
endif()
set(EVENT__HAVE_PTHREADS 1)
list(APPEND SRC_CORE evthread_pthread.c)
- list(APPEND LIB_REGRESS ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
set(EVENT__HAVE_ZLIB 1)
set(EVENT__HAVE_ZLIB_H)
include_directories(${ZLIB_INCLUDE_DIRS})
- list(APPEND LIB_REGRESS ${ZLIB_LIBRARIES})
+ list(APPEND LIB_APPS ${ZLIB_LIBRARIES})
endif()
set(SRC_EXTRA
)
if (NOT EVENT__DISABLE_SAMPLES)
- # TODO: Add samples.
+ set(SAMPLES
+ dns-example
+ event-read-fifo
+ hello-world
+ le-proxy
+ signal-test
+ http-server
+ time-test)
+
+ if (OPENSSL_LIBRARIES)
+ # Special sample with more than one file.
+ add_executable(https-client
+ sample/https-client.c
+ sample/openssl_hostname_validation.c
+ sample/hostcheck.c)
+ target_link_libraries(https-client event ${LIB_APPS} ${LIB_PLATFORM})
+ endif()
+
+ foreach(SAMPLE ${SAMPLES})
+ add_executable(${SAMPLE} sample/${SAMPLE}.c)
+ target_link_libraries(${SAMPLE} event ${LIB_APPS} ${LIB_PLATFORM})
+ endforeach()
endif()
if (NOT EVENT__DISABLE_BENCHMARK)
endif()
add_executable(regress ${SRC_REGRESS})
- target_link_libraries(regress event ${LIB_REGRESS} ${LIB_PLATFORM})
+ target_link_libraries(regress event ${LIB_APPS} ${LIB_PLATFORM})
else()
message(WARNING "Python not found, cannot generate regress tests!")
endif()
foreach(BACKEND ${BACKENDS})
# Enable this backend only.
set(BACKEND_ENV_VARS ${DEFAULT_TEST_ENV_VARS})
- list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND})
+ list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND}=1)
# Epoll has some extra settings.
if (${BACKEND} STREQUAL "EPOLL")
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
+
+#define snprintf _snprintf
+#define strcasecmp _stricmp
#else
#include <sys/socket.h>
#include <netinet/in.h>
if (argc != 2)
syntax();
+#ifdef WIN32
+ {
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ wVersionRequested = MAKEWORD(2, 2);
+
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ printf("WSAStartup failed with error: %d\n", err);
+ return 1;
+ }
+ }
+#endif
+
url = argv[1];
http_uri = evhttp_uri_parse(url);
if (http_uri == NULL) {
if (!ssl_ctx)
die_openssl("SSL_CTX_new");
+ #ifndef WIN32
+ /* TODO: Add certificate loading on Windows as well */
+
/* Attempt to use the system's trusted root certificates.
* (This path is only valid for Debian-based systems.) */
if (1 != SSL_CTX_load_verify_locations(ssl_ctx,
* "wrapping" OpenSSL's routine, not replacing it. */
SSL_CTX_set_cert_verify_callback (ssl_ctx, cert_verify_callback,
(void *) host);
+ #endif // not WIN32
// Create event base
base = event_base_new();
evhttp_connection_free(evcon);
event_base_free(base);
+#ifdef WIN32
+ WSACleanup();
+#endif
+
return 0;
}