diff --git a/cmake/modules/FindZeroMQ.cmake b/cmake/modules/FindZeroMQ.cmake index 67dbdf331..8b634d689 100644 --- a/cmake/modules/FindZeroMQ.cmake +++ b/cmake/modules/FindZeroMQ.cmake @@ -1,21 +1,94 @@ -# Try to find the ZeroMQ libraries -# ZMQ_FOUND - system has ZeroMQ lib -# ZMQ_INCLUDE_DIR - the ZeroMQ include directory -# ZMQ_LIBRARY - Libraries needed to use ZeroMQ +# Copyright (c) 2017-2020 The Bitcoin developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. -if(ZMQ_INCLUDE_DIR AND ZMQ_LIBRARY) - # Already in cache, be silent - set(ZMQ_FIND_QUIETLY TRUE) -endif() +# .rst: +# FindZeroMQ +# -------------- +# +# Find the ZeroMQ library. The following conponents are +# available:: +# zmq +# +# This will define the following variables:: +# +# ZeroMQ_FOUND - True if the ZeroMQ library is found. +# ZeroMQ_INCLUDE_DIRS - List of the header include directories. +# ZeroMQ_LIBRARIES - List of the libraries. +# ZeroMQ_VERSION - The library version MAJOR.MINOR.PATCH +# ZeroMQ_VERSION_MAJOR - Major version number +# ZeroMQ_VERSION_MINOR - Minor version number +# ZeroMQ_VERSION_PATCH - Patch version number +# +# And the following imported targets:: +# +# ZeroMQ::zmq -find_path(ZMQ_INCLUDE_DIR NAMES zmq.h) -find_library(ZMQ_LIBRARY NAMES zmq libzmq) -message(STATUS "ZeroMQ lib: " ${ZMQ_LIBRARY}) +find_path(ZeroMQ_INCLUDE_DIR + NAMES zmq.h +) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ZeroMQ DEFAULT_MSG ZMQ_INCLUDE_DIR ZMQ_LIBRARY) +set(ZeroMQ_INCLUDE_DIRS "${ZeroMQ_INCLUDE_DIR}") +mark_as_advanced(ZeroMQ_INCLUDE_DIR) + +if(NOT DEFINED ZeroMQ_VERSION) + # Extract version information from the zmq.h header. + if(ZeroMQ_INCLUDE_DIR) + # Read the version from file zmq.h into a variable. + file(READ "${ZeroMQ_INCLUDE_DIR}/zmq.h" _ZMQ_HEADER) + + # Parse the version into variables. + string(REGEX REPLACE + ".*ZMQ_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" + ZeroMQ_VERSION_MAJOR + "${_ZMQ_HEADER}" + ) + string(REGEX REPLACE + ".*ZMQ_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" + ZeroMQ_VERSION_MINOR + "${_ZMQ_HEADER}" + ) + # Patch version example on non-crypto installs: x.x.xNC + string(REGEX REPLACE + ".*ZMQ_VERSION_PATCH[ \t]+([0-9]+(NC)?).*" "\\1" + ZeroMQ_VERSION_PATCH + "${_ZMQ_HEADER}" + ) + else() + # Set some garbage values to the versions since we didn't find a file to + # read. + set(ZeroMQ_VERSION_MAJOR "0") + set(ZeroMQ_VERSION_MINOR "0") + set(ZeroMQ_VERSION_PATCH "0") + endif() -mark_as_advanced(ZMQ_INCLUDE_DIR ZMQ_LIBRARY) + # Cache the result. + set(ZeroMQ_VERSION_MAJOR ${ZeroMQ_VERSION_MAJOR} + CACHE INTERNAL "ZeroMQ major version number" + ) + set(ZeroMQ_VERSION_MINOR ${ZeroMQ_VERSION_MINOR} + CACHE INTERNAL "ZeroMQ minor version number" + ) + set(ZeroMQ_VERSION_PATCH ${ZeroMQ_VERSION_PATCH} + CACHE INTERNAL "ZeroMQ patch version number" + ) + # The actual returned/output version variable (the others can be used if + # needed). + set(ZeroMQ_VERSION + "${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}" + CACHE INTERNAL "ZeroMQ full version" + ) +endif() + +include(ExternalLibraryHelper) +find_component(ZeroMQ zmq + NAMES zmq + INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIRS} +) -set(ZeroMQ_LIBRARIES ${ZMQ_LIBRARY}) -set(ZeroMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR}) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ZeroMQ + REQUIRED_VARS ZeroMQ_INCLUDE_DIR + VERSION_VAR ZeroMQ_VERSION + HANDLE_COMPONENTS +) diff --git a/doc/dependencies.md b/doc/dependencies.md index a90d7229e..cb065c7bf 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -1,33 +1,33 @@ Dependencies ============ These are the dependencies currently used by Bitcoin ABC. You can find instructions for installing them in the `build-*.md` file for your platform. | Dependency | Version used | Minimum required | CVEs | Shared | [Bundled Qt library](https://doc.qt.io/qt-5/configure-options.html) | | --- | --- | --- | --- | --- | --- | | Berkeley DB | [5.3.28](http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 5.3 | No | | | | Boost | [1.64.0](http://www.boost.org/users/download/) | 1.58.0 | No | | | | ccache | [3.3.6](https://ccache.samba.org/download.html) | | No | | | | Clang | | [3.4](http://llvm.org/releases/download.html) (C++14 support) | | | | | CMake | | [3.13](https://cmake.org/download/) | | | | | D-Bus | [1.10.18](https://cgit.freedesktop.org/dbus/dbus/tree/NEWS?h=dbus-1.10) | | No | Yes | | | Expat | [2.2.0](https://libexpat.github.io/) | | No | Yes | | | fontconfig | [2.12.6](https://www.freedesktop.org/software/fontconfig/release/) | | No | Yes | | | FreeType | [2.7.1](http://download.savannah.gnu.org/releases/freetype) | | No | | | | GCC | | [5.0](https://gcc.gnu.org/) (C++14 support) | | | | | HarfBuzz-NG | | | | | | | libevent | [2.1.8-stable](https://github.com/libevent/libevent/releases) | 2.0.22 | No | | | | libjpeg | | | | | Yes | | libpng | | | | | Yes | | MiniUPnPc | [2.0.20170509](http://miniupnp.free.fr/files) | 1.5 | No | | | | Ninja | | [1.5.1](https://github.com/ninja-build/ninja/releases) | | | | | OpenSSL | [1.0.1k](https://www.openssl.org/source) | | Yes | | | | PCRE | | | | | Yes | | protobuf | [2.6.1](https://github.com/google/protobuf/releases) | | No | | | | Python (tests) | | [3.5](https://www.python.org/downloads) | | | | | qrencode | [3.4.4](https://fukuchi.org/works/qrencode) | | No | | | | Qt | [5.9.6](https://download.qt.io/official_releases/qt/) | 5.5.1 | No | | | | XCB | | | | | Yes (Linux only) | | xkbcommon | | | | | Yes (Linux only) | -| ZeroMQ | [4.1.5](https://github.com/zeromq/libzmq/releases) | | No | | | +| ZeroMQ | [4.1.5](https://github.com/zeromq/libzmq/releases) | 4.1.5 | No | | | | zlib | [1.2.11](http://zlib.net/) | | | | No | diff --git a/src/zmq/CMakeLists.txt b/src/zmq/CMakeLists.txt index 6f618aa00..61a9871c4 100644 --- a/src/zmq/CMakeLists.txt +++ b/src/zmq/CMakeLists.txt @@ -1,18 +1,17 @@ # Copyright (c) 2017 The Bitcoin developers project(zmq) add_library(zmq zmqabstractnotifier.cpp zmqnotificationinterface.cpp zmqpublishnotifier.cpp zmqrpc.cpp ) -find_package(ZeroMQ REQUIRED) -target_include_directories(zmq PRIVATE ${ZMQ_INCLUDE_DIR}) -target_link_libraries(zmq util ${ZMQ_LIBRARY}) +find_package(ZeroMQ 4.1.5 REQUIRED) +target_link_libraries(zmq util ZeroMQ::zmq) if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_compile_definitions(zmq PUBLIC ZMQ_STATIC) endif()