diff --git a/CMakeLists.txt b/CMakeLists.txt index e8094b72550..f5e863183b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,11 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") if(NOT protobuf_BUILD_TESTS) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") endif() + # Disable building protobuf with zlib. Building protobuf with zlib breaks + # the build if zlib is not installed on the system. + if(NOT protobuf_WITH_ZLIB) + set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") + endif() if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 91bed9a6db1..d279d02553e 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -207,6 +207,11 @@ if(NOT protobuf_BUILD_TESTS) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") endif() + # Disable building protobuf with zlib. Building protobuf with zlib breaks + # the build if zlib is not installed on the system. + if(NOT protobuf_WITH_ZLIB) + set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") + endif() if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif()