THRIFT-3097 cmake targets unconditionally depend on optional libraries Consider also cases of missing ZLIB and missing OpenSSL.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f19f999..386a63d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,10 +75,10 @@
 if(WITH_CPP)
     add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
     if(BUILD_TESTING)
-        if(WITH_LIBEVENT)
+        if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL)
             add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
         else()
-            message(WARNING "libevent not found or disabled; will not build some tests")
+            message(WARNING "libevent and/or ZLIB and/or OpenSSL not found or disabled; will not build some tests")
         endif()
     endif()
 endif()