[llvm-branch-commits] [llvm] 64260fe - [llvm] [cmake] Move LLVM_INSTALL_PACKAGE_DIR top-level to fix llvm-config
    Tobias Hieta via llvm-branch-commits 
    llvm-branch-commits at lists.llvm.org
       
    Wed Aug 17 01:57:07 PDT 2022
    
    
  
Author: Michał Górny
Date: 2022-08-17T10:56:24+02:00
New Revision: 64260feaa763ca0065637c4b0929262166035387
URL: https://github.com/llvm/llvm-project/commit/64260feaa763ca0065637c4b0929262166035387
DIFF: https://github.com/llvm/llvm-project/commit/64260feaa763ca0065637c4b0929262166035387.diff
LOG: [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 d230055234863aafe63489f9ab95e52d2c1883f2)
Added: 
    
Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/modules/CMakeLists.txt
Removed: 
    
################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c264bbeca0266..ba3d87a1e94de 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -322,6 +322,12 @@ endif()
 
 set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
 
+# LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools
+# subdirectory in order to have the value available for llvm-config.
+include(GNUInstallPackageDir)
+set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
+  "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
+
 set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
     "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
 mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
diff  --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index d4b0ab959148c..470881516915a 100644
--- a/llvm/cmake/modules/CMakeLists.txt
+++ b/llvm/cmake/modules/CMakeLists.txt
@@ -1,10 +1,7 @@
-include(GNUInstallPackageDir)
 include(ExtendPath)
 include(LLVMDistributionSupport)
 include(FindPrefixFromConfig)
 
-set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
-  "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 
        
    
    
More information about the llvm-branch-commits
mailing list