diff --git a/cmake/modules/FindMiniUPnPc.cmake b/cmake/modules/FindMiniUPnPc.cmake --- a/cmake/modules/FindMiniUPnPc.cmake +++ b/cmake/modules/FindMiniUPnPc.cmake @@ -69,6 +69,12 @@ INCLUDE_DIRS ${MiniUPnPc_INCLUDE_DIRS} ) +set(_MiniUPnPc_WINDOWS_LIBRARIES "$<$:ws2_32;iphlpapi>") +set_property(TARGET MiniUPnPc::miniupnpc + PROPERTY INTERFACE_LINK_LIBRARIES ${_MiniUPnPc_WINDOWS_LIBRARIES} +) +list(APPEND _MiniUPnPc_LIBRARIES ${_MiniUPnPc_WINDOWS_LIBRARIES}) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MiniUPnPc REQUIRED_VARS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -528,12 +528,9 @@ target_link_libraries(server MiniUPnPc::miniupnpc) if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - find_library(IPHLPAPI_LIBRARY NAMES iphlpapi) - if(NOT IPHLPAPI_LIBRARY) - message(FATAL_ERROR "Lib iphlpapi is missing") - endif() - target_link_libraries(server ${IPHLPAPI_LIBRARY}) - + # TODO: check if we are really using a static library. Assume this is + # the one from the depends for now since the native windows build is not + # supported. target_compile_definitions(server PUBLIC -DSTATICLIB PUBLIC -DMINIUPNP_STATICLIB