[llvm] 5279e6a - [cmake] Fix Findzstd.cmake to handle OpenBSD shared libraries
Michał Górny via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 22 21:51:06 PST 2022
Author: Michał Górny
Date: 2022-11-23T06:50:53+01:00
New Revision: 5279e6a7d677cdf4488883b77aacab911318100c
URL: https://github.com/llvm/llvm-project/commit/5279e6a7d677cdf4488883b77aacab911318100c
DIFF: https://github.com/llvm/llvm-project/commit/5279e6a7d677cdf4488883b77aacab911318100c.diff
LOG: [cmake] Fix Findzstd.cmake to handle OpenBSD shared libraries
Fix Findzstd CMake to handle shared libraries on OpenBSD correctly.
This userland does not use shared library symlinks without SOVERSION,
so the result of find_library() does not ever end with
zstd_SHARED_LIBRARY_SUFFIX. To work around this, reverse the logic
to compare the result against zstd_STATIC_LIBRARY_SUFFIX and assume
shared library otherwise.
While at it, fix the conditions not to fall back to "result is static
library" path if it actually was recognized as a shared library but
zstd_shared target already existed.
Fixes #59056
Differential Revision: https://reviews.llvm.org/D138361
Added:
Modified:
llvm/cmake/modules/Findzstd.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake
index 3890bd236a6c..178d99565f04 100644
--- a/llvm/cmake/modules/Findzstd.cmake
+++ b/llvm/cmake/modules/Findzstd.cmake
@@ -11,10 +11,8 @@
# zstd::libzstd_static
if(MSVC)
- set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_LINK_LIBRARY_SUFFIX}$")
set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
else()
- set(zstd_SHARED_LIBRARY_SUFFIX "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$")
set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
endif()
@@ -31,8 +29,9 @@ find_package_handle_standard_args(
)
if(zstd_FOUND)
- if(zstd_LIBRARY MATCHES "${zstd_SHARED_LIBRARY_SUFFIX}$" AND
- NOT TARGET zstd::libzstd_shared)
+ if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
+ set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
+ elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
if(MSVC)
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
@@ -51,8 +50,6 @@ if(zstd_FOUND)
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_LIBRARY}")
endif()
- else()
- set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
endif()
if(zstd_STATIC_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND
NOT TARGET zstd::libzstd_static)
@@ -63,7 +60,6 @@ if(zstd_FOUND)
endif()
endif()
-unset(zstd_SHARED_LIBRARY_SUFFIX)
unset(zstd_STATIC_LIBRARY_SUFFIX)
mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY zstd_STATIC_LIBRARY)
More information about the llvm-commits
mailing list