[llvm] a564096 - [llvm][cmake] Follow up to D117973

John Ericson via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 07:51:16 PDT 2022


Author: John Ericson
Date: 2022-07-26T14:51:12Z
New Revision: a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f

URL: https://github.com/llvm/llvm-project/commit/a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f
DIFF: https://github.com/llvm/llvm-project/commit/a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f.diff

LOG: [llvm][cmake] Follow up to D117973

1. Slightly document the "mark advanced" variable used to control the
   installed CMake package dir.

   I would document it more, but I am considering in the future adding
   pkg-config support in this manner, after which `_PACKGE_DIR` is
   probably better called `_CMAKE_PACKGE_DIR` or similar.

2. Convey the custom path to the legacy `llvm-config` binary.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D130539

Added: 
    

Modified: 
    llvm/docs/CMake.rst
    llvm/tools/llvm-config/BuildVariables.inc.in
    llvm/tools/llvm-config/llvm-config.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index d16bf78df8d50..879b7b231d4cf 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -941,9 +941,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
 
 This file is available in two 
diff erent locations.
 
-* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
-  ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
-  On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
+* ``<LLVM_INSTALL_PACKAGE_DIR>/LLVMConfig.cmake`` where
+  ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are
+  installed as part of an installed version of LLVM. This is typically
+  ``cmake/llvm/`` within the lib directory. On Linux, this is typically
+  ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
 
 * ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
   ``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only

diff  --git a/llvm/tools/llvm-config/BuildVariables.inc.in b/llvm/tools/llvm-config/BuildVariables.inc.in
index abbb8a450da6c..370005cd8d7d0 100644
--- a/llvm/tools/llvm-config/BuildVariables.inc.in
+++ b/llvm/tools/llvm-config/BuildVariables.inc.in
@@ -24,6 +24,7 @@
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
 #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
+#define LLVM_INSTALL_PACKAGE_DIR "@LLVM_INSTALL_PACKAGE_DIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"

diff  --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index e9fa7bd2c3889..2c6c55f89d38c 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -370,7 +370,11 @@ int main(int argc, char **argv) {
       ActiveBinDir = std::string(Path.str());
     }
     ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
-    ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
+    {
+      SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
+      sys::fs::make_absolute(ActivePrefix, Path);
+      ActiveCMakeDir = std::string(Path.str());
+    }
     ActiveIncludeOption = "-I" + ActiveIncludeDir;
   }
 


        


More information about the llvm-commits mailing list