[llvm] [llvm] Fix Findzstd.cmake (PR #105820)
Raed Rizqie via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 05:20:53 PDT 2024
https://github.com/raedrizqie created https://github.com/llvm/llvm-project/pull/105820
None
>From 168d657087cca8e7580e1cf0514508b1fa27d9f9 Mon Sep 17 00:00:00 2001
From: Raed Rizqie <raed.rizqie at gmail.com>
Date: Fri, 23 Aug 2024 20:14:03 +0800
Subject: [PATCH] [llvm] Fix Findzstd.cmake
---
llvm/cmake/modules/Findzstd.cmake | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake
index 4bc0b793e51c9a..c9d4cf9c15e95b 100644
--- a/llvm/cmake/modules/Findzstd.cmake
+++ b/llvm/cmake/modules/Findzstd.cmake
@@ -10,10 +10,20 @@
# zstd::libzstd_shared
# zstd::libzstd_static
-if(MSVC)
- set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+if(LLVM_USE_STATIC_ZSTD)
+ if(MSVC)
+ set(zstd_STATIC_LIBRARY_SUFFIX "_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ else()
+ set(zstd_STATIC_LIBRARY_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ endif()
+ set(zstd_LIBRARY_FULLNAME "${CMAKE_STATIC_LIBRARY_PREFIX}zstd${zstd_STATIC_LIBRARY_SUFFIX}")
else()
- set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+ if(MINGW)
+ set(zstd_SHARED_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ else()
+ set(zstd_SHARED_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ endif()
+ set(zstd_LIBRARY_FULLNAME "${CMAKE_SHARED_LIBRARY_PREFIX}zstd${zstd_SHARED_LIBRARY_SUFFIX}")
endif()
find_path(zstd_INCLUDE_DIR NAMES zstd.h)
@@ -29,7 +39,7 @@ find_package_handle_standard_args(
)
if(zstd_FOUND)
- if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
+ if(zstd_LIBRARY MATCHES "zstd${zstd_STATIC_LIBRARY_SUFFIX}")
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
@@ -53,13 +63,14 @@ if(zstd_FOUND)
IMPORTED_LOCATION "${zstd_LIBRARY}")
endif()
endif()
- if(zstd_STATIC_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND
+ if(zstd_STATIC_LIBRARY MATCHES "zstd${zstd_STATIC_LIBRARY_SUFFIX}" AND
NOT TARGET zstd::libzstd_static)
add_library(zstd::libzstd_static STATIC IMPORTED)
set_target_properties(zstd::libzstd_static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
IMPORTED_LOCATION "${zstd_STATIC_LIBRARY}")
endif()
+ message(STATUS "Found zstd: ${zstd_LIBRARY_FULLNAME}")
endif()
unset(zstd_STATIC_LIBRARY_SUFFIX)
More information about the llvm-commits
mailing list