libevent: allow build with cmake-4.0.0

This commit is contained in:
Rudi Heitbaum 2025-03-27 23:58:18 +00:00
parent 09d47b7fb8
commit 56eecd0a3d
4 changed files with 167 additions and 0 deletions

View File

@ -0,0 +1,59 @@
From bd2de4836b6b48d64da0cf010727209ad259a4f4 Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <azat@libevent.org>
Date: Wed, 26 Jun 2019 00:59:41 +0300
Subject: [PATCH] Require cmake >= 3.1.2 (for correct openssl 1.0.2 detection)
@ygj6 reported:
"My platform is MacOS 10.13.5, This problem only happens on Mac.
As written in the file CMakeLists.txt, the minimum required version of cmake is 3.1:
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
So I built this project with cmake-3.1.0, but I got the following errors:
CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:293 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:824 (find_package)
CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:294 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:824 (find_package)
CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:296 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:824 (find_package)
CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:298 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:824 (find_package)
I googled this error and got this answer:
https://bugs.archlinux.org/task/43688
It is a bug in FindOpenSSL.cmake on cmake-3.1.0 and fixed on cmake-3.1.2 .
Of course, It was successful when rebuilding with cmake-3.1.2 .
So I suggest setting the minimum version required for cmake to 3.1.2 or higher.
"
Closes: #845
Refs: https://github.com/Kitware/CMake/commit/de4ccee75a89519f95fcbcca75abc46577bfefea
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2089f832a..5aca8a9247 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@
# start libevent.sln
#
-cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.1.2 FATAL_ERROR)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)

View File

@ -0,0 +1,58 @@
From acfac7ae4a3edbbb7ce4ceee7208b4245a6e203e Mon Sep 17 00:00:00 2001
From: Ingo Bauersachs <ingo.bauersachs@xovis.com>
Date: Thu, 1 Dec 2022 18:39:52 +0100
Subject: [PATCH] Make dependency paths relocatable
The generated configurations for both CMake and pkg-config included
absolute paths to dependencies (OpenSSL, MbedTLS). This is contrary
to the general CMake advise to create relocatable packages [1].
Additionally, when building both mbedtls and libevent via CMake's
FetchContent in the same project, loading the project would fail with
INTERFACE_INCLUDE_DIRECTORIES property contains path:
"/home/user/project/cmake-build/_deps/mbedtls-build/include"
which is prefixed in the source directory.
The required changes include:
- Adding the outer includes only to the BUILD_INTERFACE solves the
makes the CMake paths relocatable and thus solves the FetchContent
problem.
- Updates to libevent_*.pc.in fixes the relocatable issues for
pkg-config and properly declares currently missing dependencies.
- Using components for linking to OpenSSL (requiring CMake 3.4)
and MbedTLS. The new MbedTLS target names now match the component
names of the MbedTLS' CMake project.
- Use the Threads CMake library reference instead of a direct
reference to support both built-in pthread and -lpthread.
v2 (azat): get back CMAKE_REQUIRED_LIBRARIES
[1] https://cmake.org/cmake/help/v3.25/manual/cmake-packages.7.html#creating-relocatable-packages
---
CMakeLists.txt | 28 +++++++++++-----------------
cmake/AddEventLibrary.cmake | 31 ++++++++++---------------------
cmake/FindMbedTLS.cmake | 20 +++++++++++---------
cmake/LibeventConfig.cmake.in | 21 ++++++++++++++++++---
libevent_core.pc.in | 5 +----
libevent_extra.pc.in | 6 ++----
libevent_mbedtls.pc.in | 8 +++-----
libevent_openssl.pc.in | 9 ++++-----
libevent_pthreads.pc.in | 8 +++-----
test-export/CMakeLists.txt | 3 ++-
test-export/test-export.py | 18 ++++++++++++++++--
11 files changed, 81 insertions(+), 76 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7199ab820d..c0c1c2fa97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@
# start libevent.sln
#
-cmake_minimum_required(VERSION 3.1.2 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)

View File

@ -0,0 +1,23 @@
From a9426941555ec52b25c3641ebb8af72d7d91ebf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C5=93ur?= <coeur@gmx.fr>
Date: Sun, 28 Apr 2024 13:16:54 +0800
Subject: [PATCH] Fix CMake Deprecation Warning
---
CMakeLists.txt | 2 +-
test-export/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ba64403ca..1869fccd2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@
# start libevent.sln
#
-cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH is enabled by default.

View File

@ -0,0 +1,27 @@
From 2d7a3b9b6a7c7ef0d651d866b4ab11fb1ea24664 Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Sat, 16 Nov 2024 21:26:55 +0000
Subject: [PATCH] cmake: Update minimum required version
Compatibility with versions of CMake older than 3.10 is now deprecated
and will be removed from a future version.
See: https://cmake.org/cmake/help/v3.31/release/3.31.html
---
CMakeLists.txt | 2 +-
test-export/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25578930b4..04e6933bee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@
# start libevent.sln
#
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH is enabled by default.