diff --git a/cmake/modules/FindBerkeleyDB.cmake b/cmake/modules/FindBerkeleyDB.cmake index 62211dfb9..1d37e0a3d 100644 --- a/cmake/modules/FindBerkeleyDB.cmake +++ b/cmake/modules/FindBerkeleyDB.cmake @@ -1,167 +1,168 @@ # 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. #.rst # FindBerkeleyDB # ------------- # # This is inspired by https://github.com/sum01/FindBerkeleyDB. # # Find the Berkeley database (versions >= 5.x) libraries The following # components are available:: # C # CXX # # This will define the following variables:: # # BerkeleyDB_FOUND - system has Berkeley DB lib # BerkeleyDB_INCLUDE_DIRS - the Berkeley DB include directories # BerkeleyDB_LIBRARIES - Libraries needed to use Berkeley DB # BerkeleyDB_VERSION - The library version MAJOR.MINOR.PATCH # BerkeleyDB_VERSION_MAJOR - Major version number # BerkeleyDB_VERSION_MINOR - Minor version number # BerkeleyDB_VERSION_PATCH - Patch version number # # And the following imported target:: # # BerkeleyDB::C # BerkeleyDB::CXX # Generate a list of all the possible versioned library name variants given a # list of separators. function(generate_versions_variants VARIANTS LIB MAJOR MINOR) set(SEPARATORS "" "." "-" "_" ) set(${VARIANTS} "${LIB}") foreach(_separator1 IN LISTS SEPARATORS) list(APPEND ${VARIANTS} "${LIB}${_separator1}${MAJOR}") foreach(_separator2 IN LISTS SEPARATORS) list(APPEND ${VARIANTS} "${LIB}${_separator1}${MAJOR}${_separator2}${MINOR}") endforeach() endforeach() set(${VARIANTS} ${${VARIANTS}} PARENT_SCOPE) endfunction() include(BrewHelper) find_brew_prefix(_BerkeleyDB_BREW_HINT berkeley-db) # If the include directory is user supplied, skip the search if(NOT BerkeleyDB_INCLUDE_DIR) # Berkeley DB 5 including latest minor release. generate_versions_variants(_BerkeleyDB_PATH_SUFFIXES_5_3 db 5 3) # Berkeley DB 6 including latest minor release. generate_versions_variants(_BerkeleyDB_PATH_SUFFIXES_6_2 db 6 2) # Berkeley DB 18 including latest minor release (current). generate_versions_variants(_BerkeleyDB_PATH_SUFFIXES_18_1 db 18 1) set(_BerkeleyDB_PATH_SUFFIXES include ${_BerkeleyDB_PATH_SUFFIXES_5_3} ${_BerkeleyDB_PATH_SUFFIXES_6_2} ${_BerkeleyDB_PATH_SUFFIXES_18_1} ) list(REMOVE_DUPLICATES _BerkeleyDB_PATH_SUFFIXES) # Try to find the db.h header. # If the header is not found the user can supply the correct path by passing # the `BerkeleyDB_ROOT` variable to cmake. find_path(BerkeleyDB_INCLUDE_DIR NAMES db.h HINTS ${_BerkeleyDB_BREW_HINT} PATH_SUFFIXES ${_BerkeleyDB_PATH_SUFFIXES} ) endif() # There is a single common include directory. # Set the BerkeleyDB_INCLUDE_DIRS variable which is the expected standard output # variable name for the include directories. set(BerkeleyDB_INCLUDE_DIRS "${BerkeleyDB_INCLUDE_DIR}") mark_as_advanced(BerkeleyDB_INCLUDE_DIR) if(BerkeleyDB_INCLUDE_DIR) # Extract version information from the db.h header. if(NOT DEFINED BerkeleyDB_VERSION) # Read the version from file db.h into a variable. file(READ "${BerkeleyDB_INCLUDE_DIR}/db.h" _BerkeleyDB_DB_HEADER) # Parse the version into variables. string(REGEX REPLACE ".*DB_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" BerkeleyDB_VERSION_MAJOR "${_BerkeleyDB_DB_HEADER}" ) string(REGEX REPLACE ".*DB_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" BerkeleyDB_VERSION_MINOR "${_BerkeleyDB_DB_HEADER}" ) # Patch version example on non-crypto installs: x.x.xNC string(REGEX REPLACE ".*DB_VERSION_PATCH[ \t]+([0-9]+(NC)?).*" "\\1" BerkeleyDB_VERSION_PATCH "${_BerkeleyDB_DB_HEADER}" ) # Cache the result. set(BerkeleyDB_VERSION_MAJOR ${BerkeleyDB_VERSION_MAJOR} CACHE INTERNAL "BerekeleyDB major version number" ) set(BerkeleyDB_VERSION_MINOR ${BerkeleyDB_VERSION_MINOR} CACHE INTERNAL "BerekeleyDB minor version number" ) set(BerkeleyDB_VERSION_PATCH ${BerkeleyDB_VERSION_PATCH} CACHE INTERNAL "BerekeleyDB patch version number" ) # The actual returned/output version variable (the others can be used if # needed). set(BerkeleyDB_VERSION "${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}.${BerkeleyDB_VERSION_PATCH}" CACHE INTERNAL "BerekeleyDB full version" ) endif() include(ExternalLibraryHelper) # Different systems sometimes have a version in the lib name... # and some have a dash or underscore before the versions. # Generate all combinations from the separators "" (none), ".", "-" and "_". generate_versions_variants( _db_variants db "${BerkeleyDB_VERSION_MAJOR}" "${BerkeleyDB_VERSION_MINOR}" ) find_component(BerkeleyDB C NAMES ${_db_variants} HINTS ${_BerkeleyDB_BREW_HINT} PATH_SUFFIXES ${_db_variants} INCLUDE_DIRS ${BerkeleyDB_INCLUDE_DIRS} ) generate_versions_variants( _db_cxx_variants db_cxx "${BerkeleyDB_VERSION_MAJOR}" "${BerkeleyDB_VERSION_MINOR}" ) find_component(BerkeleyDB CXX NAMES ${_db_cxx_variants} HINTS ${_BerkeleyDB_BREW_HINT} PATH_SUFFIXES ${_db_variants} INCLUDE_DIRS ${BerkeleyDB_INCLUDE_DIRS} ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(BerkeleyDB REQUIRED_VARS BerkeleyDB_INCLUDE_DIR VERSION_VAR BerkeleyDB_VERSION + REASON_FAILURE_MESSAGE "if you don't want to build the wallet feature, this can be skipped by passing -DBUILD_BITCOIN_WALLET=OFF to the cmake command line" HANDLE_COMPONENTS ) diff --git a/cmake/modules/FindJemalloc.cmake b/cmake/modules/FindJemalloc.cmake index ba5fd5ed4..9436c6467 100644 --- a/cmake/modules/FindJemalloc.cmake +++ b/cmake/modules/FindJemalloc.cmake @@ -1,115 +1,116 @@ # Copyright (c) 2020 The Bitcoin developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. #.rst # FindJemalloc # ------------- # # Find the Jemalloc library. # # This will define the following variables:: # # Jemalloc_FOUND - system has Jemalloc lib # Jemalloc_INCLUDE_DIRS - the Jemalloc include directories # Jemalloc_LIBRARIES - Libraries needed to use Jemalloc # Jemalloc_VERSION - The library version MAJOR.MINOR.PATCH # # And the following imported target:: # # Jemalloc::jemalloc find_package(PkgConfig) pkg_check_modules(PC_Jemalloc QUIET libjemalloc) include(BrewHelper) find_brew_prefix(_Jemalloc_BREW_HINT jemalloc) find_path(Jemalloc_INCLUDE_DIR NAMES jemalloc.h PATHS ${Jemalloc_INCLUDE_DIR} PATH_SUFFIXES include jemalloc HINTS ${_Jemalloc_BREW_HINT} ) set(Jemalloc_INCLUDE_DIRS ${Jemalloc_INCLUDE_DIR}) mark_as_advanced(Jemalloc_INCLUDE_DIR) if(Jemalloc_INCLUDE_DIR) if(NOT Jemalloc_VERSION) # If pkgconfig found a version number, use it. if(PC_Jemalloc_VERSION AND (Jemalloc_INCLUDE_DIR STREQUAL PC_Jemalloc_INCLUDEDIR)) set(_Jemalloc_VERSION ${PC_Jemalloc_VERSION}) else() # Read the version from file db.h into a variable. file(READ "${Jemalloc_INCLUDE_DIR}/jemalloc.h" _Jemalloc_HEADER) # Parse the version into variables. string(REGEX REPLACE ".*JEMALLOC_VERSION[ \t]+\"([^\"]+)\".*" "\\1" _Jemalloc_VERSION "${_Jemalloc_HEADER}" ) endif() string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" Jemalloc_VERSION "${_Jemalloc_VERSION}") set(Jemalloc_VERSION ${Jemalloc_VERSION} CACHE INTERNAL "Jemalloc library full version" ) endif() include(ExternalLibraryHelper) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) find_component(Jemalloc jemalloc NAMES jemalloc_pic jemalloc HINTS "${_Jemalloc_BREW_HINT}" INCLUDE_DIRS ${Jemalloc_INCLUDE_DIRS} PATHS ${PC_Jemalloc_LIBRARY_DIRS} INTERFACE_LINK_LIBRARIES "$<$>:m>" Threads::Threads ) # jemalloc might be built with or without libdl support. Check if the link # succeeds without -ldl, and add the flag otherwise. if(TARGET Jemalloc::jemalloc) try_compile(_Jemalloc_BUILD_WITHOUT_DL ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/cmake/utils/CheckJemallocBuilds.c" LINK_LIBRARIES Jemalloc::jemalloc OUTPUT_VARIABLE _Jemalloc_BUILD_OUTPUT ) if(NOT _Jemalloc_BUILD_WITHOUT_DL) # The expected error is: undefined reference to `dlsym`. Search for # the `dlsym` word only in the output to check the failure is # related to libdl, in order to accommodate with various compilers # and locales. string(REGEX MATCH "dlsym" _Jemalloc_DLSYM_IN_OUTPUT "${_Jemalloc_BUILD_OUTPUT}") if(_Jemalloc_DLSYM_IN_OUTPUT) set_property( TARGET Jemalloc::jemalloc APPEND PROPERTY INTERFACE_LINK_LIBRARIES dl ) set(_Jemalloc_NEEDS_DL TRUE) else() message(FATAL_ERROR "Jemalloc was found, but the configuration failed to build a simple program. Please check it is installed properly or consider disabling it. Build output: ${_Jemalloc_BUILD_OUTPUT}") endif() else() set(_Jemalloc_NEEDS_DL FALSE) endif() if(NOT Jemalloc_FIND_QUIETLY) message(STATUS "Check if jemalloc needs libdl - ${_Jemalloc_NEEDS_DL}") endif() endif() endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Jemalloc REQUIRED_VARS Jemalloc_INCLUDE_DIR VERSION_VAR Jemalloc_VERSION + REASON_FAILURE_MESSAGE "this is an optional dependency that can be disabled by passing -DUSE_JEMALLOC=OFF to the cmake command line" HANDLE_COMPONENTS ) diff --git a/cmake/modules/FindMiniUPnPc.cmake b/cmake/modules/FindMiniUPnPc.cmake index 702d50240..db63d2de0 100644 --- a/cmake/modules/FindMiniUPnPc.cmake +++ b/cmake/modules/FindMiniUPnPc.cmake @@ -1,75 +1,76 @@ # Copyright (c) 2019-2020 The Bitcoin developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. #.rst # FindMiniUPnPc # ------------- # # Find the MiniUPnPc library. The following # components are available:: # miniupnpc # # This will define the following variables:: # # MiniUPnPc_FOUND - system has MiniUPnPc lib # MiniUPnPc_INCLUDE_DIRS - the MiniUPnPc include directories # MiniUPnPc_LIBRARIES - Libraries needed to use MiniUPnPc # MiniUPnPc_VERSION - The library version MAJOR.MINOR.PATCH # # And the following imported target:: # # MiniUPnPc::miniupnpc include(BrewHelper) find_brew_prefix(_MiniUPnPc_BREW_HINT miniupnpc) find_package(PkgConfig) pkg_check_modules(PC_MiniUPnPc QUIET libqrencode) find_path(MiniUPnPc_INCLUDE_DIR NAMES miniupnpc.h HINTS ${_MiniUPnPc_BREW_HINT} PATHS ${PC_MiniUPnPc_INCLUDE_DIRS} PATH_SUFFIXES include miniupnpc ) set(MiniUPnPc_INCLUDE_DIRS "${MiniUPnPc_INCLUDE_DIR}") mark_as_advanced(MiniUPnPc_INCLUDE_DIR) if(MiniUPnPc_INCLUDE_DIR) # Extract version information from the miniupnpc.h header. if(NOT DEFINED MiniUPnPc_VERSION) # Read the version from file miniupnpc.h into a variable. file(READ "${MiniUPnPc_INCLUDE_DIR}/miniupnpc.h" _MiniUPnPc_HEADER) # Parse the version into variable. string(REGEX REPLACE ".*MINIUPNPC_VERSION[ \t]+\"([0-9]+\.[0-9]+(\.[0-9]+)?)\".*" "\\1" MiniUPnPc_VERSION "${_MiniUPnPc_HEADER}" ) set(MiniUPnPc_VERSION "${MiniUPnPc_VERSION}" CACHE INTERNAL "MiniUPnPc full version" ) endif() include(ExternalLibraryHelper) find_component(MiniUPnPc miniupnpc NAMES miniupnpc HINTS ${_MiniUPnPc_BREW_HINT} PATHS ${PC_MiniUPnPc_LIBRARY_DIRS} PATH_SUFFIXES miniupnpc INCLUDE_DIRS ${MiniUPnPc_INCLUDE_DIRS} INTERFACE_LINK_LIBRARIES "$<$:ws2_32;iphlpapi>" ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MiniUPnPc REQUIRED_VARS MiniUPnPc_INCLUDE_DIR VERSION_VAR MiniUPnPc_VERSION + REASON_FAILURE_MESSAGE "if the UPnP feature is not required, it can be skipped by passing -DENABLE_UPNP=OFF to the cmake command line" HANDLE_COMPONENTS ) diff --git a/cmake/modules/FindQREncode.cmake b/cmake/modules/FindQREncode.cmake index 694d953c4..37941974b 100644 --- a/cmake/modules/FindQREncode.cmake +++ b/cmake/modules/FindQREncode.cmake @@ -1,57 +1,58 @@ # Copyright (c) 2019-2020 The Bitcoin developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. #.rst # FindQREncode # ------------- # # Find the QREncode library. The following # components are available:: # qrencode # # This will define the following variables:: # # QREncode_FOUND - system has QREncode lib # QREncode_INCLUDE_DIRS - the QREncode include directories # QREncode_LIBRARIES - Libraries needed to use QREncode # # And the following imported target:: # # QREncode::qrencode include(BrewHelper) find_brew_prefix(_QREncode_BREW_HINT qrencode) find_package(PkgConfig) pkg_check_modules(PC_QREncode QUIET libqrencode) find_path(QREncode_INCLUDE_DIR NAMES qrencode.h HINTS ${_QREncode_BREW_HINT} PATHS ${PC_QREncode_INCLUDE_DIRS} PATH_SUFFIXES include ) set(QREncode_INCLUDE_DIRS "${QREncode_INCLUDE_DIR}") mark_as_advanced(QREncode_INCLUDE_DIR) # TODO: extract a version number. # For now qrencode does not provide an easy way to extract a version number. if(QREncode_INCLUDE_DIR) include(ExternalLibraryHelper) find_component(QREncode qrencode NAMES qrencode HINTS ${_QREncode_BREW_HINT} PATHS ${PC_QREncode_LIBRARY_DIRS} INCLUDE_DIRS ${QREncode_INCLUDE_DIRS} ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QREncode REQUIRED_VARS QREncode_INCLUDE_DIR + REASON_FAILURE_MESSAGE "if displaying QR codes is not required, it can be skipped by passing -DENABLE_QRCODE=OFF to the cmake command line" HANDLE_COMPONENTS ) diff --git a/cmake/modules/FindZeroMQ.cmake b/cmake/modules/FindZeroMQ.cmake index 5352ca71e..a3feccadd 100644 --- a/cmake/modules/FindZeroMQ.cmake +++ b/cmake/modules/FindZeroMQ.cmake @@ -1,97 +1,98 @@ # 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. # .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(ZeroMQ_INCLUDE_DIR NAMES zmq.h ) set(ZeroMQ_INCLUDE_DIRS "${ZeroMQ_INCLUDE_DIR}") mark_as_advanced(ZeroMQ_INCLUDE_DIR) if(ZeroMQ_INCLUDE_DIR) # Extract version information from the zmq.h header. if(NOT DEFINED ZeroMQ_VERSION) # 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}" ) # 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) # The dependency to iphlpapi starts from 4.2.0 if(ZeroMQ_VERSION VERSION_LESS 4.2.0) set(_ZeroMQ_WINDOWS_LIBRARIES "$<$:ws2_32;rpcrt4>") else() set(_ZeroMQ_WINDOWS_LIBRARIES "$<$:ws2_32;rpcrt4;iphlpapi>") endif() find_component(ZeroMQ zmq NAMES zmq INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIRS} INTERFACE_LINK_LIBRARIES "${_ZeroMQ_WINDOWS_LIBRARIES}" ) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ZeroMQ REQUIRED_VARS ZeroMQ_INCLUDE_DIR VERSION_VAR ZeroMQ_VERSION + REASON_FAILURE_MESSAGE "if the ZeroMQ feature is not required, it can be skipped by passing -DBUILD_BITCOIN_ZMQ=OFF to the cmake command line" HANDLE_COMPONENTS )