- updated cmake system to support using NON EMBEDDED versions of libircclient and miniupnpc for proper build in Debian

This commit is contained in:
Mark Vejvoda
2011-05-27 06:37:43 +00:00
parent 718ff368ff
commit 1cf6d523fd
5 changed files with 164 additions and 3 deletions

View File

@@ -132,7 +132,6 @@ SET(DIRS_WITH_SRC
lua
map
platform/common
platform/miniupnpc
sound
sound/openal
streflop
@@ -140,6 +139,22 @@ SET(DIRS_WITH_SRC
util
xml)
IF(NOT WANT_STATIC_LIBS)
MESSAGE(STATUS "*** Searching for miniupnpc since WANT_STATIC_LIBS is off ...")
FIND_PACKAGE(Miniupnpc)
ENDIF()
if(NOT MINIUPNP_FOUND)
MESSAGE(STATUS "*** Using EMBEDDED miniupnpc since dev system does not have it... MINIUPNP_FOUND [${MINIUPNP_FOUND}]")
SET(DIRS_WITH_SRC ${DIRS_WITH_SRC} platform/miniupnpc)
else()
MESSAGE(STATUS "*** Using SHARED miniupnpc found in [${MINIUPNP_INCLUDE_DIR}] MINIUPNP_FOUND [${MINIUPNP_FOUND}] MINIUPNP_LIBRARY [${MINIUPNP_LIBRARY}]")
INCLUDE_DIRECTORIES(${MINIUPNP_INCLUDE_DIR})
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${MINIUPNP_LIBRARY})
endif()
IF(APPLE)
SET(DIRS_WITH_SRC ${DIRS_WITH_SRC} platform/sdl)
SET(DIRS_WITH_SRC ${DIRS_WITH_SRC} platform/posix)
@@ -160,8 +175,22 @@ SET(MG_INCLUDE_FILES "")
SET(MG_SOURCE_FILES "")
INCLUDE_DIRECTORIES( ${MG_INCLUDES_ROOT}platform/sdl )
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/libircclient/src/libircclient.c)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/libircclient/include)
IF(NOT WANT_STATIC_LIBS)
MESSAGE(STATUS "*** Searching for libircclient since WANT_STATIC_LIBS is off ...")
FIND_PACKAGE(Ircclient)
ENDIF()
if(NOT IRCCLIENT_FOUND)
MESSAGE(STATUS "*** Using EMBEDDED libircclient since dev system does not have it... IRCCLIENT_FOUND [${IRCCLIENT_FOUND}]")
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/libircclient/src/libircclient.c)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/libircclient/include)
else()
MESSAGE(STATUS "*** Using SHARED libircclient found in [${IRCCLIENT_INCLUDE_DIR}] IRCCLIENT_FOUND [${IRCCLIENT_FOUND}] IRCCLIENT_LIBRARY [${IRCCLIENT_LIBRARY}]")
INCLUDE_DIRECTORIES(${IRCCLIENT_INCLUDE_DIR})
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${IRCCLIENT_LIBRARY})
endif()
IF(WIN32)
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/posix/socket.cpp)

View File

@@ -8,6 +8,8 @@
#ifndef __MINIUPNPC_H__
#define __MINIUPNPC_H__
#define MEGAGLEST_EMBEDDED_MINIUPNPC
#include "declspec.h"
#include "igd_desc_parse.h"

View File

@@ -2142,7 +2142,11 @@ int UPNP_Tools::upnp_init(void *param) {
}
char externalIP[16] = "";
#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC
UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
#else
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
#endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"UPnP device found at: [%s] callback [%p]\n",externalIP,callback);
//UPNP_Tools::NETaddRedirects(ports);
@@ -2182,12 +2186,20 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2]) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] upnp_add_redir(%d : %d)\n",__FILE__,__FUNCTION__,__LINE__,ports[0],ports[1]);
#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC
UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
#else
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
#endif
sprintf(ext_port_str, "%d", ports[0]);
sprintf(int_port_str, "%d", ports[1]);
#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
#else
r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
#endif
if (r != UPNPCOMMAND_SUCCESS) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] AddPortMapping(%s, %s, %s) failed\n",__FILE__,__FUNCTION__,__LINE__,ext_port_str, int_port_str, lanaddr);
return false;
@@ -2202,7 +2214,11 @@ void UPNP_Tools::upnp_rem_redirect(int ext_port) {
char ext_port_str[16]="";
sprintf(ext_port_str, "%d", ext_port);
#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, ext_port_str, "TCP", 0);
#else
UPNP_DeletePortMapping(urls.controlURL, data.servicetype, ext_port_str, "TCP", 0);
#endif
}
void UPNP_Tools::NETaddRedirects(std::vector<int> UPNPPortForwardList) {