more dynamic miniupnp fixes

This commit is contained in:
fluffypony 2014-09-10 20:01:30 +02:00
parent 59c0423eae
commit 8d8b47e69f
3 changed files with 19 additions and 7 deletions

View file

@ -43,6 +43,14 @@ if (UNIX AND NOT APPLE)
find_package(Threads)
endif()
if(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER)
add_definitions("-DUPNP_DYNAMIC")
set(UPNP_LIBRARIES "miniupnpc")
else()
add_definitions("-DUPNP_STATIC")
set(UPNP_LIBRARIES "upnpc-static")
endif()
if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")

View file

@ -3,16 +3,15 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
if(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER)
message(STATUS "Using shared miniupnpc")
message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}")
include_directories(${MINIUPNP_INCLUDE_DIR})
set(UPNP_LIBRARIES "miniupnpc")
else()
message(STATUS "Using static miniupnpc from external")
add_subdirectory(miniupnpc)
set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library")
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables")
add_subdirectory(miniupnpc)
set_property(TARGET upnpc-static PROPERTY FOLDER "external")
if(MSVC)
@ -20,6 +19,4 @@ else()
elseif(NOT MSVC)
set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif()
set(UPNP_LIBRARIES "upnpc-static")
endif()

View file

@ -42,8 +42,15 @@
#include "net/local_ip.h"
#include "crypto/crypto.h"
#include "storages/levin_abstract_invoke2.h"
#include "miniupnpc.h"
#include "upnpcommands.h"
// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
#ifdef UPNP_STATIC
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#else
#include "miniupnpc.h"
#include "upnpcommands.h"
#endif
#define NET_MAKE_IP(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))