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 | |||||
if(ENABLE_UPNP) | |||||
find_package(MiniUPnPc REQUIRED) | |||||
set(MINIUPNPC_REQUIRED_HEADERS | |||||
miniupnpc/miniwget.h | |||||
miniupnpc/miniupnpc.h | |||||
miniupnpc/upnpcommands.h | |||||
miniupnpc/upnperrors.h | |||||
) | |||||
deadalnix: Shouldn't this be in the find mini upnp thing ? | |||||
FabienAuthorUnsubmitted Done Inline ActionsI was hesitant about this, but as long as there is no use case for the lib without these headers this should be fine to move it to the find file. Fabien: I was hesitant about this, but as long as there is no use case for the lib without these… | |||||
include(SanitizeHelper) | |||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNPC_INCLUDE_DIR}) | |||||
foreach(_miniupnpc_header ${MINIUPNPC_REQUIRED_HEADERS}) | |||||
sanitize_variable(HAVE_MINIUPNPC_ ${_miniupnpc_header} HEADER_FOUND) | |||||
deadalnixUnsubmitted Not Done Inline ActionsWhat is this doing ? deadalnix: What is this doing ? | |||||
FabienAuthorUnsubmitted Done Inline ActionsEnsuring the cache won't prevent the check to work Fabien: Ensuring the cache won't prevent the check to work | |||||
check_include_files(${_miniupnpc_header} ${HEADER_FOUND}) | |||||
if(NOT ${HEADER_FOUND}) | |||||
message(FATAL_ERROR "Could not find ${_miniupnpc_header}") | |||||
endif() | |||||
endforeach() | |||||
# 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(START_WITH_UPNP) | |||||
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)") | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou could simply wrap the #define USE_UNP in the config file so that it doesn't get defined when some other variable isn't istead of suing a bag of trick that's going to break once someone use a different version fo cmake or gcc. deadalnix: You could simply wrap the `#define USE_UNP` in the config file so that it doesn't get defined… | |||||
endif() | |||||
set(USE_UPNP ${USE_UPNP_VALUE} CACHE INTERNAL "UPnP is enabled") | |||||
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) |
Shouldn't this be in the find mini upnp thing ?