From e406cca5f9a6477c9861717f81c156aa83feeaca Mon Sep 17 00:00:00 2001 From: James Henderson Date: Thu, 2 Jan 2020 15:35:22 +0000 Subject: Revert "build: reduce CMake handling for zlib" This reverts commit 68a235d07f9e7049c7eb0c8091f37e385327ac28. This commit broke the clang-x64-windows-msvc build bot and a follow-up commit did not fix it. Reverting to fix the bot. --- llvm/cmake/config-ix.cmake | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'llvm/cmake/config-ix.cmake') diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index d5a15a680a6..e7e5e5dcf2f 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -56,6 +56,7 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(termios.h HAVE_TERMIOS_H) check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) +check_include_file(zlib.h HAVE_ZLIB_H) check_include_file(fenv.h HAVE_FENV_H) check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) @@ -117,8 +118,17 @@ endif() # Don't look for these libraries if we're using MSan, since uninstrumented third # party code may call MSan interceptors like strlen, leading to false positives. if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set(HAVE_LIBZ 0) if(LLVM_ENABLE_ZLIB) - find_package(ZLIB REQUIRED) + foreach(library z zlib_static zlib) + string(TOUPPER ${library} library_suffix) + check_library_exists(${library} compress2 "" HAVE_LIBZ_${library_suffix}) + if(HAVE_LIBZ_${library_suffix}) + set(HAVE_LIBZ 1) + set(ZLIB_LIBRARIES "${library}") + break() + endif() + endforeach() endif() # Don't look for these libraries on Windows. @@ -505,8 +515,11 @@ else( LLVM_ENABLE_THREADS ) message(STATUS "Threads disabled.") endif() -if(LLVM_ENABLE_ZLIB) - find_package(ZLIB REQUIRED) +if (LLVM_ENABLE_ZLIB ) + # Check if zlib is available in the system. + if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) + set(LLVM_ENABLE_ZLIB 0) + endif() endif() if (LLVM_ENABLE_DOXYGEN) -- cgit v1.2.3