- 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

@ -0,0 +1,64 @@
# Locate ircclient library
# This module defines
# IRCCLIENT_FOUND, if false, do not try to link to IRCCLIENT
# IRCCLIENT_LIBRARY, the libircclient variant
# IRCCLIENT_INCLUDE_DIR, where to find libircclient.h and family)
#
# Note that the expected include convention is
# #include "libircclient.h"
# and not
# #include <libircclient/libircclient.h>
# This is because, the ircclient location is not standardized and may exist
# in locations other than libircclient/
#=============================================================================
# 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.)
FIND_PATH(IRCCLIENT_INCLUDE_DIR libircclient.h
HINTS
$ENV{IRCCLIENTDIR}
PATH_SUFFIXES include/libircclient include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
FIND_LIBRARY(IRCCLIENT_LIBRARY
NAMES ircclient
HINTS
$ENV{IRCCLIENTDIR}
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)
# handle the QUIETLY and REQUIRED arguments and set IRCCLIENT_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IRCCLIENT DEFAULT_MSG IRCCLIENT_LIBRARY IRCCLIENT_INCLUDE_DIR)
MARK_AS_ADVANCED(IRCCLIENT_LIBRARY IRCCLIENT_INCLUDE_DIR)

View File

@ -0,0 +1,50 @@
# 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)
#
# 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)
else ()
message (STATUS "Could not find miniupnp")
endif ()
MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY)

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) {