mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 01:42:58 +01:00
Merge bitcoin/bitcoin#31181: cmake: Revamp FindLibevent
module
5a96767e3f
depends, libevent: Do not install *.pc files and remove patches for them (Hennadii Stepanov)ffda355b5a
cmake, refactor: Move `HAVE_EVHTTP_...` to `libevent` interface (Hennadii Stepanov)b619bdc330
cmake: Revamp `FindLibevent` module (Hennadii Stepanov) Pull request description: This PR generalizes the use of `find_package` / `pkg_check_modules`, prioritizing the former. Addresses https://github.com/bitcoin/bitcoin/pull/30903#issuecomment-2444700876: > We should also follow up with refactoring the libevent module, to more generically use CMake/pkg-config, rather than restricting the CMake usage to `vcpkg`. At that point, we'd likely be able to dump pkg-config for the depends path entirely. Similar to https://github.com/bitcoin/bitcoin/pull/30903. ACKs for top commit: fanquake: ACK5a96767e3f
Tree-SHA512: 181020c16ccd2821e718c73f264badcdc5e62980c4a8d9691e759efe2ea00da2326e26308d1dcfdeac01e9e27930428ecace9f36941deee951b751b138d7266c
This commit is contained in:
commit
8d340be924
@ -71,9 +71,6 @@
|
||||
*/
|
||||
#cmakedefine01 HAVE_DECL_SETSID
|
||||
|
||||
/* Define this symbol if evhttp_connection_get_peer expects const char** */
|
||||
#cmakedefine HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR 1
|
||||
|
||||
/* Define to 1 if fdatasync is available. */
|
||||
#cmakedefine HAVE_FDATASYNC 1
|
||||
|
||||
|
@ -35,46 +35,52 @@ function(check_evhttp_connection_get_peer target)
|
||||
" HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
|
||||
)
|
||||
cmake_pop_check_state()
|
||||
set(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR ${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR} PARENT_SCOPE)
|
||||
target_compile_definitions(${target} INTERFACE
|
||||
$<$<BOOL:${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR}>:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
set(_libevent_components core extra)
|
||||
if(NOT WIN32)
|
||||
list(APPEND _libevent_components pthreads)
|
||||
endif()
|
||||
|
||||
find_package(Libevent ${Libevent_FIND_VERSION} QUIET
|
||||
NO_MODULE
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
find_package(Libevent ${Libevent_FIND_VERSION} NO_MODULE QUIET
|
||||
COMPONENTS extra
|
||||
if(Libevent_FOUND)
|
||||
find_package(Libevent ${Libevent_FIND_VERSION} QUIET
|
||||
REQUIRED COMPONENTS ${_libevent_components}
|
||||
NO_MODULE
|
||||
)
|
||||
find_package_handle_standard_args(Libevent
|
||||
REQUIRED_VARS Libevent_DIR
|
||||
VERSION_VAR Libevent_VERSION
|
||||
)
|
||||
check_evhttp_connection_get_peer(libevent::extra)
|
||||
add_library(libevent::libevent ALIAS libevent::extra)
|
||||
mark_as_advanced(Libevent_DIR)
|
||||
mark_as_advanced(_event_h)
|
||||
mark_as_advanced(_event_lib)
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(libevent QUIET
|
||||
IMPORTED_TARGET
|
||||
libevent>=${Libevent_FIND_VERSION}
|
||||
)
|
||||
set(_libevent_required_vars libevent_LIBRARY_DIRS libevent_FOUND)
|
||||
if(NOT WIN32)
|
||||
pkg_check_modules(libevent_pthreads QUIET
|
||||
IMPORTED_TARGET
|
||||
libevent_pthreads>=${Libevent_FIND_VERSION}
|
||||
foreach(component IN LISTS _libevent_components)
|
||||
pkg_check_modules(libevent_${component}
|
||||
REQUIRED QUIET
|
||||
IMPORTED_TARGET GLOBAL
|
||||
libevent_${component}>=${Libevent_FIND_VERSION}
|
||||
)
|
||||
list(APPEND _libevent_required_vars libevent_pthreads_FOUND)
|
||||
endif()
|
||||
if(TARGET PkgConfig::libevent_${component} AND NOT TARGET libevent::${component})
|
||||
add_library(libevent::${component} ALIAS PkgConfig::libevent_${component})
|
||||
endif()
|
||||
endforeach()
|
||||
find_package_handle_standard_args(Libevent
|
||||
REQUIRED_VARS ${_libevent_required_vars}
|
||||
VERSION_VAR libevent_VERSION
|
||||
REQUIRED_VARS libevent_core_LIBRARY_DIRS
|
||||
VERSION_VAR libevent_core_VERSION
|
||||
)
|
||||
unset(_libevent_required_vars)
|
||||
check_evhttp_connection_get_peer(PkgConfig::libevent)
|
||||
add_library(libevent::libevent ALIAS PkgConfig::libevent)
|
||||
if(NOT WIN32)
|
||||
add_library(libevent::pthreads ALIAS PkgConfig::libevent_pthreads)
|
||||
endif()
|
||||
check_evhttp_connection_get_peer(PkgConfig::libevent_extra)
|
||||
endif()
|
||||
|
||||
unset(_libevent_components)
|
||||
|
||||
mark_as_advanced(Libevent_DIR)
|
||||
mark_as_advanced(_event_h)
|
||||
mark_as_advanced(_event_lib)
|
||||
|
@ -4,7 +4,6 @@ $(package)_download_path=https://github.com/libevent/libevent/releases/download/
|
||||
$(package)_file_name=$(package)-$($(package)_version).tar.gz
|
||||
$(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
|
||||
$(package)_patches=cmake_fixups.patch
|
||||
$(package)_patches+=fix_mingw_link.patch
|
||||
$(package)_build_subdir=build
|
||||
|
||||
# When building for Windows, we set _WIN32_WINNT to target the same Windows
|
||||
@ -23,8 +22,7 @@ define $(package)_set_vars
|
||||
endef
|
||||
|
||||
define $(package)_preprocess_cmds
|
||||
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch && \
|
||||
patch -p1 < $($(package)_patch_dir)/fix_mingw_link.patch
|
||||
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch
|
||||
endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
@ -40,7 +38,8 @@ define $(package)_stage_cmds
|
||||
endef
|
||||
|
||||
define $(package)_postprocess_cmds
|
||||
rm -rf bin && \
|
||||
rm -rf bin lib/pkgconfig && \
|
||||
rm include/ev*.h && \
|
||||
rm include/event2/*_compat.h
|
||||
rm include/event2/*_compat.h && \
|
||||
rm lib/libevent.a
|
||||
endef
|
||||
|
@ -1,8 +1,5 @@
|
||||
cmake: set minimum version to 3.5
|
||||
|
||||
Fix generated pkg-config files, see
|
||||
https://github.com/libevent/libevent/pull/1165.
|
||||
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -19,7 +19,7 @@
|
||||
@ -14,22 +11,3 @@ https://github.com/libevent/libevent/pull/1165.
|
||||
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
diff --git a/cmake/AddEventLibrary.cmake b/cmake/AddEventLibrary.cmake
|
||||
index 04f5837e..d8ea42c4 100644
|
||||
--- a/cmake/AddEventLibrary.cmake
|
||||
+++ b/cmake/AddEventLibrary.cmake
|
||||
@@ -20,12 +20,12 @@ macro(generate_pkgconfig LIB_NAME)
|
||||
|
||||
set(LIBS "")
|
||||
foreach (LIB ${LIB_PLATFORM})
|
||||
- set(LIBS "${LIBS} -L${LIB}")
|
||||
+ set(LIBS "${LIBS} -l${LIB}")
|
||||
endforeach()
|
||||
|
||||
set(OPENSSL_LIBS "")
|
||||
foreach(LIB ${OPENSSL_LIBRARIES})
|
||||
- set(OPENSSL_LIBS "${OPENSSL_LIBS} -L${LIB}")
|
||||
+ set(OPENSSL_LIBS "${OPENSSL_LIBS} -l${LIB}")
|
||||
endforeach()
|
||||
|
||||
configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
|
||||
|
@ -1,25 +0,0 @@
|
||||
commit d108099913c5fdbe518f3f4d711f248f8522bd10
|
||||
Author: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
|
||||
Date: Mon Apr 22 06:39:35 2024 +0100
|
||||
|
||||
build: Add `Iphlpapi` to `Libs.private` in `*.pc` files on Windows
|
||||
|
||||
It has been required since https://github.com/libevent/libevent/pull/923
|
||||
at least for the `if_nametoindex` call.
|
||||
|
||||
See https://github.com/libevent/libevent/pull/1622.
|
||||
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index d00e063a..cd1fce37 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -906,7 +906,7 @@ if(WIN32)
|
||||
list(APPEND HDR_PRIVATE WIN32-Code/getopt.h)
|
||||
|
||||
set(EVENT__DNS_USE_FTIME_FOR_ID 1)
|
||||
- set(LIB_PLATFORM ws2_32 shell32 advapi32)
|
||||
+ set(LIB_PLATFORM ws2_32 shell32 advapi32 iphlpapi)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE)
|
@ -182,7 +182,7 @@ Setup and Build Example: Arch Linux
|
||||
-----------------------------------
|
||||
This example lists the steps necessary to setup and build a command line only distribution of the latest changes on Arch Linux:
|
||||
|
||||
pacman --sync --needed cmake boost gcc git libevent make pkgconf python sqlite
|
||||
pacman --sync --needed cmake boost gcc git libevent make python sqlite
|
||||
git clone https://github.com/bitcoin/bitcoin.git
|
||||
cd bitcoin/
|
||||
cmake -B build
|
||||
|
@ -290,13 +290,14 @@ target_link_libraries(bitcoin_node
|
||||
core_interface
|
||||
bitcoin_common
|
||||
bitcoin_util
|
||||
$<TARGET_NAME_IF_EXISTS:bitcoin_zmq>
|
||||
leveldb
|
||||
minisketch
|
||||
univalue
|
||||
Boost::headers
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
|
||||
libevent::core
|
||||
libevent::extra
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::pthreads>
|
||||
$<TARGET_NAME_IF_EXISTS:bitcoin_zmq>
|
||||
$<TARGET_NAME_IF_EXISTS:USDT::headers>
|
||||
)
|
||||
|
||||
@ -366,7 +367,8 @@ if(BUILD_CLI)
|
||||
bitcoin_cli
|
||||
bitcoin_common
|
||||
bitcoin_util
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
|
||||
libevent::core
|
||||
libevent::extra
|
||||
)
|
||||
list(APPEND installable_targets bitcoin-cli)
|
||||
endif()
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bitcoin-build-config.h> // IWYU pragma: keep
|
||||
|
||||
#include <httpserver.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
|
@ -154,7 +154,7 @@ target_link_libraries(test_bitcoin
|
||||
minisketch
|
||||
secp256k1
|
||||
Boost::headers
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
|
||||
libevent::extra
|
||||
)
|
||||
|
||||
if(ENABLE_WALLET)
|
||||
|
@ -140,7 +140,7 @@ target_link_libraries(fuzz
|
||||
univalue
|
||||
secp256k1
|
||||
Boost::headers
|
||||
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
|
||||
libevent::extra
|
||||
)
|
||||
|
||||
if(ENABLE_WALLET)
|
||||
|
Loading…
Reference in New Issue
Block a user