From 1d93e22a10a03c79d6113e084b337bfd1db90821 Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Mon, 28 Aug 2017 20:43:27 +0200
Subject: [PATCH] fix macos build

---
 CMakeLists.txt                    | 4 ++--
 Makefile                          | 2 +-
 build.yaml                        | 3 ++-
 templates/CMakeLists.txt.template | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5fc4f2ea6b2..d262026c456 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -137,8 +137,8 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
   set(CARES_STATIC ON)
   set(CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares")
   add_subdirectory(third_party/cares/cares)
-  if(TARGET c-ares_static)
-    set(_gRPC_CARES_LIBRARIES c-ares_static)
+  if(TARGET c-ares)
+    set(_gRPC_CARES_LIBRARIES c-ares)
   endif()
   if(gRPC_INSTALL)
     message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
diff --git a/Makefile b/Makefile
index 4d77cc50383..0c3648566a9 100644
--- a/Makefile
+++ b/Makefile
@@ -8373,7 +8373,7 @@ PUBLIC_HEADERS_C += \
 LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC))))
 
 $(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
-$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
+$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
 
 $(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP)  $(LIBARES_OBJS) 
 	$(E) "[AR]      Creating $@"
diff --git a/build.yaml b/build.yaml
index c694675e93b..d15cf0339ca 100644
--- a/build.yaml
+++ b/build.yaml
@@ -4842,7 +4842,8 @@ configs:
       UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt
 defaults:
   ares:
-    CFLAGS: -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
+    CFLAGS: -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32)
+      $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
     CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux)
       $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden
       -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 87785999848..966a73c28e4 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -182,8 +182,8 @@
     set(CARES_STATIC ON)
     set(CARES_INCLUDE_DIR "<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/cares/cares")
     add_subdirectory(third_party/cares/cares)
-    if(TARGET c-ares_static)
-      set(_gRPC_CARES_LIBRARIES c-ares_static)
+    if(TARGET c-ares)
+      set(_gRPC_CARES_LIBRARIES c-ares)
     endif()
     if(gRPC_INSTALL)
       message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")