From 1c1c256fbc6752b4f2068fe0eb734022b1044c41 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 17 Oct 2017 20:32:27 +0000 Subject: [PATCH] [cmake] Use find_package to discover zlib This allows us to use standard cmake utilities to point to non-system zlib locations. Patch by Oksana Shadura and me (D39002). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316025 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/config-ix.cmake | 5 ++++- lib/Support/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 7f33591de0c..c90f2d836c8 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -132,7 +132,10 @@ endif() # like strlen, leading to false positives. if( NOT PURE_WINDOWS AND NOT LLVM_USE_SANITIZER MATCHES "Memory.*") if (LLVM_ENABLE_ZLIB) - check_library_exists(z compress2 "" HAVE_LIBZ) + find_package(ZLIB REQUIRED) + if (ZLIB_FOUND) + set(HAVE_LIBZ 1) + endif() else() set(HAVE_LIBZ 0) endif() diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 56aaf10ec2c..5dcb5e58af4 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt @@ -22,7 +22,7 @@ elseif( CMAKE_HOST_UNIX ) endif() set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB}) if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ ) - set(system_libs ${system_libs} z) + set(system_libs ${system_libs} ${ZLIB_LIBRARIES}) endif() if( UNIX AND NOT (BEOS OR HAIKU) ) set(system_libs ${system_libs} m) -- 2.40.0