aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-07-21 03:11:14 -0700
committerMichael Mann <mmann78@netscape.net>2017-07-21 12:39:26 +0000
commit9ea364c389fc92bcd8efc800c9b8e852958c169a (patch)
treec392b77e9ad3f84dfd438f28089b68dce2dd22c2
parent725b7ef17598076911da9c68efbf8c0efd593191 (diff)
Require at least c-ares 1.5.0 when configuring.
That way, if you have an older version, we fail at configure time, with what should be a message indicating that your c-ares is too old, rather than at compile time, with what might provoke users to ask "what am I doing wrong?" or "what do I need to fix?" or "why is my compile failing?" or.... Change-Id: I911574c4d90174b6bd074c5ef537557d47b199dc Reviewed-on: https://code.wireshark.org/review/22752 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--CMakeLists.txt2
-rw-r--r--acinclude.m431
-rw-r--r--cmake/modules/FindCARES.cmake12
3 files changed, 41 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ffabea549..77e41d49fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -878,6 +878,8 @@ endif()
# C Asynchronous resolver
if(ENABLE_CARES)
set(PACKAGELIST ${PACKAGELIST} CARES)
+ # Minimum version needed.
+ set(CARES_OPTIONS "1.5.0" REQUIRED)
endif()
# Zlib compression
diff --git a/acinclude.m4 b/acinclude.m4
index 4ab5bcbdfb..2235c4d889 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -823,9 +823,34 @@ AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
if test "x$want_c_ares" = "xyes"; then
AC_CHECK_LIB(cares, ares_init,
[
- C_ARES_LIBS=-lcares
- AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
- have_good_c_ares=yes
+ #
+ # Make sure we have c-ares 1.5 or later; we don't
+ # support the older API.
+ #
+ AC_MSG_CHECKING([whether we have c-ares 1.5 or later])
+ AC_TRY_COMPILE(
+ [
+#include <ares.h>
+#include <ares_version.h>
+ ],
+ [
+#if ((ARES_VERSION_MAJOR < 1) || \
+ (1 == ARES_VERSION_MAJOR == 1 && ARES_VERSION_MINOR < 5))
+#error You lose
+#else
+ return 0;
+#endif
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ C_ARES_LIBS=-lcares
+ AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
+ have_good_c_ares=yes
+ ],
+ [
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Pre-1.5 versions of c-ares aren't supported])
+ ])
])
else
AC_MSG_RESULT(not required)
diff --git a/cmake/modules/FindCARES.cmake b/cmake/modules/FindCARES.cmake
index 11719a601a..2725a61d44 100644
--- a/cmake/modules/FindCARES.cmake
+++ b/cmake/modules/FindCARES.cmake
@@ -22,10 +22,20 @@ FIND_PATH(CARES_INCLUDE_DIR ares.h HINTS "${CARES_HINTS}/include" )
SET(CARES_NAMES cares libcares-2)
FIND_LIBRARY(CARES_LIBRARY NAMES ${CARES_NAMES} HINTS "${CARES_HINTS}/lib" )
+# Try to retrieve version from header if found
+if(CARES_INCLUDE_DIR)
+ set(_version_regex "^#define[ \t]+ARES_VERSION_STR[ \t]+\"([^\"]+)\".*")
+ file(STRINGS "${CARES_INCLUDE_DIR}/ares_version.h" CARES_VERSION REGEX "${_version_regex}")
+ string(REGEX REPLACE "${_version_regex}" "\\1" CARES_VERSION "${CARES_VERSION}")
+ unset(_version_regex)
+endif()
+
# handle the QUIETLY and REQUIRED arguments and set CARES_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CARES DEFAULT_MSG CARES_LIBRARY CARES_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CARES
+ REQUIRED_VARS CARES_LIBRARY CARES_INCLUDE_DIR
+ VERSION_VAR CARES_VERSION)
IF(CARES_FOUND)
SET( CARES_LIBRARIES ${CARES_LIBRARY} )