Skip to content

Commit a206de8

Browse files
[lldb][CMake] Infer Clang_DIR if not passed explicitly
Summary: If we only get `LLVM_DIR` and find Clang in the same provided build-tree, automatically infer `Clang_DIR` like this: ``` LLVM_DIR = /path/to/build-llvm/lib/cmake/llvm Clang_DIR = /paht/to/build-llvm/lib/cmake/clang ``` Reviewers: JDevlieghere, jingham, xiaobai, compnerd, labath Reviewed By: JDevlieghere, labath Subscribers: mgorny, lldb-commits, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D65798 llvm-svn: 372210
1 parent a84b200 commit a206de8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lldb/cmake/modules/LLDBStandalone.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
22

3-
find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
4-
find_package(Clang REQUIRED CONFIG HINTS "${Clang_DIR}" NO_CMAKE_FIND_ROOT_PATH)
3+
find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
4+
find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
55

66
# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
77
set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")

lldb/docs/resources/build.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ Standalone builds
120120
*****************
121121

122122
This is another way to build LLDB. We can use the same source-tree as we
123-
checked out above, but now we will have two build-trees:
123+
checked out above, but now we will have multiple build-trees:
124124

125125
* the main build-tree for LLDB in ``/path/to/lldb-build``
126-
* a provided build-tree for LLVM and Clang in ``/path/to/llvm-build``
126+
* one or more provided build-trees for LLVM and Clang; for simplicity we use a
127+
single one in ``/path/to/llvm-build``
127128

128129
Run CMake with ``-B`` pointing to a new directory for the provided
129130
build-tree\ :sup:`1` and the positional argument pointing to the ``llvm``
@@ -139,15 +140,15 @@ Clang. Then we build the ``ALL`` target with ninja:
139140

140141
Now run CMake a second time with ``-B`` pointing to a new directory for the
141142
main build-tree and the positional argument pointing to the ``lldb`` directory
142-
in the source-tree. In order to find the provided build-tree, the build-system
143-
needs the options ``LLVM_DIR`` and ``Clang_DIR`` (CMake variables are
144-
case-sensitive!):
143+
in the source-tree. In order to find the provided build-tree, the build system
144+
looks for the path to its CMake modules in ``LLVM_DIR``. If you use a separate
145+
build directory for Clang, remember to pass its module path via ``Clang_DIR``
146+
(CMake variables are case-sensitive!):
145147

146148
::
147149

148150
> cmake -B /path/to/lldb-build -G Ninja \
149151
-DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
150-
-DClang_DIR=/path/to/llvm-build/lib/cmake/clang \
151152
[<more cmake options>] /path/to/llvm-project/lldb
152153
> ninja lldb
153154

@@ -320,7 +321,6 @@ Build LLDB standalone for development with Xcode:
320321
> cmake -B /path/to/lldb-build \
321322
-C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-Xcode.cmake \
322323
-DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
323-
-DClang_DIR=/path/to/llvm-build/lib/cmake/clang \
324324
llvm-project/lldb
325325
> open lldb.xcodeproj
326326
> cmake --build /path/to/lldb-build --target check-lldb

0 commit comments

Comments
 (0)