107 lines
3.7 KiB
Diff
107 lines
3.7 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index b05c087cf..4f1a20101 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -676,6 +676,14 @@ ExternalProject_Add(generate_translations_header
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
|
|
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
|
|
include_directories(${UNBOUND_INCLUDE_DIR})
|
|
|
|
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
|
|
index 5b7f69a56..00ef3f43d 100644
|
|
--- a/external/CMakeLists.txt
|
|
+++ b/external/CMakeLists.txt
|
|
@@ -34,24 +34,47 @@
|
|
# 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
|
|
# others.
|
|
+if(NOT IOS)
|
|
+ find_package(Miniupnpc QUIET)
|
|
+endif()
|
|
|
|
-find_package(Miniupnpc REQUIRED)
|
|
-
|
|
-message(STATUS "Using in-tree miniupnpc")
|
|
set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE)
|
|
-add_subdirectory(miniupnp/miniupnpc)
|
|
-set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
|
|
-set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
-if(MSVC)
|
|
- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
|
|
-elseif(NOT MSVC)
|
|
- set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
|
|
+# If we have the correct shared version and we're not building static, use it
|
|
+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 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)
|
|
+
|
|
+ set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
|
|
+ if(MSVC)
|
|
+ set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
|
|
+ elseif(NOT MSVC)
|
|
+ set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
|
|
+ endif()
|
|
+
|
|
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
|
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE")
|
|
endif()
|
|
|
|
-set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
|
|
+ set(UPNP_STATIC true PARENT_SCOPE)
|
|
+ set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
|
|
+endif()
|
|
|
|
find_package(Unbound)
|
|
|
|
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
|
|
index f33ce977d..87d23a1e1 100644
|
|
--- a/src/p2p/net_node.inl
|
|
+++ b/src/p2p/net_node.inl
|
|
@@ -60,9 +60,16 @@
|
|
#include "cryptonote_core/cryptonote_core.h"
|
|
#include "net/parse.h"
|
|
|
|
-#include <miniupnp/miniupnpc/miniupnpc.h>
|
|
-#include <miniupnp/miniupnpc/upnpcommands.h>
|
|
-#include <miniupnp/miniupnpc/upnperrors.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/upnpcommands.h>
|
|
+ #include <miniupnp/miniupnpc/upnperrors.h>
|
|
+#else
|
|
+ #include "miniupnpc.h"
|
|
+ #include "upnpcommands.h"
|
|
+ #include "upnperrors.h"
|
|
+#endif
|
|
|
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"
|