llvm-config: Let directories aware of CMAKE_CFG_INTDIR.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 17 Dec 2013 05:48:37 +0000 (05:48 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 17 Dec 2013 05:48:37 +0000 (05:48 +0000)
With llvm-config.exe --bindir --libdir --build-mode, on Visual Studio 2010,

In build tree:
  (OBJ_ROOT)/bin/MinSizeRel
  (OBJ_ROOT)/lib/MinSizeRel
  MinSizeRel

In installed tree:
  (INSTALL_PREFIX)/bin
  (INSTALL_PREFIX)/lib
  MinSizeRel

This is enhancements since r196283.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197467 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-config/llvm-config.cpp

index 63f099f1dacb078d2e2bbff6bbda94a97f84beeb..b12be863426400195e48df730e747e5facf057e2 100644 (file)
@@ -184,6 +184,13 @@ int main(int argc, char **argv) {
   std::string CurrentExecPrefix;
   std::string ActiveObjRoot;
 
+  // If CMAKE_CFG_INTDIR is given, honor it as build mode.
+  char const *build_mode = LLVM_BUILDMODE;
+#if defined(CMAKE_CFG_INTDIR)
+  if (!(CMAKE_CFG_INTDIR[0] == '.' && CMAKE_CFG_INTDIR[1] == '\0'))
+    build_mode = CMAKE_CFG_INTDIR;
+#endif
+
   // Create an absolute path, and pop up one directory (we expect to be inside a
   // bin dir).
   sys::fs::make_absolute(CurrentPath);
@@ -239,8 +246,8 @@ int main(int argc, char **argv) {
       ActiveLibDir = ActiveObjRoot + "/lib";
       break;
     case CMakeBuildModeStyle:
-      ActiveBinDir = ActiveObjRoot + "/bin/" + LLVM_BUILDMODE;
-      ActiveLibDir = ActiveObjRoot + "/lib/" + LLVM_BUILDMODE;
+      ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode;
+      ActiveLibDir = ActiveObjRoot + "/lib/" + build_mode;
       break;
     }
 
@@ -300,11 +307,6 @@ int main(int argc, char **argv) {
       } else if (Arg == "--host-target") {
         OS << LLVM_DEFAULT_TARGET_TRIPLE << '\n';
       } else if (Arg == "--build-mode") {
-        char const *build_mode = LLVM_BUILDMODE;
-#if defined(CMAKE_CFG_INTDIR)
-        if (!(CMAKE_CFG_INTDIR[0] == '.' && CMAKE_CFG_INTDIR[1] == '\0'))
-          build_mode = CMAKE_CFG_INTDIR;
-#endif
         OS << build_mode << '\n';
       } else if (Arg == "--assertion-mode") {
 #if defined(NDEBUG)