FindMINIUPNPC.cmake 1.2 KB

12345678910111213141516171819202122232425262728293031
  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. find_path(MINIUPNPC_INCLUDE_DIR miniupnpc.h PATH_SUFFIXES miniupnpc)
  4. find_library(MINIUPNPC_LIBRARY miniupnpc)
  5. if(MINIUPNPC_INCLUDE_DIR)
  6. file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_VERSION[\t ]+.*")
  7. if(MINIUPNPC_VERSION_STR)
  8. string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_VERSION[\t ]+\"([.0-9]+)\"" "\\1" MINIUPNPC_VERSION ${MINIUPNPC_VERSION_STR})
  9. endif()
  10. endif()
  11. include(FindPackageHandleStandardArgs)
  12. find_package_handle_standard_args(MINIUPNPC
  13. REQUIRED_VARS MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY
  14. VERSION_VAR MINIUPNPC_VERSION
  15. )
  16. set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY})
  17. set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR})
  18. mark_as_advanced(MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY MINIUPNPC_API_VERSION_STR)
  19. if (MINIUPNPC_FOUND AND NOT TARGET miniupnpc)
  20. add_library(Miniupnpc::miniupnpc UNKNOWN IMPORTED)
  21. set_target_properties(Miniupnpc::miniupnpc PROPERTIES
  22. IMPORTED_LOCATION ${MINIUPNPC_LIBRARIES}
  23. INTERFACE_INCLUDE_DIRECTORIES ${MINIUPNPC_INCLUDE_DIRS}
  24. )
  25. endif()