On linux check for a new enough system version of miniupnpc. Fall back
to building the version in the externals if it is not available.
This commit is contained in:
parent
44db305602
commit
1f6b70bf87
|
@ -523,17 +523,17 @@ if(NOT ANDROID)
|
||||||
else(SDL2_FOUND)
|
else(SDL2_FOUND)
|
||||||
# SDL2 not found, try SDL
|
# SDL2 not found, try SDL
|
||||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
include(FindSDL OPTIONAL)
|
include(FindSDL OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
if(SDL_FOUND)
|
if(SDL_FOUND)
|
||||||
message("Using shared SDL")
|
message("Using shared SDL")
|
||||||
include_directories(${SDL_INCLUDE_DIR})
|
include_directories(${SDL_INCLUDE_DIR})
|
||||||
else(SDL_FOUND)
|
else(SDL_FOUND)
|
||||||
# TODO: Use the prebuilt one on Windows
|
# TODO: Use the prebuilt one on Windows
|
||||||
message("Using static SDL from Externals")
|
message("Using static SDL from Externals")
|
||||||
include_directories(Externals/SDL/SDL Externals/SDL Externals/SDL/include)
|
include_directories(Externals/SDL/SDL Externals/SDL Externals/SDL/include)
|
||||||
add_subdirectory(Externals/SDL)
|
add_subdirectory(Externals/SDL)
|
||||||
endif(SDL_FOUND)
|
endif(SDL_FOUND)
|
||||||
endif(SDL2_FOUND)
|
endif(SDL2_FOUND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -552,9 +552,17 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_UPNP)
|
if(USE_UPNP)
|
||||||
message("Using static MiniUPnP client from Externals")
|
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ANDROID)
|
||||||
add_subdirectory(Externals/miniupnpc)
|
include(FindMiniupnpc)
|
||||||
include_directories(Externals/miniupnpc/src)
|
endif()
|
||||||
|
if(MINIUPNP_FOUND AND NOT MINIUPNPC_VERSION_PRE1_7)
|
||||||
|
message("Using shared miniupnpc")
|
||||||
|
include_directories(${MINIUPNP_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
message("Using static miniupnpc from Externals")
|
||||||
|
add_subdirectory(Externals/miniupnpc)
|
||||||
|
include_directories(Externals/miniupnpc/src)
|
||||||
|
endif()
|
||||||
add_definitions(-DUSE_UPNP)
|
add_definitions(-DUSE_UPNP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
# 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)
|
||||||
|
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)
|
||||||
|
message(STATUS "Found miniupnpc version is v1.7 or higher")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
else ()
|
||||||
|
message (STATUS "Could not find miniupnp")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY)
|
||||||
|
|
Loading…
Reference in New Issue