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

Vassil Vassilev via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 00:50:13 PDT 2024


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

>From 98d52c82a846a7501a513be0794b70347b9f2cea 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 4bc0b793e51c9a..86b6d48b6ec6b6 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)
       if(NOT "${CMAKE_INSTALL_LIBDIR}" STREQUAL "" AND NOT "${CMAKE_INSTALL_BINDIR}" STREQUAL "")



More information about the llvm-commits mailing list