$OpenBSD: patch-mk_cmake_Modules_FindMiniupnpc_cmake,v 1.2 2014/02/03 15:20:45 dcoppa Exp $

Unbreak build with miniupnpc>1.7
(from upstream SVN revision 3958)

--- mk/cmake/Modules/FindMiniupnpc.cmake.orig	Tue Jun  5 23:45:54 2012
+++ mk/cmake/Modules/FindMiniupnpc.cmake	Mon Feb  3 16:03:38 2014
@@ -58,20 +58,16 @@ if (MINIUPNP_FOUND)
     #include <stdio.h>
     int main()
     {
-        struct UPNPDev *devlist = NULL;
-	int upnp_delay = 5000;
-	const char *upnp_multicastif = NULL;
-	const char *upnp_minissdpdsock = NULL;
-	int upnp_sameport = 0;
-	int upnp_ipv6 = 0;
-	int upnp_error = 0;
-	devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error);
+        static struct UPNPUrls urls;
+        static struct IGDdatas data;
 
+        GetUPNPUrls (&urls, &data, \"myurl\",0);
+
         return 0;
     }"
-   MINIUPNPC_VERSION_1_6_OR_HIGHER)
-    
-   IF (NOT MINIUPNPC_VERSION_1_6_OR_HIGHER)
+   MINIUPNPC_VERSION_1_7_OR_HIGHER)
+
+  IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
           set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
           set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
           check_cxx_source_runs("
@@ -88,6 +84,30 @@ if (MINIUPNP_FOUND)
 	        int upnp_sameport = 0;
 	        int upnp_ipv6 = 0;
 	        int upnp_error = 0;
+	        devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error);
+
+                return 0;
+            }"
+           MINIUPNPC_VERSION_PRE1_7)
+   ENDIF()
+ 
+   IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
+          set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
+          set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
+          check_cxx_source_runs("
+            #include <miniwget.h>
+            #include <miniupnpc.h>
+            #include <upnpcommands.h>
+            #include <stdio.h>
+            int main()
+            {
+                struct UPNPDev *devlist = NULL;
+	        int upnp_delay = 5000;
+	        const char *upnp_multicastif = NULL;
+	        const char *upnp_minissdpdsock = NULL;
+	        int upnp_sameport = 0;
+	        int upnp_ipv6 = 0;
+	        int upnp_error = 0;
 	        devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport);
 
                 return 0;
@@ -96,25 +116,28 @@ if (MINIUPNP_FOUND)
 
    ENDIF()
 
-   set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
-   set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
-   check_cxx_source_runs("
-    #include <miniwget.h>
-    #include <miniupnpc.h>
-    #include <upnpcommands.h>
-    #include <stdio.h>
-    static struct UPNPUrls urls;
-    static struct IGDdatas data;
-    int main()
-    {
-        char externalIP[16]     = "";
-	UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
+   IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
+           set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
+           set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
+           check_cxx_source_runs("
+            #include <miniwget.h>
+            #include <miniupnpc.h>
+            #include <upnpcommands.h>
+            #include <stdio.h>
+            static struct UPNPUrls urls;
+            static struct IGDdatas data;
+            int main()
+            {
+	        char externalIP[16];
+	        externalIP[0] = '\0';
+	        UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
 
-        return 0;
-    }"
-    MINIUPNPC_VERSION_1_5_OR_HIGHER)
+                return 0;
+            }"
+            MINIUPNPC_VERSION_1_5_OR_HIGHER)
+    ENDIF()
 
-    IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER)
+    IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
          set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
          set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
          check_cxx_source_runs("
@@ -126,7 +149,8 @@ if (MINIUPNP_FOUND)
             static struct IGDdatas data;
             int main()
             {
-                char externalIP[16]     = "";
+	        char externalIP[16];
+	        externalIP[0] = '\0';
 	        UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
 
                 return 0;
@@ -141,8 +165,12 @@ if (MINIUPNP_FOUND)
     IF(MINIUPNPC_VERSION_PRE1_6)
 	message(STATUS "Found miniupnpc version is pre v1.6")
     ENDIF()
-    IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6)
-	message(STATUS "Found miniupnpc version is v1.6 or higher")
+    IF(MINIUPNPC_VERSION_PRE1_7)
+	message(STATUS "Found miniupnpc version is pre v1.7")
+    ENDIF()
+
+    IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7)
+	message(STATUS "Found miniupnpc version is v1.7 or higher")
     ENDIF()
 
 else ()
