summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/monero-use-system-miniupnpc.patch
blob: 6bc825d121258fb340f1a819743e810960b8bcc6 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
This reverts commit 1e20d705e7c64d2b17c031f345057d1e8850fafa, so that it's possible to use our own
miniupnpc, instead of a git submodule.
---
 CMakeLists.txt          |  8 ++++++++
 external/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++----------
 src/p2p/net_node.inl    | 13 ++++++++++---
 3 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b93988e..ef948885 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -430,6 +430,14 @@ 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})
 link_directories(${UNBOUND_LIBRARY_DIRS})
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index 1fc4d64c..b4f712ee 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -34,21 +34,42 @@
 # 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)
+# 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()
 
-message(STATUS "Using in-tree miniupnpc")
+if(USE_SHARED_MINIUPNPC)
+  message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}")
 
-add_subdirectory(miniupnp/miniupnpc)
+  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()
 
-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()
+  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()
 
-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 9b21705e..76340a22 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -49,9 +49,16 @@
 #include "storages/levin_abstract_invoke2.h"
 #include "cryptonote_core/cryptonote_core.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"
-- 
2.16.2