Skip to content

Commit 216db5e

Browse files
authored
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 e7fc754
1 parent da1f491 commit 216db5e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/cmake/modules/Findzstd.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ if(zstd_FOUND)
3636
if(MSVC)
3737
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
3838
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
39-
string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
39+
if(NOT "${CMAKE_INSTALL_LIBDIR}" STREQUAL "" AND NOT "${CMAKE_INSTALL_BINDIR}" STREQUAL "")
40+
string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
41+
endif()
4042
get_filename_component(zstd_BASENAME "${zstd_LIBRARY}" NAME)
4143
string(REGEX REPLACE "\\${CMAKE_LINK_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME "${zstd_BASENAME}")
4244
set_target_properties(zstd::libzstd_shared PROPERTIES

0 commit comments

Comments
 (0)