diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ffdaeb55ed..d77a1d68906 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -643,7 +643,7 @@ function (monero_add_library name) endfunction() function (monero_add_library_with_deps) - cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN}) + cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;LINKS;PRIVATE_LINKS;INCLUDES;PRIVATE_INCLUDES;SOURCES" ${ARGN}) source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES}) # Define a ("virtual") object library and an actual library that links those @@ -658,6 +658,22 @@ function (monero_add_library_with_deps) if (MONERO_ADD_LIBRARY_DEPENDS) add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS}) endif() + if (MONERO_ADD_LIBRARY_LINKS) + target_link_libraries(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_LINKS}) + target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_LINKS}) + endif() + if (MONERO_ADD_LIBRARY_PRIVATE_LINKS) + target_link_libraries(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS}) + target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS}) + endif() + if (MONERO_ADD_LIBRARY_INCLUDES) + target_include_directories(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES}) + target_include_directories(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES}) + endif() + if (MONERO_ADD_LIBRARY_PRIVATE_INCLUDES) + target_include_directories(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES}) + target_include_directories(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES}) + endif() set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs") target_compile_definitions(${objlib} PRIVATE $) diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake deleted file mode 100644 index ad2004afcca..00000000000 --- a/cmake/FindMiniupnpc.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# --------------------------------- FindMiniupnpc Start --------------------------------- -# 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) -# MINIUPNPC_VERSION_1_7_OR_HIGHER, set if we detect the version of miniupnpc is 1.7 or higher -# -# Note that the expected include convention is -# #include "miniupnpc.h" -# and not -# #include -# This is because, the miniupnpc location is not standardized and may exist -# in locations other than miniupnpc/ - -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - # Already in cache, be silent - set(MINIUPNP_FIND_QUIETLY TRUE) -endif () - -find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h - HINTS $ENV{MINIUPNP_INCLUDE_DIR} - PATH_SUFFIXES miniupnpc -) - -find_library(MINIUPNP_LIBRARY miniupnpc - HINTS $ENV{MINIUPNP_LIBRARY} -) - -find_library(MINIUPNP_STATIC_LIBRARY libminiupnpc.a - HINTS $ENV{MINIUPNP_STATIC_LIBRARY} -) - -set(MINIUPNP_INCLUDE_DIRS ${MINIUPNP_INCLUDE_DIR}) -set(MINIUPNP_LIBRARIES ${MINIUPNP_LIBRARY}) -set(MINIUPNP_STATIC_LIBRARIES ${MINIUPNP_STATIC_LIBRARY}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - MiniUPnPc DEFAULT_MSG - MINIUPNP_INCLUDE_DIR - MINIUPNP_LIBRARY -) - -IF(MINIUPNPC_FOUND) - file(STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+") - if(MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)") - set(MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}") - if (${MINIUPNPC_API_VERSION} GREATER "10" OR ${MINIUPNPC_API_VERSION} EQUAL "10") - message(STATUS "Found miniupnpc API version " ${MINIUPNPC_API_VERSION}) - set(MINIUPNP_FOUND true) - set(MINIUPNPC_VERSION_1_7_OR_HIGHER true) - endif() - endif() - -ENDIF() - -mark_as_advanced(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY) -# --------------------------------- FindMiniupnpc End --------------------------------- diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 8deadc7ba63..5010e68f39c 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -35,10 +35,13 @@ # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # others. -find_package(Miniupnpc REQUIRED) +if(NOT MSVC) + add_compile_options(-D_GNU_SOURCE) +endif() message(STATUS "Using in-tree miniupnpc") set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE) +set(UPNPC_BUILD_TESTS FALSE CACHE BOOL "Disable miniupnp internal tests." FORCE) add_subdirectory(miniupnp/miniupnpc) set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external") set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/external/miniupnp b/external/miniupnp index 544e6fcc73c..b55145ec095 160000 --- a/external/miniupnp +++ b/external/miniupnp @@ -1 +1 @@ -Subproject commit 544e6fcc73c5ad9af48a8985c94f0f1d742ef2e0 +Subproject commit b55145ec095652289a59c33603f3abafee898273 diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 505ba026ea3..50d2063ea35 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -58,9 +58,9 @@ #include "cryptonote_core/cryptonote_core.h" #include "net/parse.h" -#include -#include -#include +#include +#include +#include #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p" @@ -2985,7 +2985,8 @@ namespace nodetool UPNPUrls urls; IGDdatas igdData; char lanAddress[64]; - result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress); + char wanaddr[64]; /* up address of the IGD on the WAN */ + result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanaddr, sizeof wanaddr); freeUPNPDevlist(deviceList); if (result > 0) { if (result == 1) { @@ -3053,7 +3054,8 @@ namespace nodetool UPNPUrls urls; IGDdatas igdData; char lanAddress[64]; - result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress); + char wanaddr[64]; /* up address of the IGD on the WAN */ + result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanaddr, sizeof wanaddr); freeUPNPDevlist(deviceList); if (result > 0) { if (result == 1) { diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index fe80d3083e3..beb27b46d18 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -96,12 +96,31 @@ monero_private_headers(daemon_rpc_server monero_add_library(rpc_base ${rpc_base_sources} ${rpc_base_headers} - ${rpc_base_private_headers}) + ${rpc_base_private_headers} + LINKS + common + epee + ${Boost_REGEX_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + PRIVATE_LINKS + ${EXTRA_LIBRARIES}) monero_add_library(rpc ${rpc_sources} ${rpc_headers} - ${rpc_private_headers}) + ${rpc_private_headers} + LINKS + rpc_base + common + cryptonote_core + cryptonote_protocol + net + version + ${Boost_REGEX_LIBRARY} + ${Boost_THREAD_LIBRARY} + PRIVATE_LINKS + ${EXTRA_LIBRARIES}) monero_add_library(rpc_pub ${rpc_pub_sources} @@ -118,30 +137,6 @@ monero_add_library(daemon_rpc_server ${daemon_rpc_server_headers} ${daemon_rpc_server_private_headers}) - -target_link_libraries(rpc_base - PUBLIC - common - epee - ${Boost_REGEX_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - PRIVATE - ${EXTRA_LIBRARIES}) - -target_link_libraries(rpc - PUBLIC - rpc_base - common - cryptonote_core - cryptonote_protocol - net - version - ${Boost_REGEX_LIBRARY} - ${Boost_THREAD_LIBRARY} - PRIVATE - ${EXTRA_LIBRARIES}) - target_link_libraries(rpc_pub PUBLIC epee