Merge branch 'master' into cmake-export-fix
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
index e324802..e4c94f5 100644
--- a/cmake/zlib.cmake
+++ b/cmake/zlib.cmake
@@ -16,15 +16,15 @@
   if(NOT ZLIB_ROOT_DIR)
     set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
   endif()
-  set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}")
   if(EXISTS "${ZLIB_ROOT_DIR}/CMakeLists.txt")
-      # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218
-      include_directories(${ZLIB_INCLUDE_DIR})
+    # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218
+    include_directories("${ZLIB_ROOT_DIR}")
+    add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib)
 
-      add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib)
-      if(TARGET zlibstatic)
-          set(_gRPC_ZLIB_LIBRARIES zlibstatic)
-      endif()
+    if(TARGET zlibstatic)
+      set(_gRPC_ZLIB_LIBRARIES zlibstatic)
+      set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
+    endif()
   else()
       message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
   endif()
@@ -34,12 +34,12 @@
   endif()
 elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
   find_package(ZLIB REQUIRED)
-  
+
   if(TARGET ZLIB::ZLIB)
     set(_gRPC_ZLIB_LIBRARIES ZLIB::ZLIB)
   else()
     set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
   endif()
-  
+  set(_gRPC_ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS})
   set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n  find_package(ZLIB)\nendif()")
 endif()