From 2971e639b7abf0b6edb28423333db701e9e656a7 Mon Sep 17 00:00:00 2001 From: anonimal Date: Thu, 19 Apr 2018 08:47:10 +0000 Subject: [PATCH] CMake: update new location of in-tree miniupnpc --- external/CMakeLists.txt | 26 ++++++++++++++++++++------ src/p2p/net_node.inl | 13 ++++++++++--- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 1fc4d64c1..4aa2c0ebf 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -39,13 +39,27 @@ find_package(Miniupnpc REQUIRED) message(STATUS "Using in-tree miniupnpc") -add_subdirectory(miniupnp/miniupnpc) + set(UPNP_STATIC false PARENT_SCOPE) + set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE) + set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE) +else() + if(STATIC) + message(STATUS "Using miniupnpc from local source tree for static build") + else() + message(STATUS "Using miniupnpc from local source tree (/external/miniupnp/miniupnpc)") + endif() -set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external") -if(MSVC) - set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") -elseif(NOT MSVC) - set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") + add_subdirectory(miniupnp/miniupnpc) + + set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external") + if(MSVC) + set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") + elseif(NOT MSVC) + set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") + endif() + + set(UPNP_STATIC true PARENT_SCOPE) + set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE) endif() set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE) diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 17dcd8ef1..672850b36 100755 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -49,9 +49,16 @@ #include "storages/levin_abstract_invoke2.h" #include "cryptonote_core/cryptonote_core.h" -#include -#include -#include +// We have to look for miniupnpc headers in different places, dependent on if its compiled or external +#ifdef UPNP_STATIC + #include + #include + #include +#else + #include "miniupnpc.h" + #include "upnpcommands.h" + #include "upnperrors.h" +#endif #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"