Skip to content

Commit 64260fe

Browse files
mgornytru
authored andcommitted
[llvm] [cmake] Move LLVM_INSTALL_PACKAGE_DIR top-level to fix llvm-config
Move the `LLVM_INSTALL_PACKAGE_DIR` declaration from llvm/cmake/modules directory to the top-level llvm/CMakeLists.txt, in order to fix the regression in `llvm-config --cmakedir` output for installed LLVM. Since the tools directory is processed by CMake prior to llvm/cmake/modules, the llvm-config executable ended up using the variable prior to it being defined and incorrectly used an empty path, resulting in e.g.: $ llvm-config --cmakedir /usr/lib/llvm/16/ With this patch, the path is defined (and therefore the default value is being set) prior to adding the tools subdirectory and llvm-config starts working correctly: $ llvm-config --cmakedir /usr/lib/llvm/16/lib64/cmake/llvm This fixes a regression introduced by D130539. Thanks to Petr Polezhaev for reporting the problem @ https://bugs.gentoo.org/865165 Differential Revision: https://reviews.llvm.org/D131878 (cherry picked from commit d230055)
1 parent b4a285b commit 64260fe

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ endif()
322322

323323
set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
324324

325+
# LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools
326+
# subdirectory in order to have the value available for llvm-config.
327+
include(GNUInstallPackageDir)
328+
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
329+
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
330+
325331
set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
326332
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
327333
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)

llvm/cmake/modules/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
include(GNUInstallPackageDir)
21
include(ExtendPath)
32
include(LLVMDistributionSupport)
43
include(FindPrefixFromConfig)
54

6-
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
7-
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
85
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
96
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
107

0 commit comments

Comments
 (0)