[PATCH] D26894: [llvm-config] Add --cmakedir to obtain CMake module location

Michał Górny via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 20 02:33:01 PST 2016


mgorny created this revision.
mgorny added reviewers: beanz, rnk, chapuni, chandlerc.
mgorny added a subscriber: llvm-commits.

Add a --cmakedir option to llvm-config that returns the correct path to
built/installed CMake modules (i.e. lib/cmake/llvm). This is mostly
intended as a convenience option for stand-alone builds of other LLVM
projects that frequently reconstruct LLVM_CMAKE_PATH after querying
llvm-config.


https://reviews.llvm.org/D26894

Files:
  tools/llvm-config/llvm-config.cpp


Index: tools/llvm-config/llvm-config.cpp
===================================================================
--- tools/llvm-config/llvm-config.cpp
+++ tools/llvm-config/llvm-config.cpp
@@ -196,6 +196,7 @@
   --bindir          Directory containing LLVM executables.\n\
   --includedir      Directory containing LLVM headers.\n\
   --libdir          Directory containing LLVM libraries.\n\
+  --cmakedir        Directory containing LLVM cmake modules.\n\
   --cppflags        C preprocessor flags for files that include LLVM headers.\n\
   --cflags          C compiler flags for files that include LLVM headers.\n\
   --cxxflags        C++ compiler flags for files that include LLVM headers.\n\
@@ -301,7 +302,8 @@
 
   // Compute various directory locations based on the derived location
   // information.
-  std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir;
+  std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir,
+              ActiveCMakeDir;
   std::string ActiveIncludeOption;
   if (IsInDevelopmentTree) {
     ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include";
@@ -313,12 +315,14 @@
     case CMakeStyle:
       ActiveBinDir = ActiveObjRoot + "/bin";
       ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX;
+      ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
       break;
     case CMakeBuildModeStyle:
       ActivePrefix = ActiveObjRoot;
       ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode;
       ActiveLibDir =
           ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX + "/" + build_mode;
+      ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
       break;
     }
 
@@ -330,6 +334,7 @@
     ActiveIncludeDir = ActivePrefix + "/include";
     ActiveBinDir = ActivePrefix + "/bin";
     ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
+    ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
     ActiveIncludeOption = "-I" + ActiveIncludeDir;
   }
 
@@ -356,6 +361,7 @@
       std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\');
       std::replace(ActiveBinDir.begin(), ActiveBinDir.end(), '/', '\\');
       std::replace(ActiveLibDir.begin(), ActiveLibDir.end(), '/', '\\');
+      std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\');
       std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/',
                    '\\');
     }
@@ -466,6 +472,8 @@
         OS << ActiveIncludeDir << '\n';
       } else if (Arg == "--libdir") {
         OS << ActiveLibDir << '\n';
+      } else if (Arg == "--cmakedir") {
+        OS << ActiveCMakeDir << '\n';
       } else if (Arg == "--cppflags") {
         OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n';
       } else if (Arg == "--cflags") {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26894.78655.patch
Type: text/x-patch
Size: 2734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161120/7f33134e/attachment.bin>


More information about the llvm-commits mailing list