Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/110'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Mar 3, 2014
2 parents cbfa8da + 4545fa9 commit 8896a92
Show file tree
Hide file tree
Showing 17 changed files with 562 additions and 26 deletions.
100 changes: 79 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Additional changes:
# Brodie Thiesfield
# Joakim Soderberg
# Trond Norbye
#
# Build example:
#
Expand All @@ -27,9 +28,16 @@ set(EVENT_VERSION_MAJOR 2)
set(EVENT_VERSION_MINOR 1)
set(EVENT_VERSION_PATCH 4)
set(EVENT_NUMERIC_VERSION 0x02010401)

set(EVENT_ABI_MAJOR 2)
set(EVENT_ABI_MINOR 1)
set(EVENT_ABI_PATCH 4)
set(EVENT_ABI_LIBVERSION "${EVENT_ABI_MAJOR}.${EVENT_ABI_MINOR}.${EVENT_ABI_PATCH}")

set(EVENT_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-beta")
set(EVENT_PACKAGE_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}")

option(EVENT__BUILD_SHARED_LIBRARIES "Define if libevent should be built with shared libraries instead of archives" OFF)
option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" OFF)
option(EVENT__ENABLE_VERBOSE_DEBUG "Enables verbose debugging" OFF)
option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" OFF)
Expand Down Expand Up @@ -652,8 +660,24 @@ source_group("Source Extra" FILES ${SRC_EXTRA})
# (Place them in the build dir so we don't polute the source tree with generated files).
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include)

if (EVENT__BUILD_SHARED_LIBRARIES)
set(EVENT__LIBRARY_TYPE SHARED)

