[PATCH] D66644: [llvm-config] Support MSVS layout

Sergej Jaskiewicz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 05:21:03 PDT 2019


broadwaylamb created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When using a Visual Studio generator in CMake, the llvm-config
executable is placed in the ${LLVM_OBJ_ROOT}/<build-mode>/bin
directory, which wasn't recognized by the llvm-config tool.

This led to llvm-config returning the wrong path for --cmakedir.
This is fixed here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66644

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


Index: llvm/tools/llvm-config/llvm-config.cpp
===================================================================
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -267,7 +267,18 @@
   // that we can report the correct information when run from a development
   // tree.
   bool IsInDevelopmentTree;
-  enum { CMakeStyle, CMakeBuildModeStyle } DevelopmentTreeLayout;
+
+  enum {
+    // llvm-config is in ${LLVM_OBJ_ROOT}/bin/
+    CMakeStyle,
+
+    // llvm-config is in ${LLVM_OBJ_ROOT}/bin/<build-mode>
+    CMakeBuildModeStyle,
+
+    // llvm-config is in ${LLVM_OBJ_ROOT}/<build-mode>/bin
+    CMakeReverseBuildModeStyle
+  } DevelopmentTreeLayout;
+
   llvm::SmallString<256> CurrentPath(GetExecutablePath(argv[0]));
   std::string CurrentExecPrefix;
   std::string ActiveObjRoot;
@@ -296,6 +307,11 @@
     IsInDevelopmentTree = true;
     DevelopmentTreeLayout = CMakeBuildModeStyle;
     ActiveObjRoot = LLVM_OBJ_ROOT;
+  } else if (sys::fs::equivalent(CurrentExecPrefix,
+                                 Twine(LLVM_OBJ_ROOT) + "/" + build_mode)) {
+    IsInDevelopmentTree = true;
+    DevelopmentTreeLayout = CMakeReverseBuildModeStyle;
+    ActiveObjRoot = LLVM_OBJ_ROOT;
   } else {
     IsInDevelopmentTree = false;
     DevelopmentTreeLayout = CMakeStyle; // Initialized to avoid warnings.
@@ -328,6 +344,12 @@
       ActiveCMakeDir =
           ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX + "/cmake/llvm";
       break;
+    case CMakeReverseBuildModeStyle:
+      ActiveBinDir = ActiveObjRoot + "/" + build_mode + "/bin";
+      ActiveLibDir =
+          ActiveObjRoot + "/" + build_mode + "/lib" + LLVM_LIBDIR_SUFFIX;
+      ActiveCMakeDir = ActiveObjRoot + "/lib/cmake/llvm";
+      break;
     }
 
     // We need to include files from both the source and object trees.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66644.216812.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/b6924a0b/attachment.bin>


More information about the llvm-commits mailing list