[llvm] e7fc754 - [CMake] Fix Findzstd module for shared DLL on Windows
Andrew Ng via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 18 04:38:47 PDT 2022
Author: Andrew Ng
Date: 2022-10-18T12:35:11+01:00
New Revision: e7fc7540daa9333f0be4f380fc9c619236d17f57
URL: https://github.com/llvm/llvm-project/commit/e7fc7540daa9333f0be4f380fc9c619236d17f57
DIFF: https://github.com/llvm/llvm-project/commit/e7fc7540daa9333f0be4f380fc9c619236d17f57.diff
LOG: [CMake] Fix Findzstd module for shared DLL on Windows
Differential Revision: https://reviews.llvm.org/D136065
Added:
Modified:
llvm/cmake/modules/Findzstd.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake
index 2994eaf7c9980..3890bd236a6cb 100644
--- a/llvm/cmake/modules/Findzstd.cmake
+++ b/llvm/cmake/modules/Findzstd.cmake
@@ -34,9 +34,23 @@ if(zstd_FOUND)
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 "\\${CMAKE_LINK_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()
More information about the llvm-commits
mailing list