Skip to content

Commit a809720

Browse files
committed
[lldb][NFCI] Change logic to find clang resource dir in standalone builds
As of 0beffb8 there is a CMake function to actually calculate the relative path to the clang resource directory. Currently we have some bespoke logic that looks in a few places, but with this new function we should be able to eliminate some complexity here. Also, I moved the functionality from LLDBConfig to LLDBStandalone since it is only used in standalone builds. Differential Revision: https://reviews.llvm.org/D156270
1 parent 03399a9 commit a809720

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -282,30 +282,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
282282
endif()
283283
endif()
284284

285-
286-
# If LLDB is building against a prebuilt Clang, then the Clang resource
287-
# directory that LLDB is using for its embedded Clang instance needs to point
288-
# to the resource directory of the used Clang installation.
289-
if (NOT TARGET clang-resource-headers)
290-
set(LLDB_CLANG_RESOURCE_DIR_NAME "${LLVM_VERSION_MAJOR}")
291-
# Iterate over the possible places where the external resource directory
292-
# could be and pick the first that exists.
293-
foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
294-
"${LLVM_BUILD_LIBRARY_DIR}"
295-
"${LLVM_LIBRARY_DIR}")
296-
# Build the resource directory path by appending 'clang/<version number>'.
297-
set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
298-
if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")
299-
set(LLDB_EXTERNAL_CLANG_RESOURCE_DIR "${CANDIDATE_RESOURCE_DIR}")
300-
break()
301-
endif()
302-
endforeach()
303-
304-
if (NOT LLDB_EXTERNAL_CLANG_RESOURCE_DIR)
305-
message(FATAL_ERROR "Expected directory for clang-resource headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
306-
endif()
307-
endif()
308-
309285
# Find Apple-specific libraries or frameworks that may be needed.
310286
if (APPLE)
311287
if(NOT APPLE_EMBEDDED)

lldb/cmake/modules/LLDBStandalone.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,16 @@ endif()
128128
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
129129
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
130130
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
131+
132+
# If LLDB is building against a prebuilt Clang, then the Clang resource
133+
# directory that LLDB is using for its embedded Clang instance needs to point to
134+
# the resource directory of the used Clang installation.
135+
if (NOT TARGET clang-resource-headers)
136+
include(GetClangResourceDir)
137+
get_clang_resource_dir(LLDB_EXTERNAL_CLANG_RESOURCE_DIR
138+
PREFIX "${Clang_DIR}/../../../")
139+
140+
if (NOT EXISTS ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR})
141+
message(FATAL_ERROR "Expected directory for clang-resource-headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
142+
endif()
143+
endif()

0 commit comments

Comments
 (0)