-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix zstd_shared detection on mingw #139945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you briefly explain what the code within this conditional branch does? (It's quite unreadable cmake soup as is...) I presume it does some transformation which is essential for using zstd in a mingw build setting. Is it essential only for using the output of llvm-config, or for building llvm itself as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It transforms the detected zstd_LIBRARY value from an absolute path such as "/usr/lib/libzstd.dll.a" into a linker flag "-lzstd" and marks it in cmake as being a dll. The linker usually doesn't care very much about whether you pass an absolute path or |
||
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library". | ||
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any cmake variable that contains the
.dll.a
suffix as a string? But perhaps we don't want to use that here; for MSVC that (.lib
) would be equal to the static library suffix, so it would negate the effect of the first part of the condition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of any such variable, though we're more interested here in how zstd was compiled, while this check still incorrectly assumes the conventions are based on how LLVM will be compiled. I wasn't sure it is even possible to correctly identify the kind of file this is just using pattern matching on the name, but this change is trying to just make it behave more consistently. (When compiling MSVC, this tests against "_static.lib", so adding "not .dll.a" has no impact)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that this used
zstd_STATIC_LIBRARY_SUFFIX
, I thought it was the usualCMAKE_STATIC_LIBRARY_SUFFIX
.If it would be the cmake general ones, and if we'd use the variable for import library suffix, like
if (zstd_LIBRARY MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$" AND NOT zstd_LIBRARY MATCHES "${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
, it'd essentially beif (zstd_LIBRARY MATCHES ".lib$" AND NOT zstd_LIBRARY MATCHES ".lib$")
.But this wasn't the case, so nevermind - sorry for the detour.