|
1 | 1 | # This file handles building LLVM runtime sub-projects.
|
2 | 2 | cmake_minimum_required(VERSION 3.20.0)
|
3 | 3 |
|
| 4 | +# This file can be used in two ways: the bootstrapping build calls it from |
| 5 | +# llvm/runtimes/CMakeLists.txt where we reuse the build tree of the top-level |
| 6 | +# build or it can be directly invoked in this directory. In the latter case we |
| 7 | +# might be building against a LLVM install tree and might not have a valid build |
| 8 | +# tree set up yet. We can detect whether we are using the bootstrapping build |
| 9 | +# by checking for the HAVE_LLVM_LIT flag that is passed explicitly to |
| 10 | +# llvm_ExternalProject_Add(). |
| 11 | +if (HAVE_LLVM_LIT) |
| 12 | + message(STATUS "Performing bootstrapping runtimes build.") |
| 13 | +else() |
| 14 | + message(STATUS "Performing standalone runtimes build.") |
| 15 | +endif() |
4 | 16 | # Add path for custom and the LLVM build's modules to the CMake module path.
|
5 | 17 | set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
6 | 18 | include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
|
@@ -236,6 +248,25 @@ foreach(entry ${runtimes})
|
236 | 248 | endforeach()
|
237 | 249 |
|
238 | 250 | if(LLVM_INCLUDE_TESTS)
|
| 251 | + # If built with the runtimes build (rooted at runtimes/CMakeLists.txt), we |
| 252 | + # won't have llvm-lit. If built with the bootstrapping build (rooted at |
| 253 | + # llvm/CMakeLists.txt), the top-level llvm CMake invocation already generated |
| 254 | + # the llvm-lit script. |
| 255 | + if (NOT HAVE_LLVM_LIT) |
| 256 | + # Ensure that the appropriate variables for lit are set before adding any |
| 257 | + # runtimes since their CMake tests configuration might depend on lit being |
| 258 | + # present. This ensures that the testsuites use a local lit from the build |
| 259 | + # dir rather than ${LLVM_INSTALL_DIR}/bin/llvm-lit (which may not exist if |
| 260 | + # LLVM_BINARY_DIR points at an installed LLVM tree rather than a build tree). |
| 261 | + set(LLVM_LIT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin) |
| 262 | + get_llvm_lit_path(_base_dir _file_name) |
| 263 | + set(LLVM_EXTERNAL_LIT "${_base_dir}/${_file_name}" CACHE STRING "Command used to spawn lit" FORCE) |
| 264 | + # Avoid warning about missing llvm-lit from runtimes CMake files. This is |
| 265 | + # fine since we call configure_file() to create llvm-lit at the end of this |
| 266 | + # file (after recursing into all runtimes' CMake logic), so it will exist. |
| 267 | + set(LLVM_EXTERNAL_LIT_MISSING_WARNED_ONCE YES CACHE INTERNAL "") |
| 268 | + endif() |
| 269 | + |
239 | 270 | set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
|
240 | 271 | if (MSVC OR XCODE)
|
241 | 272 | set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
@@ -273,6 +304,8 @@ if(LLVM_INCLUDE_TESTS)
|
273 | 304 | # If built by manually invoking cmake on this directory, we don't have
|
274 | 305 | # llvm-lit. If invoked via llvm/runtimes, the toplevel llvm cmake
|
275 | 306 | # invocation already generated the llvm-lit script.
|
| 307 | + # NOTE: this must be called after all testsuites have been added, since |
| 308 | + # otherwise the generated llvm-lit does not have all required path mappings. |
276 | 309 | add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
|
277 | 310 | ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
|
278 | 311 | endif()
|
@@ -306,10 +339,10 @@ if(SUB_COMPONENTS)
|
306 | 339 | if(LLVM_RUNTIMES_TARGET)
|
307 | 340 | configure_file(
|
308 | 341 | ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
|
309 |
| - ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake) |
| 342 | + ${CMAKE_CURRENT_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake) |
310 | 343 | else()
|
311 | 344 | configure_file(
|
312 | 345 | ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
|
313 |
| - ${LLVM_BINARY_DIR}/runtimes/Components.cmake) |
| 346 | + ${CMAKE_CURRENT_BINARY_DIR}/runtimes/Components.cmake) |
314 | 347 | endif()
|
315 | 348 | endif()
|
0 commit comments