diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/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/ + CMakeBuildModeStyle, + + // llvm-config is in ${LLVM_OBJ_ROOT}//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.