Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MbedTLS v3 version support #39

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
freebsd_task:
matrix:
- name: FreeBSD 11.4
- name: FreeBSD 13.3
freebsd_instance:
image: freebsd-11-4-release-amd64
- name: FreeBSD 12.2
image: freebsd-13-3-release-amd64
- name: FreeBSD 14.1
freebsd_instance:
image: freebsd-12-2-release-amd64
image_family: freebsd-14-1

env:
HOME: /home/testuser

Expand Down Expand Up @@ -35,8 +36,8 @@ freebsd_task:
linux_mbedtls_task: # use master branch of libevent to support mbedtls
container:
matrix:
- image: ubuntu:18.04
- image: ubuntu:20.04
- image: ubuntu:24.04
- image: ubuntu:22.04

install_script:
- apt update && apt upgrade -y
Expand All @@ -62,11 +63,40 @@ linux_mbedtls_task: # use master branch of libevent to support mbedtls
- make
- make test

linux_mbedtls_v3_task: # use master branch of libevent to support mbedtls
container:
matrix:
- image: ubuntu:24.04

install_script:
- apt update && apt upgrade -y
- DEBIAN_FRONTEND=noninteractive apt install -y unzip git cmake build-essential curl libssl-dev libmbedtls-dev libpcre3-dev python3-dev
prepare_script:
- git submodule update --init
- curl -L https://github.com/libevent/libevent/archive/refs/heads/master.zip -o libevent.zip
- unzip libevent.zip
- cd libevent-master && cmake -DCMAKE_BUILD_TYPE=Release . && make install && cd ..
- curl -L https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.5.2.zip -o mbedtls.zip
- unzip mbedtls.zip
- cd mbedtls-3.5.2 && cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF . && make install && cd ..
build_default_test_script:
- mkdir -p build/default
- cd build/default
- cmake -DUSE_MBEDTLS=ON ../..
- make
- make test
build_acl_test_script:
- mkdir -p build/acl
- cd build/acl
- cmake -DUSE_MBEDTLS=ON -DWITH_ACL=ON ../..
- make
- make test

linux_openssl_task:
container:
matrix:
- image: ubuntu:18.04
- image: ubuntu:20.04
- image: ubuntu:22.04
- image: ubuntu:24.04

install_script:
- apt update && apt upgrade -y
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ endif()

find_package(Libevent2 REQUIRED)
include_directories(${LIBEVENT2_INCLUDE_DIR})
list(APPEND THIRDPARTY_LIBS ${LIBEVENT2_LIBRARIES})

list(APPEND THIRDPARTY_LIBS ${LIBEVENT2_LIBRARIES} ${LIBEVENT2_CORE} ${LIBEVENT2_EXTRA} ${LIBEVENT2_PTHREADS_LIBRARIES})

if(USE_MBEDTLS)
find_package(MbedTLS REQUIRED)
Expand Down Expand Up @@ -332,6 +332,7 @@ if(NOT ${A2X_EXECUTABLE} STREQUAL A2X_EXECUTABLE-NOTFOUND)
endif()

# tests
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
enable_testing()
add_subdirectory(test)

92 changes: 48 additions & 44 deletions cmake/FindLibevent2.cmake
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
#
# https://github.com/sipwise/sems/blob/master/cmake/FindLibevent2.cmake
#
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
FIND_PATH(LIBEVENT2_INCLUDE_DIR event2/event.h)
# found in on openssl site and made some changes GPL 2.0 licenced

IF(NOT WITH_LIBEVENT)
SET(WITH_LIBEVENT system)
ENDIF()

list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .imp)
list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .imp.lib)
IF(WITH_LIBEVENT STREQUAL "system" OR WITH_LIBEVENT STREQUAL "yes")
IF(NOT WIN32)
SET(LIBEVENT2_INCLUDE_PATH /usr/local/include /opt/local/include)
SET(LIBEVENT2_LIB_PATHS /usr/local/lib /opt/local/lib)
ENDIF()

