[llvm] [cmake] Include GNUInstallDirs before using variables defined by it. (PR #83807)

Vassil Vassilev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 01:23:52 PST 2024


https://github.com/vgvassilev created https://github.com/llvm/llvm-project/pull/83807

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

>From f7a0587aa9b975fbc7600cd05dc76f37ec207dc5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev <v.g.vassilev at gmail.com>
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 178d99565f044e..650f053e84ffd0 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}")



More information about the llvm-commits mailing list