@@ -110,6 +110,7 @@ macro(find_llvm use_llvm)
110110 if (NOT "${__llvm_exit_code} " STREQUAL "0" )
111111 message (FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --libdir" )
112112 endif ()
113+ message (STATUS "LLVM libdir: ${__llvm_libdir} " )
113114 # map prefix => $
114115 # to handle the case when the prefix contains space.
115116 string (REPLACE ${__llvm_prefix} "$" __llvm_cxxflags ${__llvm_cxxflags_space} )
@@ -144,14 +145,33 @@ macro(find_llvm use_llvm)
144145 endforeach ()
145146 separate_arguments (__llvm_system_libs)
146147 foreach (__flag IN ITEMS ${__llvm_system_libs} )
147- # If the library file ends in .lib try to
148- # also search the llvm_libdir
149- if (__flag MATCHES ".lib$" )
150- if (EXISTS "${__llvm_libdir} /${__flag} " )
151- set (__flag "${__llvm_libdir} /${__flag} " )
148+ if ("${__flag} " STREQUAL "-lm" )
149+ message (STATUS "LLVM links against math" )
150+ list (APPEND LLVM_LIBS "m" )
151+ elseif (("${__flag} " STREQUAL "-lz" ) OR ("${__flag} " STREQUAL "z.lib" ))
152+ message (STATUS "LLVM links against zlib" )
153+ find_package (ZLIB REQUIRED)
154+ list (APPEND LLVM_LIBS "ZLIB::ZLIB" )
155+ elseif ("${__flag} " STREQUAL "-lzstd" OR ("${__flag} " STREQUAL "zstd.dll.lib" ))
156+ find_package (zstd REQUIRED)
157+ if (TARGET "zstd::libzstd_static" )
158+ message (STATUS "LLVM links against static zstd" )
159+ list (APPEND LLVM_LIBS "zstd::libzstd_static" )
160+ else ()
161+ message (STATUS "LLVM links against shared zstd" )
162+ list (APPEND LLVM_LIBS "zstd::libzstd_shared" )
152163 endif ()
164+ elseif ("${__flag} " STREQUAL "-lxml2" )
165+ message (STATUS "LLVM links against xml2" )
166+ list (APPEND LLVM_LIBS "-lxml2" )
167+ elseif ((__flag MATCHES ".lib$" ) AND (EXISTS "${__llvm_libdir} /${__flag} " ))
168+ # If the library file ends in .lib try to also search the llvm_libdir
169+ message (STATUS "LLVM linker flag under LLVM libdir: ${__llvm_libdir} /${__flag} " )
170+ list (APPEND LLVM_LIBS "${__llvm_libdir} /${__flag} " )
171+ else ()
172+ message (STATUS "LLVM linker flag: ${__flag} " )
173+ list (APPEND LLVM_LIBS "${__flag} " )
153174 endif ()
154- list (APPEND LLVM_LIBS "${__flag} " )
155175 endforeach ()
156176 endif ()
157177 message (STATUS "Found LLVM_INCLUDE_DIRS=" "${LLVM_INCLUDE_DIRS} " )
0 commit comments