mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
cmake: Add FindZeroMQ
module
This commit is contained in:
parent
0c4ff18ee9
commit
6b8a74463b
3 changed files with 43 additions and 14 deletions
|
@ -133,16 +133,7 @@ endif()
|
||||||
|
|
||||||
option(WITH_ZMQ "Enable ZMQ notifications." OFF)
|
option(WITH_ZMQ "Enable ZMQ notifications." OFF)
|
||||||
if(WITH_ZMQ)
|
if(WITH_ZMQ)
|
||||||
if(VCPKG_TARGET_TRIPLET)
|
find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
|
||||||
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()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(WITH_USDT "Enable tracepoints for Userspace, Statically Defined Tracing." OFF)
|
option(WITH_USDT "Enable tracepoints for Userspace, Statically Defined Tracing." OFF)
|
||||||
|
|
41
cmake/module/FindZeroMQ.cmake
Normal file
41
cmake/module/FindZeroMQ.cmake
Normal file
|
@ -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
|
target_compile_definitions(bitcoin_zmq
|
||||||
INTERFACE
|
INTERFACE
|
||||||
ENABLE_ZMQ=1
|
ENABLE_ZMQ=1
|
||||||
PRIVATE
|
|
||||||
$<$<AND:$<PLATFORM_ID:Windows>,$<CXX_COMPILER_ID:GNU>>:ZMQ_STATIC>
|
|
||||||
)
|
)
|
||||||
target_link_libraries(bitcoin_zmq
|
target_link_libraries(bitcoin_zmq
|
||||||
PRIVATE
|
PRIVATE
|
||||||
core_interface
|
core_interface
|
||||||
univalue
|
univalue
|
||||||
$<TARGET_NAME_IF_EXISTS:libzmq>
|
zeromq
|
||||||
$<TARGET_NAME_IF_EXISTS:PkgConfig::libzmq>
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue