aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindMiniupnpc.cmake
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2014-10-07 00:21:40 +0200
committerRiccardo Spagni <ric@spagni.net>2014-10-07 00:21:53 +0200
commit6f65ab1904543f103c0187e2362604cc22f5d337 (patch)
treeff1a23128c9b2e326f97a9aad10251c25cbe3ff0 /cmake/FindMiniupnpc.cmake
parentMerge pull request #173 (diff)
parentadded hardcoded checkpoint at block 249380 (diff)
downloadmonero-6f65ab1904543f103c0187e2362604cc22f5d337.tar.xz
Merge pull request #175
b419075 added hardcoded checkpoint at block 249380 (Riccardo Spagni) 7c1d3b5 fixed miniupnpc dynamic target (Riccardo Spagni) 26728d9 mingw library tweaks (Riccardo Spagni) 2cf94c1 fix for mingw not playing nicely with libunbound configure, fix for correctly finding static libs on various operating systems (Riccardo Spagni) b05e27f need to link with -ldl on Linux when building statically (Riccardo Spagni) e55982a set the winsock variable differently on Windows (Riccardo Spagni) 0586a27 fixed configure_command for libunbound under mingw (Riccardo Spagni) f8fd036 turns out mingw does actually produce .a libs and not .dll.a (Riccardo Spagni) 6be3d1d added bison/yacc static build dependency (Riccardo Spagni) 1afba73 quieten CMake when it can't find packages (Riccardo Spagni) 735a017 removed required flags from miniupnp and unbound (Riccardo Spagni) 6b7ac4b enforce static libraries when building statically (Riccardo Spagni) 1d5991e include openssl in linbunbound static linking, added errors for openssl and expat (Riccardo Spagni) 6ef8ae8 reference the correct unbound static lib (Riccardo Spagni) 23cc93c added libtool's install command (Riccardo Spagni) 409e9ba use the correct CMake variable for static builds (Riccardo Spagni) 3a0b00a build libunbound correctly (Riccardo Spagni) 75a616f fix missing parentheses (Riccardo Spagni) 59172ee build libunbound from external if no local libunbound or for static builds (Riccardo Spagni) 1dee71a added static build dependency instructions to README (Riccardo Spagni) ff3a766 added static build dependency instructions to README (Riccardo Spagni) 5829b35 include openssl in linbunbound static linking, added errors for openssl and expat (Riccardo Spagni) c70fa86 reference the correct unbound static lib (Riccardo Spagni) 954a244 added libtool's install command (Riccardo Spagni) fd52015 use the correct CMake variable for static builds (Riccardo Spagni) cc0f6a6 build libunbound correctly (Riccardo Spagni) 8c00098 fix missing parentheses (Riccardo Spagni) cee8747 build libunbound from external if no local libunbound or for static builds (Riccardo Spagni) add1a60 added static build dependency instructions to README (Riccardo Spagni)
Diffstat (limited to 'cmake/FindMiniupnpc.cmake')
-rw-r--r--cmake/FindMiniupnpc.cmake185
1 files changed, 185 insertions, 0 deletions
diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake
new file mode 100644
index 000000000..0bf331da2
--- /dev/null
+++ b/cmake/FindMiniupnpc.cmake
@@ -0,0 +1,185 @@
+# --------------------------------- FindMiniupnpc Start ---------------------------------
+# Locate miniupnp library
+# This module defines
+# MINIUPNP_FOUND, if false, do not try to link to miniupnp
+# MINIUPNP_LIBRARY, the miniupnp variant
+# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
+# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is
+# pre 1.6
+# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is
+# pre 1.5
+#
+# Note that the expected include convention is
+# #include "miniupnpc.h"
+# and not
+# #include <miniupnpc/miniupnpc.h>
+# This is because, the miniupnpc location is not standardized and may exist
+# in locations other than miniupnpc/
+
+#=============================================================================
+# Copyright 2011 Mark Vejvoda
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
+ # Already in cache, be silent
+ set(MINIUPNP_FIND_QUIETLY TRUE)
+endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
+
+find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
+ PATH_SUFFIXES miniupnpc)
+find_library(MINIUPNP_LIBRARY miniupnpc)
+
+if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
+ set (MINIUPNP_FOUND TRUE)
+endif ()
+
+if (MINIUPNP_FOUND)
+ include(CheckCXXSourceRuns)
+ if (NOT MINIUPNP_FIND_QUIETLY)
+ message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}")
+ message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}")
+ endif (NOT MINIUPNP_FIND_QUIETLY)
+
+ message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}")
+
+ 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()
+ {
+ static struct UPNPUrls urls;
+ static struct IGDdatas data;
+
+ GetUPNPUrls (&urls, &data, \"myurl\",0);
+
+ return 0;
+ }"
+ 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("
+ #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, 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;
+ }"
+ MINIUPNPC_VERSION_PRE1_6)
+
+ ENDIF()
+
+ 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] = \"\";
+ UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
+
+ return 0;
+ }"
+ MINIUPNPC_VERSION_1_5_OR_HIGHER)
+ ENDIF()
+
+ 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("
+ #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.servicetype, externalIP);
+
+ return 0;
+ }"
+ MINIUPNPC_VERSION_PRE1_5)
+
+ENDIF()
+
+IF(MINIUPNPC_VERSION_PRE1_5)
+ message(STATUS "Found miniupnpc version is pre v1.5")
+ENDIF()
+IF(MINIUPNPC_VERSION_PRE1_6)
+ message(STATUS "Found miniupnpc version is pre v1.6")
+ENDIF()
+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)
+ IF(MINIUPNPC_VERSION_1_5_OR_HIGHER)
+ message(STATUS "Found miniupnpc version is v1.5 or higher")
+ ELSE()
+ message(STATUS "Found miniupnpc version is v1.7 or higher")
+ ENDIF()
+ENDIF()
+
+else ()
+ message (STATUS "Could not find miniupnp")
+endif ()
+
+MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY)
+# --------------------------------- FindMiniupnpc End --------------------------------- \ No newline at end of file