[llvm] 216db5e - Fix Findzstd.cmake for compiler-rt with MSVC (#98645)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 08:06:08 PDT 2024
Author: Yaxun (Sam) Liu
Date: 2024-07-12T11:06:05-04:00
New Revision: 216db5e051733cf1c6250310392cbbe9cafce1b5
URL: https://github.com/llvm/llvm-project/commit/216db5e051733cf1c6250310392cbbe9cafce1b5
DIFF: https://github.com/llvm/llvm-project/commit/216db5e051733cf1c6250310392cbbe9cafce1b5.diff
LOG: Fix Findzstd.cmake for compiler-rt with MSVC (#98645)
When building compiler-rt with MSVC, CMAKE_INSTALL_LIBDIR and
CMAKE_INSTALL_BINDIR are empty.
This causes error in Findzstd.cmake like the following:
CMake Error at C:/llvm/cmake/modules/Findzstd.cmake:39 (string):
string sub-command REGEX, mode REPLACE: regex "$" matched an empty
string.
Do not do the REGEX when CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_BINDIR
are empty.
Similar issues were reported by others at
https://github.com/llvm/llvm-project/commit/e7fc7540daa9333f0be4f380fc9c619236d17f57
Added:
Modified:
llvm/cmake/modules/Findzstd.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake
index 178d99565f044..4bc0b793e51c9 100644
--- a/llvm/cmake/modules/Findzstd.cmake
+++ b/llvm/cmake/modules/Findzstd.cmake
@@ -36,7 +36,9 @@ if(zstd_FOUND)
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}")
+ if(NOT "${CMAKE_INSTALL_LIBDIR}" STREQUAL "" AND NOT "${CMAKE_INSTALL_BINDIR}" STREQUAL "")
+ string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
+ endif()
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
More information about the llvm-commits
mailing list