[PATCH] D70519: [CMake] use findzlib util to include zlib
Michael Holman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 16:19:44 PST 2019
Holman updated this revision to Diff 230558.
Holman added a comment.
Only use FindZLIB if one of the relevant variables is set.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70519/new/
https://reviews.llvm.org/D70519
Files:
llvm/cmake/config-ix.cmake
Index: llvm/cmake/config-ix.cmake
===================================================================
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -56,7 +56,6 @@
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)
@@ -120,15 +119,30 @@
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
set(HAVE_LIBZ 0)
if(LLVM_ENABLE_ZLIB)
- 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()
+ if(ZLIB_ROOT OR ZLIB_LIBRARY OR ZLIB_INCLUDE_DIR)
+ include(FindZLIB)
+
+ if (ZLIB_FOUND)
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ set(HAVE_ZLIB_H 1)
+ string(TOUPPER ${ZLIB_LIBRARIES} library_suffix)
+ check_library_exists(${ZLIB_LIBRARIES} compress2 "" HAVE_LIBZ_${library_suffix})
+ if(HAVE_LIBZ_${library_suffix})
+ set(HAVE_LIBZ 1)
+ endif()
endif()
- endforeach()
+ else()
+ check_include_file(zlib.h HAVE_ZLIB_H)
+ 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()
endif()
# Don't look for these libraries on Windows.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70519.230558.patch
Type: text/x-patch
Size: 1887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191122/16aa3b21/attachment.bin>
More information about the llvm-commits
mailing list