1# Downloads the declared version of libevent source code and builds it.
2
3if (APPLE OR WIN32)
4  # We bundle OpenSSL on MacOS X and Windows, and we want support
5  # for OpenSSL in libevent so we need to install the OpenSSL Package
6  SET (_openssl_install "${CMAKE_CURRENT_BINARY_DIR}/dep-install")
7  SET (_orig_install_prefix "${CMAKE_INSTALL_PREFIX}")
8  SET (CMAKE_INSTALL_PREFIX "${_openssl_install}")
9  DECLARE_DEP(openssl VERSION 1.0.2k-cb2 PLATFORMS windows_msvc windows_msvc2012 windows_msvc2013 windows_msvc2015 windows_msvc2017 macosx)
10  SET (CMAKE_INSTALL_PREFIX "${_orig_install_prefix}")
11  SET (_libevent_extra_options -D OPENSSL_ROOT_DIR=${_openssl_install})
12endif (APPLE OR WIN32)
13
14include(ExternalProject)
15
16### Download, configure and build libevent ####################################
17ExternalProject_Add(libevent
18  GIT_REPOSITORY ${_git_repo}
19  GIT_TAG ${_git_rev}
20
21  CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install
22             -D EVENT__BUILD_SHARED_LIBRARIES=ON
23             -D EVENT__DISABLE_DEBUG_MODE=ON
24             -D EVENT__DISABLE_BENCHMARK=ON
25             -D EVENT__DISABLE_TESTS=ON
26             -D EVENT__DISABLE_REGRESS=ON
27             -D EVENT__DISABLE_SAMPLES=ON
28             ${_libevent_extra_options}
29
30  INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install
31  INSTALL_COMMAND $(MAKE) install
32          COMMAND ${CMAKE_COMMAND} -E remove -f <INSTALL_DIR>/lib/cmake
33          COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt <INSTALL_DIR>/CMakeLists.txt
34)
35
36# OS X-only: Custom post-build step to set the shared library install name.
37if (APPLE)
38  ExternalProject_Add_Step(libevent install_name
39    COMMAND install_name_tool -id @rpath/libevent.2.1.8.dylib <BINARY_DIR>/lib/libevent.2.1.8.dylib
40    COMMAND install_name_tool -id @rpath/libevent_core.2.1.8.dylib <BINARY_DIR>/lib/libevent_core.2.1.8.dylib
41    COMMAND install_name_tool -id @rpath/libevent_extra.2.1.8.dylib <BINARY_DIR>/lib/libevent_extra.2.1.8.dylib
42    DEPENDEES build
43    DEPENDERS install
44    WORKING_DIRECTORY <BINARY_DIR>
45  )
46endif(APPLE)
47
48# cbdeps boilerplate
49_ADD_PACKAGE_STEP()
50