[PATCH] D136065: [CMake] Fix Findzstd module for shared DLL on Windows
Andrew Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 03:25:30 PDT 2022
andrewng created this revision.
andrewng added reviewers: phosek, mgorny, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
andrewng requested review of this revision.
Herald added a project: LLVM.
https://reviews.llvm.org/D136065
Files:
llvm/cmake/modules/Findzstd.cmake
Index: llvm/cmake/modules/Findzstd.cmake
===================================================================
--- llvm/cmake/modules/Findzstd.cmake
+++ llvm/cmake/modules/Findzstd.cmake
@@ -34,9 +34,23 @@
if(zstd_LIBRARY MATCHES "${zstd_SHARED_LIBRARY_SUFFIX}$" AND
NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
- set_target_properties(zstd::libzstd_shared PROPERTIES
+ if(MSVC)
+ # IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
+ get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
+ string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
+ get_filename_component(zstd_BASENAME "${zstd_LIBRARY}" NAME)
+ string(REGEX REPLACE "${zstd_SHARED_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME "${zstd_BASENAME}")
+ set_target_properties(zstd::libzstd_shared PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
+ IMPORTED_LOCATION "${zstd_DIRNAME}/${zstd_BASENAME}"
+ IMPORTED_IMPLIB "${zstd_LIBRARY}")
+ unset(zstd_DIRNAME)
+ unset(zstd_BASENAME)
+ else()
+ set_target_properties(zstd::libzstd_shared PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_LIBRARY}")
+ endif()
else()
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136065.468147.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221017/41be48bd/attachment.bin>
More information about the llvm-commits
mailing list