v29.4-roots.3 · Commit 1: [PATCH 01/30] build: port platform and dependency support
cmake/module/FindMiniUPnPc.cmake
Before: /dev/null · After: cmake/module/FindMiniUPnPc.cmake
File metadata
new file mode 100644 index 0000000000000000000000000000000000000000..34b94f05f16efbb87ad9e1b5029e1056a7dbea7d
Download original patch · Release notes
Diff rows 1–84 of 84. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
cmake/module/FindMiniUPnPc.cmake
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright (c) 2023-present The Bitcoin Core developers
|
|
2
|
+
# Distributed under the MIT software license, see the accompanying
|
|
3
|
+
# file COPYING or https://opensource.org/license/mit/.
|
|
4
|
+
|
|
5
|
+
if(NOT MSVC)
|
|
6
|
+
find_package(PkgConfig REQUIRED)
|
|
7
|
+
pkg_check_modules(PC_MiniUPnPc QUIET miniupnpc)
|
|
8
|
+
endif()
|
|
9
|
+
|
|
10
|
+
find_path(MiniUPnPc_INCLUDE_DIR
|
|
11
|
+
NAMES miniupnpc/miniupnpc.h
|
|
12
|
+
PATHS ${PC_MiniUPnPc_INCLUDE_DIRS}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if(MiniUPnPc_INCLUDE_DIR)
|
|
16
|
+
file(
|
|
17
|
+
STRINGS "${MiniUPnPc_INCLUDE_DIR}/miniupnpc/miniupnpc.h" version_strings
|
|
18
|
+
REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+"
|
|
19
|
+
)
|
|
20
|
+
string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)" "\\1" MiniUPnPc_API_VERSION "${version_strings}")
|
|
21
|
+
|
|
22
|
+
# The minimum supported miniUPnPc API version is set to 17. This excludes
|
|
23
|
+
# versions with known vulnerabilities.
|
|
24
|
+
if(MiniUPnPc_API_VERSION GREATER_EQUAL 17)
|
|
25
|
+
set(MiniUPnPc_API_VERSION_OK TRUE)
|
|
26
|
+
endif()
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
if(MSVC)
|
|
30
|
+
cmake_path(GET MiniUPnPc_INCLUDE_DIR PARENT_PATH MiniUPnPc_IMPORTED_PATH)
|
|
31
|
+
find_library(MiniUPnPc_LIBRARY_DEBUG
|
|
32
|
+
NAMES miniupnpc PATHS ${MiniUPnPc_IMPORTED_PATH}/debug/lib
|
|
33
|
+
NO_DEFAULT_PATH
|
|
34
|
+
)
|
|
35
|
+
find_library(MiniUPnPc_LIBRARY_RELEASE
|
|
36
|
+
NAMES miniupnpc PATHS ${MiniUPnPc_IMPORTED_PATH}/lib
|
|
37
|
+
NO_DEFAULT_PATH
|
|
38
|
+
)
|
|
39
|
+
set(MiniUPnPc_required MiniUPnPc_IMPORTED_PATH)
|
|
40
|
+
else()
|
|
41
|
+
find_library(MiniUPnPc_LIBRARY
|
|
42
|
+
NAMES miniupnpc
|
|
43
|
+
PATHS ${PC_MiniUPnPc_LIBRARY_DIRS}
|
|
44
|
+
)
|
|
45
|
+
set(MiniUPnPc_required MiniUPnPc_LIBRARY)
|
|
46
|
+
endif()
|
|
47
|
+
|
|
48
|
+
include(FindPackageHandleStandardArgs)
|
|
49
|
+
find_package_handle_standard_args(MiniUPnPc
|
|
50
|
+
REQUIRED_VARS ${MiniUPnPc_required} MiniUPnPc_INCLUDE_DIR MiniUPnPc_API_VERSION_OK
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if(MiniUPnPc_FOUND AND NOT TARGET MiniUPnPc::MiniUPnPc)
|
|
54
|
+
add_library(MiniUPnPc::MiniUPnPc UNKNOWN IMPORTED)
|
|
55
|
+
set_target_properties(MiniUPnPc::MiniUPnPc PROPERTIES
|
|
56
|
+
INTERFACE_INCLUDE_DIRECTORIES "${MiniUPnPc_INCLUDE_DIR}"
|
|
57
|
+
)
|
|
58
|
+
if(MSVC)
|
|
59
|
+
if(MiniUPnPc_LIBRARY_DEBUG)
|
|
60
|
+
set_property(TARGET MiniUPnPc::MiniUPnPc APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
|
61
|
+
set_target_properties(MiniUPnPc::MiniUPnPc PROPERTIES
|
|
62
|
+
IMPORTED_LOCATION_DEBUG "${MiniUPnPc_LIBRARY_DEBUG}"
|
|
63
|
+
)
|
|
64
|
+
endif()
|
|
65
|
+
if(MiniUPnPc_LIBRARY_RELEASE)
|
|
66
|
+
set_property(TARGET MiniUPnPc::MiniUPnPc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
67
|
+
set_target_properties(MiniUPnPc::MiniUPnPc PROPERTIES
|
|
68
|
+
IMPORTED_LOCATION_RELEASE "${MiniUPnPc_LIBRARY_RELEASE}"
|
|
69
|
+
)
|
|
70
|
+
endif()
|
|
71
|
+
else()
|
|
72
|
+
set_target_properties(MiniUPnPc::MiniUPnPc PROPERTIES
|
|
73
|
+
IMPORTED_LOCATION "${MiniUPnPc_LIBRARY}"
|
|
74
|
+
)
|
|
75
|
+
endif()
|
|
76
|
+
set_property(TARGET MiniUPnPc::MiniUPnPc PROPERTY
|
|
77
|
+
INTERFACE_COMPILE_DEFINITIONS USE_UPNP=1 $<$<PLATFORM_ID:Windows>:MINIUPNP_STATICLIB>
|
|
78
|
+
)
|
|
79
|
+
endif()
|
|
80
|
+
|
|
81
|
+
mark_as_advanced(
|
|
82
|
+
MiniUPnPc_INCLUDE_DIR
|
|
83
|
+
MiniUPnPc_LIBRARY
|
|
84
|
+
)
|