Add libc-ares detection to cmake
This commit is contained in:
parent
264a98d106
commit
d66d34f9b9
|
@ -59,6 +59,7 @@ find_package(PythonInterp)
|
||||||
# Auto-detection of features that can be toggled
|
# Auto-detection of features that can be toggled
|
||||||
find_package(OpenSSL 1.0.1)
|
find_package(OpenSSL 1.0.1)
|
||||||
find_package(Libev 4.11)
|
find_package(Libev 4.11)
|
||||||
|
find_package(Libcares 1.7.5)
|
||||||
find_package(ZLIB 1.2.3)
|
find_package(ZLIB 1.2.3)
|
||||||
if(OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND)
|
if(OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND)
|
||||||
set(ENABLE_APP_DEFAULT ON)
|
set(ENABLE_APP_DEFAULT ON)
|
||||||
|
@ -207,6 +208,14 @@ if(LIBEVENT_FOUND)
|
||||||
# Must both link the core and openssl libraries.
|
# Must both link the core and openssl libraries.
|
||||||
set(LIBEVENT_OPENSSL_LIBRARIES ${LIBEVENT_LIBRARIES})
|
set(LIBEVENT_OPENSSL_LIBRARIES ${LIBEVENT_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
# libc-ares (for src)
|
||||||
|
set(HAVE_LIBCARES ${LIBCARES_FOUND})
|
||||||
|
if(LIBCARES_FOUND)
|
||||||
|
set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
set(LIBCARES_INCLUDE_DIRS "")
|
||||||
|
set(LIBCARES_LIBRARIES "")
|
||||||
|
endif()
|
||||||
# jansson (for src/nghttp, src/deflatehd and src/inflatehd)
|
# jansson (for src/nghttp, src/deflatehd and src/inflatehd)
|
||||||
set(HAVE_JANSSON ${JANSSON_FOUND})
|
set(HAVE_JANSSON ${JANSSON_FOUND})
|
||||||
# libxml2 (for src/nghttp)
|
# libxml2 (for src/nghttp)
|
||||||
|
@ -499,6 +508,7 @@ message(STATUS "summary of build options:
|
||||||
OpenSSL: ${HAVE_OPENSSL} (LIBS='${OPENSSL_LIBRARIES}')
|
OpenSSL: ${HAVE_OPENSSL} (LIBS='${OPENSSL_LIBRARIES}')
|
||||||
Libxml2: ${HAVE_LIBXML2} (LIBS='${LIBXML2_LIBRARIES}')
|
Libxml2: ${HAVE_LIBXML2} (LIBS='${LIBXML2_LIBRARIES}')
|
||||||
Libev: ${HAVE_LIBEV} (LIBS='${LIBEV_LIBRARIES}')
|
Libev: ${HAVE_LIBEV} (LIBS='${LIBEV_LIBRARIES}')
|
||||||
|
Libc-ares: ${HAVE_LIBCARES} (LIBS='${LIBCARES_LIBRARIES}')
|
||||||
Libevent(SSL): ${HAVE_LIBEVENT_OPENSSL} (LIBS='${LIBEVENT_OPENSSL_LIBRARIES}')
|
Libevent(SSL): ${HAVE_LIBEVENT_OPENSSL} (LIBS='${LIBEVENT_OPENSSL_LIBRARIES}')
|
||||||
Spdylay: ${HAVE_SPDYLAY} (LIBS='${SPDYLAY_LIBRARIES}')
|
Spdylay: ${HAVE_SPDYLAY} (LIBS='${SPDYLAY_LIBRARIES}')
|
||||||
Jansson: ${HAVE_JANSSON} (LIBS='${JANSSON_LIBRARIES}')
|
Jansson: ${HAVE_JANSSON} (LIBS='${JANSSON_LIBRARIES}')
|
||||||
|
|
|
@ -45,7 +45,8 @@ EXTRA_DIST = nghttpx.conf.sample proxy.pac.sample android-config android-make \
|
||||||
cmake/Version.cmake \
|
cmake/Version.cmake \
|
||||||
cmake/FindCython.cmake \
|
cmake/FindCython.cmake \
|
||||||
cmake/FindLibevent.cmake \
|
cmake/FindLibevent.cmake \
|
||||||
cmake/FindJansson.cmake
|
cmake/FindJansson.cmake \
|
||||||
|
cmake/FindLibcares.cmake
|
||||||
|
|
||||||
.PHONY: clang-format
|
.PHONY: clang-format
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
# - Try to find libcares
|
||||||
|
# Once done this will define
|
||||||
|
# LIBCARES_FOUND - System has libcares
|
||||||
|
# LIBCARES_INCLUDE_DIRS - The libcares include directories
|
||||||
|
# LIBCARES_LIBRARIES - The libraries needed to use libcares
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(PC_LIBCARES QUIET libcares)
|
||||||
|
|
||||||
|
find_path(LIBCARES_INCLUDE_DIR
|
||||||
|
NAMES ares.h
|
||||||
|
HINTS ${PC_LIBCARES_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
find_library(LIBCARES_LIBRARY
|
||||||
|
NAMES cares
|
||||||
|
HINTS ${PC_LIBCARES_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBCARES_INCLUDE_DIR)
|
||||||
|
set(_version_regex "^#define[ \t]+ARES_VERSION_STR[ \t]+\"([^\"]+)\".*")
|
||||||
|
file(STRINGS "${LIBCARES_INCLUDE_DIR}/ares_version.h"
|
||||||
|
LIBCARES_VERSION REGEX "${_version_regex}")
|
||||||
|
string(REGEX REPLACE "${_version_regex}" "\\1"
|
||||||
|
LIBCARES_VERSION "${LIBCARES_VERSION}")
|
||||||
|
unset(_version_regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LIBCARES_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE and the requested version matches.
|
||||||
|
find_package_handle_standard_args(Libcares REQUIRED_VARS
|
||||||
|
LIBCARES_LIBRARY LIBCARES_INCLUDE_DIR
|
||||||
|
VERSION_VAR LIBCARES_VERSION)
|
||||||
|
|
||||||
|
if(LIBCARES_FOUND)
|
||||||
|
set(LIBCARES_LIBRARIES ${LIBCARES_LIBRARY})
|
||||||
|
set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(LIBCARES_INCLUDE_DIR LIBCARES_LIBRARY)
|
|
@ -19,6 +19,7 @@ include_directories(
|
||||||
${LIBXML2_INCLUDE_DIRS}
|
${LIBXML2_INCLUDE_DIRS}
|
||||||
${LIBEV_INCLUDE_DIRS}
|
${LIBEV_INCLUDE_DIRS}
|
||||||
${OPENSSL_INCLUDE_DIRS}
|
${OPENSSL_INCLUDE_DIRS}
|
||||||
|
${LIBCARES_INCLUDE_DIRS}
|
||||||
${JANSSON_INCLUDE_DIRS}
|
${JANSSON_INCLUDE_DIRS}
|
||||||
${ZLIB_INCLUDE_DIRS}
|
${ZLIB_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
@ -31,6 +32,7 @@ link_libraries(
|
||||||
${LIBXML2_LIBRARIES}
|
${LIBXML2_LIBRARIES}
|
||||||
${LIBEV_LIBRARIES}
|
${LIBEV_LIBRARIES}
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
|
${LIBCARES_LIBRARIES}
|
||||||
${JANSSON_LIBRARIES}
|
${JANSSON_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
${APP_LIBRARIES}
|
${APP_LIBRARIES}
|
||||||
|
@ -112,6 +114,9 @@ if(ENABLE_APP)
|
||||||
shrpx_api_downstream_connection.cc
|
shrpx_api_downstream_connection.cc
|
||||||
shrpx_health_monitor_downstream_connection.cc
|
shrpx_health_monitor_downstream_connection.cc
|
||||||
shrpx_exec.cc
|
shrpx_exec.cc
|
||||||
|
shrpx_dns_resolver.cc
|
||||||
|
shrpx_dual_dns_resolver.cc
|
||||||
|
shrpx_dns_tracker.cc
|
||||||
xsi_strerror.c
|
xsi_strerror.c
|
||||||
)
|
)
|
||||||
if(HAVE_SPDYLAY)
|
if(HAVE_SPDYLAY)
|
||||||
|
|
Loading…
Reference in New Issue