2016-10-16 21:13:18 +00:00
|
|
|
# - Try to find resolv
|
|
|
|
# Once done this will define
|
|
|
|
#
|
|
|
|
# RESOLV_FOUND - system has resolv
|
|
|
|
# RESOLV_INCLUDES - the resolv include directory
|
2019-11-25 05:56:32 +00:00
|
|
|
# RESOLV_LIBRARIES - the libraries needed to use resolv
|
2020-03-28 20:02:41 +00:00
|
|
|
# RESOLV_THREAD_SAFE - resolv has thread-safe functions (res_ninit/res_nclose)
|
2016-10-16 21:13:18 +00:00
|
|
|
#
|
2020-01-28 18:56:52 +00:00
|
|
|
# Copyright (c) 2016-2020, Ivailo Monev, <xakepa10@gmail.com>
|
2016-10-16 21:13:18 +00:00
|
|
|
#
|
|
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
|
|
|
|
|
|
# resolv does not provide pkg-config files
|
|
|
|
|
2020-12-03 16:33:21 +00:00
|
|
|
include(CMakePushCheckState)
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
2020-04-02 05:57:31 +00:00
|
|
|
set(RESOLV_NAMES c resolv)
|
2020-03-28 20:02:41 +00:00
|
|
|
|
2016-10-16 21:13:18 +00:00
|
|
|
find_path(RESOLV_INCLUDES
|
2020-02-10 21:21:33 +00:00
|
|
|
NAMES resolv.h
|
|
|
|
HINTS $ENV{RESOLVDIR}/include
|
2016-10-16 21:13:18 +00:00
|
|
|
)
|
|
|
|
|
2020-03-28 20:02:41 +00:00
|
|
|
set(RESOLV_LIBRARIES)
|
|
|
|
foreach(name ${RESOLV_NAMES})
|
2020-11-27 23:23:27 +00:00
|
|
|
if(NOT RESOLV_LIBRARIES)
|
2020-11-30 05:19:36 +00:00
|
|
|
unset(HAVE_res_ninit CACHE)
|
2020-03-28 20:02:41 +00:00
|
|
|
cmake_reset_check_state()
|
2020-04-02 05:57:31 +00:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${name})
|
2020-12-01 16:15:35 +00:00
|
|
|
katie_check_defined(res_ninit "netinet/in.h;resolv.h")
|
2020-11-27 23:23:27 +00:00
|
|
|
cmake_reset_check_state()
|
2020-03-28 20:02:41 +00:00
|
|
|
if(NOT HAVE_res_ninit)
|
2020-11-30 05:19:36 +00:00
|
|
|
unset(HAVE_res_init CACHE)
|
2020-03-28 20:02:41 +00:00
|
|
|
cmake_reset_check_state()
|
2020-04-02 05:57:31 +00:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${name})
|
2020-12-01 16:15:35 +00:00
|
|
|
katie_check_defined(res_init "netinet/in.h;resolv.h")
|
2020-11-27 23:23:27 +00:00
|
|
|
cmake_reset_check_state()
|
2020-03-28 20:02:41 +00:00
|
|
|
endif()
|
|
|
|
if(HAVE_res_ninit OR HAVE_res_init)
|
|
|
|
find_library(RESOLV_LIBRARIES
|
|
|
|
NAMES ${name}
|
|
|
|
HINTS $ENV{RESOLVDIR}/lib
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-10-16 21:13:18 +00:00
|
|
|
|
2019-07-30 12:04:33 +00:00
|
|
|
find_package_handle_standard_args(Resolv
|
2019-12-25 18:29:33 +00:00
|
|
|
REQUIRED_VARS RESOLV_LIBRARIES RESOLV_INCLUDES
|
2019-07-30 12:04:33 +00:00
|
|
|
)
|
2016-10-16 21:13:18 +00:00
|
|
|
|
2020-03-28 20:02:41 +00:00
|
|
|
set(RESOLV_THREAD_SAFE "${HAVE_res_ninit}" CACHE BOOL "resolv has thread-safe functions (res_ninit/res_nclose)")
|
|
|
|
|
|
|
|
mark_as_advanced(RESOLV_INCLUDES RESOLV_LIBRARIES RESOLV_THREAD_SAFE)
|