aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-06-04 13:44:32 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-08-16 19:27:40 +0100
commit6480e1dcdb03f43ce3d0aad96b8668d017d11750 (patch)
tree57683d60ae5a68c54d089694587d2827cddd778d /cmake
parente73e9304a11af65f9b086460ff349f9f700709ce (diff)
cmake: Add `libnatpmp` optional package support
Diffstat (limited to 'cmake')
-rw-r--r--cmake/module/FindNATPMP.cmake32
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/module/FindNATPMP.cmake b/cmake/module/FindNATPMP.cmake
new file mode 100644
index 0000000000..930555232b
--- /dev/null
+++ b/cmake/module/FindNATPMP.cmake
@@ -0,0 +1,32 @@
+# Copyright (c) 2023-present The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit/.
+
+find_path(NATPMP_INCLUDE_DIR
+ NAMES natpmp.h
+)
+
+find_library(NATPMP_LIBRARY
+ NAMES natpmp
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(NATPMP
+ REQUIRED_VARS NATPMP_LIBRARY NATPMP_INCLUDE_DIR
+)
+
+if(NATPMP_FOUND AND NOT TARGET NATPMP::NATPMP)
+ add_library(NATPMP::NATPMP UNKNOWN IMPORTED)
+ set_target_properties(NATPMP::NATPMP PROPERTIES
+ IMPORTED_LOCATION "${NATPMP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${NATPMP_INCLUDE_DIR}"
+ )
+ set_property(TARGET NATPMP::NATPMP PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS USE_NATPMP=1 $<$<PLATFORM_ID:Windows>:NATPMP_STATICLIB>
+ )
+endif()
+
+mark_as_advanced(
+ NATPMP_INCLUDE_DIR
+ NATPMP_LIBRARY
+)