Skip to content

Commit 3d577f8

Browse files
rjodinchrgithub-actions[bot]
authored andcommitted
Automerge: [clang] fix clang_cmake_builddir (#155844)
When building llvm from a subdirectory (like clspv does) `CMAKE_BINARY_DIR` is at the top of the build directory. When building runtimes (libclc for example), the build fails looking for clang (through `find_package` looking at `LLVM_BINARY_DIR` with `NO_DEFAULT_PATH` & `NO_CMAKE_FIND_ROOT_PATH`) because clang is not in `LLVM_BINARY_DIR`. Fix that issue by setting `clang_cmake_builddir` the same way we set `llvm_cmake_builddir` from `LLVM_BINARY_DIR`. For default llvm build (using llvm as the main cmake project), it should not change anything.
2 parents 6f68637 + 61664b6 commit 3d577f8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

clang/cmake/modules/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ include(FindPrefixFromConfig)
88
# the usual CMake convention seems to be ${Project}Targets.cmake.
99
set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING
1010
"Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')")
11-
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
12-
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")
1311

1412
# Keep this in sync with llvm/cmake/CMakeLists.txt!
1513
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
1614
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
1715
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
18-
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
19-
set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
16+
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_builddir "${LLVM_LIBRARY_DIR}")
17+
set(llvm_cmake_builddir "${llvm_builddir}/cmake/llvm")
18+
set(clang_cmake_builddir "${llvm_builddir}/cmake/clang")
2019

2120
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
2221
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)

0 commit comments

Comments
 (0)