Page MenuHomePhabricator

D5450.diff
No OneTemporary

D5450.diff

diff --git a/cmake/modules/FindMiniUPnPc.cmake b/cmake/modules/FindMiniUPnPc.cmake
--- a/cmake/modules/FindMiniUPnPc.cmake
+++ b/cmake/modules/FindMiniUPnPc.cmake
@@ -1,47 +1,78 @@
-# Try to find libminiupnpc
-# MINIUPNPC_FOUND - system has libminiupnpc
-# MINIUPNPC_INCLUDE_DIR - the libminiupnpc include directory
-# MINIUPNPC_LIBRARY - Library needed to use libminiupnpc
-
-if (MINIUPNPC_INCLUDE_DIR AND MINIUPNPC_LIBRARY)
- # Already in cache, be silent
- set(MINIUPNPC_FIND_QUIETLY TRUE)
-endif()
+# Copyright (c) 2019-2020 The Bitcoin developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-find_path(MINIUPNPC_INCLUDE_DIR miniupnpc/miniupnpc.h)
+#.rst
+# FindMiniUPnPc
+# -------------
+#
+# Find the MiniUPnPc library. The following
+# components are available::
+# miniupnpc
+#
+# This will define the following variables::
+#
+# MiniUPnPc_FOUND - system has MiniUPnPc lib
+# MiniUPnPc_INCLUDE_DIRS - the MiniUPnPc include directories
+# MiniUPnPc_LIBRARIES - Libraries needed to use MiniUPnPc
+# MiniUPnPc_VERSION - The library version MAJOR.MINOR.PATCH
+#
+# And the following imported target::
+#
+# MiniUPnPc::miniupnpc
-if(MINIUPNPC_INCLUDE_DIR)
- set(MINIUPNPC_REQUIRED_HEADERS
- miniupnpc/miniwget.h
- miniupnpc/upnpcommands.h
- miniupnpc/upnperrors.h
- )
+include(BrewHelper)
+find_brew_prefix(BREW_HINT miniupnpc)
- include(SanitizeHelper)
- set(CMAKE_REQUIRED_INCLUDES ${MINIUPNPC_INCLUDE_DIR})
- foreach(_miniupnpc_header ${MINIUPNPC_REQUIRED_HEADERS})
- sanitize_variable(HAVE_MINIUPNPC_ ${_miniupnpc_header} HEADER_FOUND)
- check_include_files(${_miniupnpc_header} ${HEADER_FOUND})
- if(NOT ${HEADER_FOUND})
- set(MINIUPNPC_MISSING_HEADER ON)
- endif()
- endforeach()
-endif()
+find_package(PkgConfig)
+pkg_check_modules(PC_MiniUPnPc QUIET libqrencode)
-if(NOT MINIUPNPC_MISSING_HEADER)
- find_library(MINIUPNPC_LIBRARY NAMES miniupnpc libminiupnpc)
+find_path(MiniUPnPc_INCLUDE_DIR
+ NAMES miniupnpc.h
+ HINTS ${BREW_HINT}
+ PATHS ${PC_MiniUPnPc_INCLUDE_DIRS}
+ PATH_SUFFIXES miniupnpc
+)
- message(STATUS "MiniUPnPc lib: " ${MINIUPNPC_LIBRARY})
+set(MiniUPnPc_INCLUDE_DIRS "${MiniUPnPc_INCLUDE_DIR}")
+mark_as_advanced(MiniUPnPc_INCLUDE_DIR)
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(
- MiniUPnPc DEFAULT_MSG
- MINIUPNPC_INCLUDE_DIR
- MINIUPNPC_LIBRARY
+if(NOT DEFINED MiniUPnPc_VERSION)
+ # Extract version information from the miniupnpc.h header.
+ if(MiniUPnPc_INCLUDE_DIR)
+ # Read the version from file miniupnpc.h into a variable.
+ file(READ "${MiniUPnPc_INCLUDE_DIR}/miniupnpc.h" _MiniUPnPc_HEADER)
+
+ # Parse the version into variable.
+ string(REGEX REPLACE
+ ".*MINIUPNPC_VERSION[ \t]+\"([0-9]+\.[0-9]+(\.[0-9]+)?)\".*" "\\1"
+ MiniUPnPc_VERSION
+ "${_MiniUPnPc_HEADER}"
+ )
+ else()
+ # Set some garbage values to the versions since we didn't find a file to
+ # read.
+ set(MiniUPnPc_VERSION "0.0.0")
+ endif()
+
+ set(MiniUPnPc_VERSION "${MiniUPnPc_VERSION}"
+ CACHE INTERNAL "MiniUPnPc full version"
)
+endif()
- mark_as_advanced(MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY)
+include(ExternalLibraryHelper)
+find_component(MiniUPnPc miniupnpc
+ NAMES miniupnpc
+ HINTS ${BREW_HINT}
+ PATHS ${PC_MiniUPnPc_LIBRARY_DIRS}
+ PATH_SUFFIXES miniupnpc
+ INCLUDE_DIRS ${MiniUPnPc_INCLUDE_DIRS}
+)
- set(MiniUPnPc_LIBRARIES ${MINIUPNPC_LIBRARY})
- set(MiniUPnPc_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR})
-endif()
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MiniUPnPc
+ REQUIRED_VARS
+ MiniUPnPc_INCLUDE_DIR
+ VERSION_VAR MiniUPnPc_VERSION
+ HANDLE_COMPONENTS
+)
diff --git a/doc/dependencies.md b/doc/dependencies.md
--- a/doc/dependencies.md
+++ b/doc/dependencies.md
@@ -19,7 +19,7 @@
| libevent | [2.1.8-stable](https://github.com/libevent/libevent/releases) | 2.0.22 | No | | |
| libjpeg | | | | | Yes |
| libpng | | | | | Yes |
-| MiniUPnPc | [2.0.20170509](http://miniupnp.free.fr/files) | | No | | |
+| MiniUPnPc | [2.0.20170509](http://miniupnp.free.fr/files) | 1.5 | No | | |
| Ninja | | [1.5.1](https://github.com/ninja-build/ninja/releases) | | | |
| OpenSSL | [1.0.1k](https://www.openssl.org/source) | | Yes | | |
| PCRE | | | | | Yes |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -509,8 +509,8 @@
endif()
if(ENABLE_UPNP)
- target_include_directories(server PUBLIC ${MINIUPNPC_INCLUDE_DIR})
- target_link_libraries(server ${MINIUPNPC_LIBRARY})
+ find_package(MiniUPnPc 1.5 REQUIRED)
+ target_link_libraries(server MiniUPnPc::miniupnpc)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_library(IPHLPAPI_LIBRARY NAMES iphlpapi)
diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt
--- a/src/config/CMakeLists.txt
+++ b/src/config/CMakeLists.txt
@@ -216,8 +216,6 @@
# Try to find miniupnpc
if(ENABLE_UPNP)
- find_package(MiniUPnPc REQUIRED)
-
# The expected behavior is as follow:
# - If UPnP is enabled USE_UPNP must be defined
# - If UPnP should be the default port map method, USE_UPNP should be

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:28 (8 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187608
Default Alt Text
D5450.diff (5 KB)

Event Timeline