| 1 |
# This file only works for MiniUPnPc 1.7 or later (it requires MINIUPNPC_API_VERSION). |
| 2 |
# TODO Find out if any distribution still ships with /usr/include/miniupnpc.h (i.e. not in a separate directory). |
| 3 |
|
| 4 |
find_path(MINIUPNPC_INCLUDE_DIR miniupnpc.h PATH_SUFFIXES miniupnpc) |
| 5 |
find_library(MINIUPNPC_LIBRARY miniupnpc) |
| 6 |
|
| 7 |
if(MINIUPNPC_INCLUDE_DIR) |
| 8 |
file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_VERSION[\t ]+.*") |
| 9 |
if(MINIUPNPC_VERSION_STR) |
| 10 |
string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_VERSION[\t ]+\"([.0-9]+)\"" "\\1" MINIUPNPC_VERSION ${MINIUPNPC_VERSION_STR}) |
| 11 |
endif() |
| 12 |
endif() |
| 13 |
|
| 14 |
include(FindPackageHandleStandardArgs) |
| 15 |
find_package_handle_standard_args(MINIUPNPC |
| 16 |
REQUIRED_VARS MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY |
| 17 |
VERSION_VAR MINIUPNPC_VERSION |
| 18 |
) |
| 19 |
|
| 20 |
set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY}) |
| 21 |
set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR}) |
| 22 |
mark_as_advanced(MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY MINIUPNPC_API_VERSION_STR) |
| 23 |
|
| 24 |
if (MINIUPNPC_FOUND AND NOT TARGET miniupnpc) |
| 25 |
add_library(Miniupnpc::miniupnpc UNKNOWN IMPORTED) |
| 26 |
set_target_properties(Miniupnpc::miniupnpc PROPERTIES |
| 27 |
IMPORTED_LOCATION ${MINIUPNPC_LIBRARIES} |
| 28 |
INTERFACE_INCLUDE_DIRECTORIES ${MINIUPNPC_INCLUDE_DIRS} |
| 29 |
) |
| 30 |
endif() |