summaryrefslogtreecommitdiffstats
path: root/cmake/FindLibcares.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:34:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:34:15 +0000
commitafea5f9539cbf1eeaa85ec77d79eb2f59724f470 (patch)
tree2a4eba394a6bc60d2eaa8304d91168a07225d51e /cmake/FindLibcares.cmake
parentInitial commit. (diff)
downloadnghttp2-afea5f9539cbf1eeaa85ec77d79eb2f59724f470.tar.xz
nghttp2-afea5f9539cbf1eeaa85ec77d79eb2f59724f470.zip
Adding upstream version 1.52.0.upstream/1.52.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/FindLibcares.cmake')
-rw-r--r--cmake/FindLibcares.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/cmake/FindLibcares.cmake b/cmake/FindLibcares.cmake
new file mode 100644
index 0000000..1fe56ce
--- /dev/null
+++ b/cmake/FindLibcares.cmake
@@ -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)