aboutsummaryrefslogtreecommitdiff
path: root/cmake/module/FindNATPMP.cmake
blob: 930555232bd86387627798cc51c04ec0dc1abeee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
)