From f7a0587aa9b975fbc7600cd05dc76f37ec207dc5 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 4 Mar 2024 09:21:43 +0000 Subject: [PATCH] [cmake] Include GNUInstallDirs before using variables defined by it. This fixes an odd problem with the regex when `CMAKE_INSTALL_LIBDIR` is not defined: `string sub-command REGEX, mode REPLACE: regex "$" matched an empty string.` Fixes llvm/llvm-project#83802 --- llvm/cmake/modules/Findzstd.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/Findzstd.cmake b/llvm/cmake/modules/Findzstd.cmake index 178d99565f044..650f053e84ffd 100644 --- a/llvm/cmake/modules/Findzstd.cmake +++ b/llvm/cmake/modules/Findzstd.cmake @@ -34,6 +34,7 @@ if(zstd_FOUND) elseif (NOT TARGET zstd::libzstd_shared) add_library(zstd::libzstd_shared SHARED IMPORTED) if(MSVC) + include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends. # 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}")