cmake: Add `FindZeroMQ` module

pull/30903/head
Hennadii Stepanov 2 months ago
parent 0c4ff18ee9
commit 6b8a74463b
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

@ -133,16 +133,7 @@ endif()
option(WITH_ZMQ "Enable ZMQ notifications." OFF)
if(WITH_ZMQ)
if(VCPKG_TARGET_TRIPLET)
find_package(ZeroMQ CONFIG REQUIRED)
else()
# The ZeroMQ project has provided config files since v4.2.2.
# However, mainstream distributions do not yet provide CMake
# config files for ZeroMQ packages. If they do in the future,
# find_package(ZeroMQ) may be used instead.
find_package(PkgConfig REQUIRED)
pkg_check_modules(libzmq REQUIRED IMPORTED_TARGET libzmq>=4)
endif()
find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
endif()
option(WITH_USDT "Enable tracepoints for Userspace, Statically Defined Tracing." OFF)

@ -0,0 +1,41 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
#[=======================================================================[
FindZeroMQ
----------
Finds the ZeroMQ headers and library.
This is a wrapper around find_package()/pkg_check_modules() commands that:
- facilitates searching in various build environments
- prints a standard log message
#]=======================================================================]
include(FindPackageHandleStandardArgs)
find_package(ZeroMQ ${ZeroMQ_FIND_VERSION} NO_MODULE QUIET)
if(ZeroMQ_FOUND)
find_package_handle_standard_args(ZeroMQ
REQUIRED_VARS ZeroMQ_DIR
VERSION_VAR ZeroMQ_VERSION
)
if(TARGET libzmq)
add_library(zeromq ALIAS libzmq)
elseif(TARGET libzmq-static)
add_library(zeromq ALIAS libzmq-static)
endif()
mark_as_advanced(ZeroMQ_DIR)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libzmq QUIET
IMPORTED_TARGET
libzmq>=${ZeroMQ_FIND_VERSION}
)
find_package_handle_standard_args(ZeroMQ
REQUIRED_VARS libzmq_LIBRARY_DIRS
VERSION_VAR libzmq_VERSION
)
add_library(zeromq ALIAS PkgConfig::libzmq)
endif()

@ -12,13 +12,10 @@ add_library(bitcoin_zmq STATIC EXCLUDE_FROM_ALL
target_compile_definitions(bitcoin_zmq
INTERFACE
ENABLE_ZMQ=1
PRIVATE
$<$<AND:$<PLATFORM_ID:Windows>,$<CXX_COMPILER_ID:GNU>>:ZMQ_STATIC>
)
target_link_libraries(bitcoin_zmq
PRIVATE
core_interface
univalue
$<TARGET_NAME_IF_EXISTS:libzmq>
$<TARGET_NAME_IF_EXISTS:PkgConfig::libzmq>
zeromq
)

Loading…
Cancel
Save