Changeset View
Changeset View
Standalone View
Standalone View
src/config/CMakeLists.txt
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | |||||
check_symbol_exists(EVP_MD_CTX_new "openssl/evp.h" HAVE_DECL_EVP_MD_CTX_NEW) | check_symbol_exists(EVP_MD_CTX_new "openssl/evp.h" HAVE_DECL_EVP_MD_CTX_NEW) | ||||
# Activate wallet | # Activate wallet | ||||
set(ENABLE_WALLET ${BUILD_BITCOIN_WALLET}) | set(ENABLE_WALLET ${BUILD_BITCOIN_WALLET}) | ||||
# Activate ZeroMQ | # Activate ZeroMQ | ||||
set(ENABLE_ZMQ ${BUILD_BITCOIN_ZMQ}) | set(ENABLE_ZMQ ${BUILD_BITCOIN_ZMQ}) | ||||
# Try to find miniupnpc | |||||
find_package(MiniUPnPc) | |||||
if(MINIUPNPC_FOUND) | |||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNPC_INCLUDE_DIR}) | |||||
check_include_files(miniupnpc/miniwget.h HAVE_MINIWIDGET_H) | |||||
check_include_files(miniupnpc/miniupnpc.h HAVE_MINIUPNPC_H) | |||||
check_include_files(miniupnpc/upnpcommands.h HAVE_UPNPCCOMMANDS_H) | |||||
check_include_files(miniupnpc/upnperrors.h HAVE_UPNPCERRORS_H) | |||||
# Should have them all to enable | |||||
if( | |||||
HAVE_MINIWIDGET_H AND | |||||
HAVE_MINIUPNPC_H AND | |||||
HAVE_UPNPCCOMMANDS_H AND | |||||
HAVE_UPNPCERRORS_H | |||||
) | |||||
set(HAVE_MINIUPNPC 1) | |||||
endif() | |||||
endif() | |||||
if(NOT HAVE_MINIUPNPC) | |||||
# If the user explicitly enabled UPnP through -DENABLE_UPNP=ON, ensure the | |||||
# miniupnpc library is present. | |||||
if(ENABLE_UPNP AND NOT ENABLE_UPNP STREQUAL "AUTO") | |||||
message(FATAL_ERROR | |||||
"UPnP requested but cannot be built. Use -DENABLE_UPNP=OFF" | |||||
) | |||||
endif() | |||||
else() | |||||
if(ENABLE_UPNP) | |||||
# UPnP is enabled, whether implicitly (not set) or explicitly by | |||||
# passing -DENABLE_UPNP=ON on the CMake command line. | |||||
# The expected behavior is as follow: | |||||
# - If UPnP is enabled USE_UPNP must be defined | |||||
# - If UPnP should be the default port map method, USE_UPNP should be | |||||
# defined to 1, otherwise it should be defined to 0. | |||||
# | |||||
# What we need is some tristate value: | |||||
# - /* #undef USE_UPNP */ if UPnP is disabled | |||||
# - #define USE_UPNP 0 if UPnP is enabled but not the default method | |||||
# - #define USE_UPNP 1 if UPnP is enabled and is the default method | |||||
# | |||||
# CMake cannot differentiate between a 0 value and the #undef case when | |||||
# using the configure_file function. | |||||
# To workaround this limitation, the #define 0 case is set to a value | |||||
# which is not interpreted as false by CMake but will be casted to | |||||
# boolean as false in the code. | |||||
if(USE_UPNP_DEFAULT) | |||||
set(USE_UPNP_VALUE 1) | |||||
else() | |||||
# Use parenthesis to avoid CMake to interpret as false, and use a | |||||
# quoted variable to avoid CMake escaping the parenthesis. | |||||
set(USE_UPNP_VALUE "(0)") | |||||
endif() | |||||
set(USE_UPNP ${USE_UPNP_VALUE} CACHE INTERNAL "UPnP is enabled") | |||||
endif() | |||||
endif() | |||||
# Generate the config | # Generate the config | ||||
configure_file(bitcoin-config.h.cmake.in bitcoin-config.h ESCAPE_QUOTES) | configure_file(bitcoin-config.h.cmake.in bitcoin-config.h ESCAPE_QUOTES) |