Skip to content

Commit f093d7e

Browse files
authored
fix zstd_shared detection on mingw (#139945)
The zstd_shared autodetection was broken for non-MSVC (mingw) compiled LLVM, since it assumed that `*.a` uniquely identifies a file as being a static library, but typically this is actually an import lib formed as the longer name `*.dll.a` from the binary. This leads to confusing output elsewhere, in cmake and llvm-config, when they report this is a static library at an absolute path instead of a shared library named `-lzstd`.
1 parent abf1bfb commit f093d7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/cmake/modules/Findzstd.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ find_package_handle_standard_args(
2929
)
3030

3131
if(zstd_FOUND)
32-
if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
32+
if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND NOT zstd_LIBRARY MATCHES "\\.dll\\.a$")
3333
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
3434
elseif (NOT TARGET zstd::libzstd_shared)
3535
add_library(zstd::libzstd_shared SHARED IMPORTED)
36-
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
36+
if(WIN32 OR CYGWIN)
3737
include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends.
3838
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
3939
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)

0 commit comments

Comments
 (0)