llvm.org GIT mirror llvm / 2f1bcfe
[cmake] Enable zlib support on windows Summary: zlib support was hard-wired to off for (non-cygwin) windows targets. This disables some features, such as reading debug info from compressed dwarf sections. This has been this way since zlib support was added in 2013 (r180083), but there is no obvious reason for that. Zlib is perfectly capable of being compiled for windows (it even has a cmake file that works out of the box). This enables one to turn on zlib support on windows, if one has zlib avaliable. Reviewers: rnk, beanz Subscribers: mgorny, aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D40655 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319533 91177308-0d34-0410-b5e6-96231b3b80d8 Pavel Labath 1 year, 10 months ago
2 changed file(s) with 42 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
126126 set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
127127 endif()
128128
129 # Don't look for these libraries on Windows. Also don't look for them if we're
130 # using MSan, since uninstrumented third party code may call MSan interceptors
131 # like strlen, leading to false positives.
132 if( NOT PURE_WINDOWS AND NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
133 if (LLVM_ENABLE_ZLIB)
134 check_library_exists(z compress2 "" HAVE_LIBZ)
129 # Don't look for these libraries if we're using MSan, since uninstrumented third
130 # party code may call MSan interceptors like strlen, leading to false positives.
131 if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
132 find_library(ZLIB_LIBRARY_PATH NAMES z zlib)
133 if (LLVM_ENABLE_ZLIB AND ZLIB_LIBRARY_PATH)
134 check_library_exists(${ZLIB_LIBRARY_PATH} compress2 "" HAVE_LIBZ)
135135 else()
136136 set(HAVE_LIBZ 0)
137137 endif()
138 # Skip libedit if using ASan as it contains memory leaks.
139 if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
140 check_library_exists(edit el_init "" HAVE_LIBEDIT)
141 else()
142 set(HAVE_LIBEDIT 0)
143 endif()
144 if(LLVM_ENABLE_TERMINFO)
145 set(HAVE_TERMINFO 0)
146 foreach(library tinfo terminfo curses ncurses ncursesw)
147 string(TOUPPER ${library} library_suffix)
148 check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
149 if(HAVE_TERMINFO_${library_suffix})
150 set(HAVE_TERMINFO 1)
151 set(TERMINFO_LIBS "${library}")
152 break()
138
139 # Don't look for these libraries on Windows.
140 if (NOT PURE_WINDOWS)
141 # Skip libedit if using ASan as it contains memory leaks.
142 if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
143 check_library_exists(edit el_init "" HAVE_LIBEDIT)
144 else()
145 set(HAVE_LIBEDIT 0)
146 endif()
147 if(LLVM_ENABLE_TERMINFO)
148 set(HAVE_TERMINFO 0)
149 foreach(library tinfo terminfo curses ncurses ncursesw)
150 string(TOUPPER ${library} library_suffix)
151 check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
152 if(HAVE_TERMINFO_${library_suffix})
153 set(HAVE_TERMINFO 1)
154 set(TERMINFO_LIBS "${library}")
155 break()
156 endif()
157 endforeach()
158 else()
159 set(HAVE_TERMINFO 0)
160 endif()
161
162 find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
163 set(LLVM_LIBXML2_ENABLED 0)
164 set(LIBXML2_FOUND 0)
165 if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE))
166 find_package(LibXml2)
167 if (LIBXML2_FOUND)
168 set(LLVM_LIBXML2_ENABLED 1)
169 include_directories(${LIBXML2_INCLUDE_DIR})
170 set(LIBXML2_LIBS "xml2")
153171 endif()
154 endforeach()
155 else()
156 set(HAVE_TERMINFO 0)
157 endif()
158
159 find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
160 set(LLVM_LIBXML2_ENABLED 0)
161 set(LIBXML2_FOUND 0)
162 if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE))
163 find_package(LibXml2)
164 if (LIBXML2_FOUND)
165 set(LLVM_LIBXML2_ENABLED 1)
166 include_directories(${LIBXML2_INCLUDE_DIR})
167 set(LIBXML2_LIBS "xml2")
168172 endif()
169173 endif()
170174 endif()
0 set(system_libs)
1 if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
2 set(system_libs ${system_libs} ${ZLIB_LIBRARY_PATH})
3 endif()
14 if( MSVC OR MINGW )
25 # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
36 set(system_libs ${system_libs} psapi shell32 ole32 uuid)
2023 set(system_libs ${system_libs} atomic)
2124 endif()
2225 set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB})
23 if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
24 set(system_libs ${system_libs} z)
25 endif()
2626 if( UNIX AND NOT (BEOS OR HAIKU) )
2727 set(system_libs ${system_libs} m)
2828 endif()