if(CMAKE_CL_64)
FIND_LIBRARY(LIBEVENT2_LIBRARIES NAMES libevent-x64-v120-mt-2_1_4_0 event libevent )
else()
FIND_LIBRARY(LIBEVENT2_LIBRARIES NAMES libevent-x86-v120-mt-2_1_4_0 event libevent )
endif()
else()
set(LIBEVENT2_INCLUDE_DIR_SEARCH_PATHS /usr/local/include /usr/include)
set(LIBEVENT2_LIB_SEARCH_PATHS /usr/local/lib /usr/lib)
if(DEFINED Libevent2_ROOT)
set(LIBEVENT2_INCLUDE_DIR_SEARCH_PATHS ${Libevent2_ROOT}/include ${LIBEVENT2_INCLUDE_DIR_SEARCH_PATHS})
set(LIBEVENT2_LIB_SEARCH_PATHS ${Libevent2_ROOT}/lib ${LIBEVENT2_LIB_SEARCH_PATHS})
endif()
# -levent -levent_core -levent_extra -levent_openssl
FIND_PATH(LIBEVENT2_INCLUDE_DIR event2/event.h PATHS ${LIBEVENT2_INCLUDE_DIR_SEARCH_PATHS} NO_CMAKE_SYSTEM_PATH)
# OpenBSD issue, lookup from /usr/local/lib to avoid lib mismatch
FIND_LIBRARY(LIBEVENT2_LIBRARIES NAMES event libevent PATHS ${LIBEVENT2_LIB_SEARCH_PATHS} NO_CMAKE_SYSTEM_PATH)
FIND_LIBRARY(LIBEVENT2_CORE_LIBRARIES NAMES event_core libevent_core PATHS ${LIBEVENT2_LIB_SEARCH_PATHS} NO_CMAKE_SYSTEM_PATH)
FIND_LIBRARY(LIBEVENT2_EXTRA_LIBRARIES NAMES event_extra libevent_extra PATHS ${LIBEVENT2_LIB_SEARCH_PATHS} NO_CMAKE_SYSTEM_PATH)
FIND_LIBRARY(LIBEVENT2_SSL_LIBRARIES NAMES event_openssl libevent_openssl PATHS ${LIBEVENT2_LIB_SEARCH_PATHS} NO_CMAKE_SYSTEM_PATH)
FIND_LIBRARY(LIBEVENT2_MBEDTLS_LIBRARIES NAMES event_mbedtls libevent_mbedtls PATHS ${LIBEVENT2_LIB_SEARCH_PATHS}b NO_CMAKE_SYSTEM_PATH)
endif()
# use default paths
SET(HOW_TO_FIND)
ELSEIF(WITH_LIBEVENT STREQUAL "bundled")
MESSAGE(FATAL_ERROR "bundled libevent isn't support")
ELSE()
# make the users path for libevent absolute
GET_FILENAME_COMPONENT(LIBEVENT_ABS_DIR "${WITH_LIBEVENT}" ABSOLUTE)
SET(LIBEVENT2_INCLUDE_PATH ${LIBEVENT_ABS_DIR}/include)
SET(LIBEVENT2_LIB_PATHS ${LIBEVENT_ABS_DIR}/lib)

# if path specified, use that path only
SET(HOW_TO_FIND NO_DEFAULT_PATH)
ENDIF()

IF(LIBEVENT2_INCLUDE_DIR AND LIBEVENT2_LIBRARIES)
SET(LIBEVENT2_FOUND TRUE)
ENDIF(LIBEVENT2_INCLUDE_DIR AND LIBEVENT2_LIBRARIES)
FIND_PATH(LIBEVENT2_INCLUDE_DIR event2/event.h PATHS ${LIBEVENT2_INCLUDE_PATH} ${HOW_TO_FIND})
IF(WIN32)
## libevent-2.0.22 on windows is only 'event.lib' and 'event.dll'
FIND_LIBRARY(LIBEVENT2_CORE NAMES event PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
SET(LIBEVENT2_EXTRA)
ELSE()
FIND_LIBRARY(LIBEVENT2_CORE NAMES event_core libevent_core PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
FIND_LIBRARY(LIBEVENT2_EXTRA NAMES event_extra libevent_extra PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
FIND_LIBRARY(LIBEVENT2_SSL_LIBRARIES NAMES event_openssl libevent_openssl PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
FIND_LIBRARY(LIBEVENT2_MBEDTLS_LIBRARIES NAMES event_mbedtls libevent_mbedtls PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
FIND_LIBRARY(LIBEVENT2_PTHREADS_LIBRARIES NAMES event_pthreads libevent_pthreads PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})
ENDIF()

IF(LIBEVENT2_FOUND)
IF (NOT Libevent2_FIND_QUIETLY)
MESSAGE(STATUS "Found libevent2 includes: ${LIBEVENT2_INCLUDE_DIR}/event2/event.h")
MESSAGE(STATUS "Found libevent2 library: ${LIBEVENT2_LIBRARIES}")
MESSAGE(STATUS "Found libevent2 core library: ${LIBEVENT2_CORE_LIBRARIES}")
MESSAGE(STATUS "Found libevent2 extra library: ${LIBEVENT2_EXTRA_LIBRARIES}")
MESSAGE(STATUS "Found libevent2 openssl library: ${LIBEVENT2_SSL_LIBRARIES}")
MESSAGE(STATUS "Found libevent2 mbedtls library: ${LIBEVENT2_MBEDTLS_LIBRARIES}")
ENDIF (NOT Libevent2_FIND_QUIETLY)
ELSE(LIBEVENT2_FOUND)
IF (Libevent2_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find libevent2 development files: ${LIBEVENT2_INCLUDE_DIR} :: ${LIBEVENT2_LIBRARIES}")
ENDIF (Libevent2_FIND_REQUIRED)
ENDIF(LIBEVENT2_FOUND)
IF (LIBEVENT2_INCLUDE_DIR AND LIBEVENT2_CORE)
SET(LibEvent2_FOUND TRUE)
ELSE()
SET(LibEvent2_FOUND FALSE)
ENDIF()

# don't expose them in the cmake UI
MARK_AS_ADVANCED(
LIBEVENT2_INCLUDE_DIR
LIBEVENT2_CORE
LIBEVENT2_EXTRA
LIBEVENT2_SSL_LIBRARIES
LIBEVENT2_MBEDTLS_LIBRARIES
LIBEVENT2_PTHREADS_LIBRARIES
)
Loading