[llvm] f093d7e - fix zstd_shared detection on mingw (#139945)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 24 14:05:05 PDT 2025
Author: Jameson Nash
Date: 2025-05-25T00:05:02+03:00
New Revision: f093d7e46c8ed3b8f01b4a7a96207f054ee7c16f
URL: https://github.com/llvm/llvm-project/commit/f093d7e46c8ed3b8f01b4a7a96207f054ee7c16f
DIFF: https://github.com/llvm/llvm-project/commit/f093d7e46c8ed3b8f01b4a7a96207f054ee7c16f.diff
LOG: 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`.
Added:
Modified:
llvm/cmake/modules/Findzstd.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake
index f6ca5d1ebe546..dbfaadb5de2b8 100644
--- a/llvm/cmake/modules/Findzstd.cmake
+++ b/llvm/cmake/modules/Findzstd.cmake
@@ -29,11 +29,11 @@ find_package_handle_standard_args(
)
if(zstd_FOUND)
- if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
+ if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND NOT zstd_LIBRARY MATCHES "\\.dll\\.a$")
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
- if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
+ if(WIN32 OR CYGWIN)
include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends.
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
More information about the llvm-commits
mailing list