Build: update CMake and p2p for in-tree miniupnp

(cherry picked from commit a7366b5feeffaeb65b217b2d6f138e0ab1c90192)
This commit is contained in:
anonimal 2018-04-21 09:30:55 +00:00
parent 859db52fda
commit 6b85398031
No known key found for this signature in database
GPG key ID: 66A76ECF914409F1
3 changed files with 16 additions and 52 deletions

View file

@ -430,14 +430,6 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
add_subdirectory(external) add_subdirectory(external)
# Final setup for miniupnpc
if(UPNP_STATIC OR IOS)
add_definitions("-DUPNP_STATIC")
else()
add_definitions("-DUPNP_DYNAMIC")
include_directories(${UPNP_INCLUDE})
endif()
# Final setup for libunbound # Final setup for libunbound
include_directories(${UNBOUND_INCLUDE}) include_directories(${UNBOUND_INCLUDE})
link_directories(${UNBOUND_LIBRARY_DIRS}) link_directories(${UNBOUND_LIBRARY_DIRS})

View file

@ -34,29 +34,10 @@
# We always compile if we are building statically to reduce static dependency issues... # We always compile if we are building statically to reduce static dependency issues...
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
# others. # others.
if(NOT IOS)
find_package(Miniupnpc QUIET)
endif()
# If we have the correct shared version and we're not building static, use it find_package(Miniupnpc REQUIRED)
if(STATIC OR IOS)
set(USE_SHARED_MINIUPNPC false)
elseif(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER)
set(USE_SHARED_MINIUPNPC true)
endif()
if(USE_SHARED_MINIUPNPC) message(STATUS "Using in-tree miniupnpc")
message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}")
set(UPNP_STATIC false PARENT_SCOPE)
set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE)
set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE)
else()
if(STATIC)
message(STATUS "Using miniupnpc from local source tree for static build")
else()
message(STATUS "Using miniupnpc from local source tree (/external/miniupnp/miniupnpc)")
endif()
add_subdirectory(miniupnp/miniupnpc) add_subdirectory(miniupnp/miniupnpc)
@ -67,9 +48,7 @@ else()
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif() endif()
set(UPNP_STATIC true PARENT_SCOPE)
set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE) set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
endif()
find_package(Unbound) find_package(Unbound)

View file

@ -49,16 +49,9 @@
#include "storages/levin_abstract_invoke2.h" #include "storages/levin_abstract_invoke2.h"
#include "cryptonote_core/cryptonote_core.h" #include "cryptonote_core/cryptonote_core.h"
// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
#ifdef UPNP_STATIC
#include <miniupnp/miniupnpc/miniupnpc.h> #include <miniupnp/miniupnpc/miniupnpc.h>
#include <miniupnp/miniupnpc/upnpcommands.h> #include <miniupnp/miniupnpc/upnpcommands.h>
#include <miniupnp/miniupnpc/upnperrors.h> #include <miniupnp/miniupnpc/upnperrors.h>
#else
#include "miniupnpc.h"
#include "upnpcommands.h"
#include "upnperrors.h"
#endif
#undef MONERO_DEFAULT_LOG_CATEGORY #undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p" #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"