if (CMAKE_COMPILER_IS_GNUC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xldscope=hidden")
endif ()
set(EVENT__NEED_DLLIMPORT 1)

else (EVENT__BUILD_SHARED_LIBRARIES)
set(EVENT__LIBRARY_TYPE STATIC)
endif (EVENT__BUILD_SHARED_LIBRARIES)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake
${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/event2/event-config.h)

configure_file(
Expand All @@ -665,23 +689,48 @@ configure_file(
#

# TODO: Add dynamic versions of the libraries as well.
add_library(event_core STATIC
add_library(event_core ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
${HDR_PUBLIC}
${SRC_CORE}
)

add_library(event_extras STATIC

add_library(event_extra ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
${HDR_PUBLIC}
${SRC_CORE}
${SRC_EXTRA}
)

add_library(event STATIC
# 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.
add_library(event ${EVENT__LIBRARY_TYPE}
${HDR_PRIVATE}
${HDR_PUBLIC}
${SRC_CORE}
${SRC_EXTRA}
)

if (EVENT__BUILD_SHARED_LIBRARIES)
target_link_libraries(event_core ${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LIB_PLATFORM})

target_link_libraries(event ${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LIB_PLATFORM})

target_link_libraries(event_extra ${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LIB_PLATFORM})

set_target_properties(event PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION})
set_target_properties(event_core PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION})
set_target_properties(event_extra PROPERTIES SOVERSION ${EVENT_ABI_LIBVERSION})

endif (EVENT__BUILD_SHARED_LIBRARIES)

#
# Samples.
#
Expand All @@ -701,31 +750,31 @@ if (NOT EVENT__DISABLE_SAMPLES)
sample/https-client.c
sample/openssl_hostname_validation.c
sample/hostcheck.c)
target_link_libraries(https-client event ${LIB_APPS} ${LIB_PLATFORM})
add_dependencies(https-client event)
target_link_libraries(https-client event_extra ${LIB_APPS} ${LIB_PLATFORM})
add_dependencies(https-client event_extra)

# Requires OpenSSL.
list(APPEND SAMPLES le-proxy)
endif()

foreach(SAMPLE ${SAMPLES})
add_executable(${SAMPLE} sample/${SAMPLE}.c)
target_link_libraries(${SAMPLE} event ${LIB_APPS} ${LIB_PLATFORM})
add_dependencies(${SAMPLE} event)
target_link_libraries(${SAMPLE} event_extra ${LIB_APPS} ${LIB_PLATFORM})
add_dependencies(${SAMPLE} event_extra)
endforeach()
endif()

if (NOT EVENT__DISABLE_BENCHMARK)
foreach (BENCHMARK bench bench_cascade bench_http bench_httpclient)
set(BENCH_SRC test/${BENCHMARK}.c)

if (WIN32)
list(APPEND BENCH_SRC WIN32-Code/getopt.c WIN32-Code/getopt_long.c)
endif()

add_executable(${BENCHMARK} ${BENCH_SRC})
target_link_libraries(${BENCHMARK} event ${LIB_PLATFORM})
add_dependencies(${BENCHMARK} event)
target_link_libraries(${BENCHMARK} event_extra ${LIB_PLATFORM})
add_dependencies(${BENCHMARK} event_extra)
endforeach()
endif()

Expand Down Expand Up @@ -770,6 +819,8 @@ if (NOT EVENT__DISABLE_TESTS)
test/regress_testutils.h
test/regress_util.c
test/tinytest.c
${SRC_CORE}
${SRC_EXTRA}
)

if (WIN32)
Expand All @@ -790,8 +841,14 @@ if (NOT EVENT__DISABLE_TESTS)
endif()

add_executable(regress ${SRC_REGRESS})
target_link_libraries(regress event ${LIB_APPS} ${LIB_PLATFORM})
add_dependencies(regress event)
# 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)
SET_TARGET_PROPERTIES(regress PROPERTIES COMPILE_DEFINITIONS
"EVENT_BUILDING_REGRESS_TEST=1")

target_link_libraries(regress ${LIB_APPS} ${LIB_PLATFORM})
else()
message(WARNING "Python not found, cannot generate regress tests!")
endif()
Expand All @@ -812,8 +869,8 @@ if (NOT EVENT__DISABLE_TESTS)
# Create test program executables.
foreach (TESTPROG ${ALL_TESTPROGS})
add_executable(${TESTPROG} test/${TESTPROG}.c)
target_link_libraries(${TESTPROG} event ${LIB_PLATFORM})
add_dependencies(${TESTPROG} event)
target_link_libraries(${TESTPROG} event_extra ${LIB_PLATFORM})
add_dependencies(${TESTPROG} event_extra)
endforeach()

#
Expand Down Expand Up @@ -1014,7 +1071,7 @@ foreach(p LIB BIN INCLUDE CMAKE)
endforeach()

# Export targets (This is used for other CMake projects to easily find the libraries and include files).
export(TARGETS event event_extras event_core
export(TARGETS event event_extra event_core
FILE "${PROJECT_BINARY_DIR}/LibeventTargets.cmake")
export(PACKAGE libevent)

Expand Down Expand Up @@ -1049,14 +1106,15 @@ configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in
@ONLY)

# Define the public headers.
set_target_properties(event event_core event_extras
set_target_properties(event event_core event_extra
PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}")

#
# Install targets.
#
install(TARGETS event event_core event_extras
install(TARGETS event event_core event_extra
EXPORT LibeventTargets
RUNTIME DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT bin
LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev)
Expand All @@ -1069,7 +1127,7 @@ install(FILES


# Install exports for the install-tree.
install(EXPORT LibeventTargets
install(EXPORT LibeventTargets
DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev)

set(LIBEVENT_LIBRARIES event event_core event_extras CACHE STRING "Libevent libraries")
set(LIBEVENT_LIBRARIES event event_core event_extra CACHE STRING "Libevent libraries")
2 changes: 2 additions & 0 deletions event-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,6 @@
/* Define to `int' if <sys/types.h> does not define. */
#cmakedefine EVENT__ssize_t ${EVENT__ssize_t}

#cmakedefine EVENT__NEED_DLLIMPORT ${EVENT__NEED_DLLIMPORT}

#endif
Loading

0 comments on commit 8896a92

Please sign in to comment.