diff --git a/CMakeLists.txt b/CMakeLists.txt index 9614d702..3b07a96e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 481fbe9d..bf3dd601 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -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() diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index c2b39741..626e227b 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -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 + #include +#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))))