1# - Try to find libcares 2# Once done this will define 3# LIBCARES_FOUND - System has libcares 4# LIBCARES_INCLUDE_DIRS - The libcares include directories 5# LIBCARES_LIBRARIES - The libraries needed to use libcares 6 7find_package(PkgConfig QUIET) 8pkg_check_modules(PC_LIBCARES QUIET libcares) 9 10find_path(LIBCARES_INCLUDE_DIR 11 NAMES ares.h 12 HINTS ${PC_LIBCARES_INCLUDE_DIRS} 13) 14find_library(LIBCARES_LIBRARY 15 NAMES cares 16 HINTS ${PC_LIBCARES_LIBRARY_DIRS} 17) 18 19if(LIBCARES_INCLUDE_DIR) 20 set(_version_regex "^#define[ \t]+ARES_VERSION_STR[ \t]+\"([^\"]+)\".*") 21 file(STRINGS "${LIBCARES_INCLUDE_DIR}/ares_version.h" 22 LIBCARES_VERSION REGEX "${_version_regex}") 23 string(REGEX REPLACE "${_version_regex}" "\\1" 24 LIBCARES_VERSION "${LIBCARES_VERSION}") 25 unset(_version_regex) 26endif() 27 28include(FindPackageHandleStandardArgs) 29# handle the QUIETLY and REQUIRED arguments and set LIBCARES_FOUND to TRUE 30# if all listed variables are TRUE and the requested version matches. 31find_package_handle_standard_args(Libcares REQUIRED_VARS 32 LIBCARES_LIBRARY LIBCARES_INCLUDE_DIR 33 VERSION_VAR LIBCARES_VERSION) 34 35if(LIBCARES_FOUND) 36 set(LIBCARES_LIBRARIES ${LIBCARES_LIBRARY}) 37 set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR}) 38endif() 39 40mark_as_advanced(LIBCARES_INCLUDE_DIR LIBCARES_LIBRARY) 41