Fix finding c-ares in package mode with CMake
The next release of c-ares will install a CMake package (when built
using CMake), but it will be called "c-ares", not "CARES".
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93f8393..a65ce56 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,11 +150,11 @@
message(WARNING "gRPC_CARES_PROVIDER is \"module\" but CARES_ROOT_DIR is wrong")
endif()
elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package")
- find_package(CARES)
- if(TARGET CARES::CARES)
- set(_gRPC_CARES_LIBRARIES CARES::CARES)
+ find_package(c-ares CONFIG)
+ if(TARGET c-ares::cares)
+ set(_gRPC_CARES_LIBRARIES c-ares::cares)
endif()
- set(_gRPC_FIND_CARES "if(NOT CARES_FOUND)\n find_package(CARES)\nendif()")
+ set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
endif()
if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 2252a7e..3e03afd 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -195,11 +195,11 @@
message(WARNING "gRPC_CARES_PROVIDER is \"module\" but CARES_ROOT_DIR is wrong")
endif()
elseif("<%text>${gRPC_CARES_PROVIDER}</%text>" STREQUAL "package")
- find_package(CARES)
- if(TARGET CARES::CARES)
- set(_gRPC_CARES_LIBRARIES CARES::CARES)
+ find_package(c-ares CONFIG)
+ if(TARGET c-ares::cares)
+ set(_gRPC_CARES_LIBRARIES c-ares::cares)
endif()
- set(_gRPC_FIND_CARES "if(NOT CARES_FOUND)\n find_package(CARES)\nendif()")
+ set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
endif()
if("<%text>${gRPC_PROTOBUF_PROVIDER}</%text>" STREQUAL "module")
diff --git a/tools/cmake/gRPCConfig.cmake.in b/tools/cmake/gRPCConfig.cmake.in
index 48f0674..1a0fa6a 100644
--- a/tools/cmake/gRPCConfig.cmake.in
+++ b/tools/cmake/gRPCConfig.cmake.in
@@ -2,6 +2,7 @@
@_gRPC_FIND_ZLIB@
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
+@_gRPC_FIND_CARES@
# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)