[Lldb-commits] [PATCH] D65798: [lldb][CMake] Infer `Clang_DIR` if not passed explicitly

Stefan Gränitz via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 6 03:34:57 PDT 2019


sgraenitz created this revision.
sgraenitz added reviewers: JDevlieghere, jingham, xiaobai, compnerd, labath.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

This shrinks standalone configuration lines by one more parameter. In the provided build-tree, the default structure of CMake module directories is:

  /path/to/build-llvm/lib/cmake/llvm
  /paht/to/build-llvm/lib/cmake/clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65798

Files:
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/docs/resources/build.rst


Index: lldb/docs/resources/build.rst
===================================================================
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -323,7 +323,6 @@
   > cmake -B /path/to/lldb-build \
           -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-Xcode.cmake \
           -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
-          -DClang_DIR=/path/to/llvm-build/lib/cmake/clang \
           llvm-project/lldb
   > open lldb.xcodeproj
   > cmake --build /path/to/lldb-build --target check-lldb
Index: lldb/cmake/modules/LLDBStandalone.cmake
===================================================================
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,5 +1,12 @@
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
+if(NOT Clang_DIR)
+  # ClangConfig.cmake is usually found in the clang directory
+  # next to LLVM's module directory.
+  set(Clang_DIR ${LLVM_DIR}/../clang)
+  message(STATUS "Inferred Clang_DIR: ${Clang_DIR}")
+endif()
+
 find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS "${Clang_DIR}" NO_CMAKE_FIND_ROOT_PATH)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65798.213566.patch
Type: text/x-patch
Size: 1248 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190806/8650caf9/attachment.bin>


More information about the lldb-commits mailing list