summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-12-05 10:24:15 +0000
committerPavel Labath <labath@google.com>2017-12-05 10:24:15 +0000
commitfd8ab369e9aa88dc16583eeff4298c638e017722 (patch)
tree23e1dd6f731c5195fc151694f87ac7f2fb78720b /cmake
parentfa8338cb07e267f6fd9c0b3045d46874dd2ad780 (diff)
Re-commit "[cmake] Enable zlib support on windows"
This recommits r319533 which was broken llvm-config --system-libs output. The reason was that I used find_libraries for searching for the z library. This returns absolute paths, and when these paths made it into llvm-config, it made it produce nonsensical flags. To fix this, I hand-roll a search for the library in the same way that we search for the terminfo library a couple of lines below. This is a bit less flexible than the find_library option, as it does not allow the user to specify the path to the library at configure time (which is important on windows, as zlib is unlikely to be found in any of the standard places cmake searches), but I was able to guide the build to find it with appropriate values of LIB and INCLUDE environment variables. Reviewers: compnerd, rnk, beanz, rafael Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D40779 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/config-ix.cmake76
1 files changed, 43 insertions, 33 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index caa538082fc..42597c871ea 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -127,45 +127,55 @@ if(HAVE_LIBPTHREAD)
set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
endif()
-# Don't look for these libraries on Windows. Also don't look for them if we're
-# using MSan, since uninstrumented third party code may call MSan interceptors
-# 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)
- else()
- set(HAVE_LIBZ 0)
- endif()
- # Skip libedit if using ASan as it contains memory leaks.
- if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
- check_library_exists(edit el_init "" HAVE_LIBEDIT)
- else()
- set(HAVE_LIBEDIT 0)
- endif()
- if(LLVM_ENABLE_TERMINFO)
- set(HAVE_TERMINFO 0)
- foreach(library tinfo terminfo curses ncurses ncursesw)
+# 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)
+ foreach(library z zlib_static zlib)
string(TOUPPER ${library} library_suffix)
- check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
- if(HAVE_TERMINFO_${library_suffix})
- set(HAVE_TERMINFO 1)
- set(TERMINFO_LIBS "${library}")
+ 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()
- else()
- set(HAVE_TERMINFO 0)
endif()
- find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
- set(LLVM_LIBXML2_ENABLED 0)
- set(LIBXML2_FOUND 0)
- if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE))
- find_package(LibXml2)
- if (LIBXML2_FOUND)
- set(LLVM_LIBXML2_ENABLED 1)
- include_directories(${LIBXML2_INCLUDE_DIR})
- set(LIBXML2_LIBS "xml2")
+ # Don't look for these libraries on Windows.
+ if (NOT PURE_WINDOWS)
+ # Skip libedit if using ASan as it contains memory leaks.
+ if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
+ check_library_exists(edit el_init "" HAVE_LIBEDIT)
+ else()
+ set(HAVE_LIBEDIT 0)
+ endif()
+ if(LLVM_ENABLE_TERMINFO)
+ set(HAVE_TERMINFO 0)
+ foreach(library tinfo terminfo curses ncurses ncursesw)
+ string(TOUPPER ${library} library_suffix)
+ check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
+ if(HAVE_TERMINFO_${library_suffix})
+ set(HAVE_TERMINFO 1)
+ set(TERMINFO_LIBS "${library}")
+ break()
+ endif()
+ endforeach()
+ else()
+ set(HAVE_TERMINFO 0)
+ endif()
+
+ find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
+ set(LLVM_LIBXML2_ENABLED 0)
+ set(LIBXML2_FOUND 0)
+ if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE))
+ find_package(LibXml2)
+ if (LIBXML2_FOUND)
+ set(LLVM_LIBXML2_ENABLED 1)
+ include_directories(${LIBXML2_INCLUDE_DIR})
+ set(LIBXML2_LIBS "xml2")
+ endif()
endif()
endif()
endif()