[docs] Fix build-docs.sh
[llvm-project.git] / llvm / runtimes / CMakeLists.txt
blob4665864f485aa09b173ae836d1569f6d125278f2
1 # TODO: This file assumes the Clang toolchain so it'd be better if it lived in
2 # Clang, except there already is clang/runtime directory which contains
3 # similar although simpler functionality. We should figure out how to merge
4 # the two files.
6 set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON")
7 foreach(proj ${LLVM_ENABLE_RUNTIMES})
8   set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
9   if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
10     list(APPEND runtimes ${proj_dir})
11   else()
12     message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
13   endif()
14   string(TOUPPER "${proj}" canon_name)
15   STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
16   set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
17 endforeach()
19 function(get_compiler_rt_path path)
20   foreach(entry ${runtimes})
21     get_filename_component(projName ${entry} NAME)
22     if("${projName}" MATCHES "compiler-rt")
23       set(${path} ${entry} PARENT_SCOPE)
24       return()
25     endif()
26   endforeach()
27 endfunction()
29 include(LLVMExternalProjectUtils)
31 if(NOT LLVM_BUILD_RUNTIMES)
32   set(EXTRA_ARGS EXCLUDE_FROM_ALL)
33 endif()
35 function(check_apple_target triple builtin_or_runtime)
36   set(error "\
37 compiler-rt for Darwin builds for all platforms and architectures using a \
38 single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \
39 in your targets list (and not a triple for a specific platform such as macos). \
40 You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \
41 control the specific platforms and architectures to build.")
43   set(seen_property ${builtin_or_runtime}_darwin_triple_seen)
44   string(REPLACE "-" ";" triple_components ${triple})
45   foreach(component ${triple_components})
46     string(TOLOWER "${component}" component_lower)
47     if(component_lower MATCHES "^darwin")
48       get_property(darwin_triple_seen GLOBAL PROPERTY ${seen_property})
49       if(darwin_triple_seen)
50         message(FATAL_ERROR "${error}")
51       endif()
52       set_property(GLOBAL PROPERTY ${seen_property} YES)
53       if(NOT RUNTIMES_BUILD_ALLOW_DARWIN)
54         message(FATAL_ERROR "\
55 ${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
56       endif()
57     elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos")
58       message(FATAL_ERROR "${error}")
59     endif()
60   endforeach()
61 endfunction()
63 function(builtin_default_target compiler_rt_path)
64   cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
66   set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
67   # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
68   if (LLVM_TARGET_TRIPLE MATCHES "aix")
69     set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
70   endif()
72   llvm_ExternalProject_Add(builtins
73                            ${compiler_rt_path}/lib/builtins
74                            DEPENDS ${ARG_DEPENDS}
75                            CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
76                                       -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
77                                       -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
78                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
79                                       -DCMAKE_C_COMPILER_WORKS=ON
80                                       -DCMAKE_ASM_COMPILER_WORKS=ON
81                                       ${COMMON_CMAKE_ARGS}
82                                       ${BUILTINS_CMAKE_ARGS}
83                            PASSTHROUGH_PREFIXES COMPILER_RT
84                                                 DARWIN
85                                                 SANITIZER
86                            USE_TOOLCHAIN
87                            TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
88                            ${EXTRA_ARGS})
89 endfunction()
91 function(builtin_register_target compiler_rt_path target)
92   cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
94   check_apple_target(${target} builtin)
96   get_cmake_property(variableNames VARIABLES)
97   foreach(variableName ${variableNames})
98     string(FIND "${variableName}" "BUILTINS_${target}" out)
99     if("${out}" EQUAL 0)
100       string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
101       string(REPLACE ";" "|" new_value "${${variableName}}")
102       list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
103     endif()
104   endforeach()
106   llvm_ExternalProject_Add(builtins-${target}
107                            ${compiler_rt_path}/lib/builtins
108                            DEPENDS ${ARG_DEPENDS}
109                            CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
110                                       -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
111                                       -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
112                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
113                                       -DCMAKE_C_COMPILER_WORKS=ON
114                                       -DCMAKE_ASM_COMPILER_WORKS=ON
115                                       -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
116                                       ${COMMON_CMAKE_ARGS}
117                                       ${${target}_extra_args}
118                            USE_TOOLCHAIN
119                            TARGET_TRIPLE ${target}
120                            ${EXTRA_ARGS})
121 endfunction()
123 # If compiler-rt is present we need to build the builtin libraries first. This
124 # is required because the other runtimes need the builtin libraries present
125 # before the just-built compiler can pass the configuration tests.
126 get_compiler_rt_path(compiler_rt_path)
127 if(compiler_rt_path)
128   if(NOT LLVM_BUILTIN_TARGETS)
129     builtin_default_target(${compiler_rt_path}
130       DEPENDS clang-resource-headers)
131   else()
132     if("default" IN_LIST LLVM_BUILTIN_TARGETS)
133       builtin_default_target(${compiler_rt_path}
134         DEPENDS clang-resource-headers)
135       list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
136     else()
137       add_custom_target(builtins)
138       add_custom_target(install-builtins)
139       add_custom_target(install-builtins-stripped)
140     endif()
142     foreach(target ${LLVM_BUILTIN_TARGETS})
143       builtin_register_target(${compiler_rt_path} ${target}
144         DEPENDS clang-resource-headers)
146       add_dependencies(builtins builtins-${target})
147       add_dependencies(install-builtins install-builtins-${target})
148       add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
149     endforeach()
150   endif()
151   set(deps builtins)
152   # We don't need to depend on the builtins if we're building instrumented
153   # because the next stage will use the same compiler used to build this stage.
154   if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
155     add_dependencies(clang-bootstrap-deps builtins)
156   endif()
157 endif()
159 # Create a list with the names of all the runtime projects in all uppercase and
160 # with dashes turned to underscores. This gives us the CMake variable `prefixes`
161 # for all variables that will apply to runtimes.
162 foreach(entry ${runtimes})
163   get_filename_component(projName ${entry} NAME)
164   if(projName STREQUAL "libc")
165     # For now, we will use the name "llvmlibc" for the libc project as it is
166     # not a full libc yet. Also, if we leave it as is, the "lib" prefix gets
167     # stripped below and the targets endup having the name "c", "check-c" etc.
168     set(projName "llvmlibc")
169   endif()
170   string(REPLACE "-" "_" canon_name ${projName})
171   string(TOUPPER ${canon_name} canon_name)
172   list(APPEND prefixes ${canon_name})
173   if (${canon_name} STREQUAL "OPENMP")
174     list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
175   endif()
176   # Many compiler-rt options start with SANITIZER_ and DARWIN_ rather than
177   # COMPILER_RT_, so when compiler-rt is enabled, consider both.
178   if(canon_name STREQUAL "COMPILER_RT")
179     list(APPEND prefixes SANITIZER DARWIN)
180   endif()
182   string(FIND ${projName} "lib" LIB_IDX)
183   if(LIB_IDX EQUAL 0)
184     string(SUBSTRING ${projName} 3 -1 projName)
185   endif()
186   list(APPEND runtime_names ${projName})
187 endforeach()
189 function(runtime_default_target)
190   cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN})
192   include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
193   set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
194   set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
196   foreach(runtime_name ${runtime_names})
197     list(APPEND extra_targets
198       ${runtime_name}
199       install-${runtime_name}
200       install-${runtime_name}-stripped)
201     if(LLVM_INCLUDE_TESTS)
202       list(APPEND test_targets check-${runtime_name})
203     endif()
204   endforeach()
205   foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
206     if(NOT ${component} IN_LIST SUB_COMPONENTS)
207       list(APPEND extra_targets install-${component} install-${component}-stripped)
208     endif()
209   endforeach()
211   if(LLVM_INCLUDE_TESTS)
212     include(${LLVM_BINARY_DIR}/runtimes/Tests.cmake OPTIONAL RESULT_VARIABLE have_tests)
213     set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Tests.cmake)
214     if(have_tests)
215       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES ${SUB_LIT_TESTSUITES})
216       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_PARAMS ${SUB_LIT_PARAMS})
217       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_EXTRA_ARGS ${SUB_LIT_EXTRA_ARGS})
218     endif()
219     list(APPEND test_targets runtimes-test-depends check-runtimes)
220   endif()
222   set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
223   # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
224   if (LLVM_TARGET_TRIPLE MATCHES "aix")
225     set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
226   endif()
228   llvm_ExternalProject_Add(runtimes
229                            ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
230                            DEPENDS ${ARG_DEPENDS}
231                            # Builtins were built separately above
232                            CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
233                                       -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
234                                       -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
235                                       -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
236                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
237                                       -DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
238                                       -DCMAKE_C_COMPILER_WORKS=ON
239                                       -DCMAKE_CXX_COMPILER_WORKS=ON
240                                       -DCMAKE_ASM_COMPILER_WORKS=ON
241                                       ${COMMON_CMAKE_ARGS}
242                                       ${RUNTIMES_CMAKE_ARGS}
243                            PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
244                                                 LLVM_USE_LINKER
245                                                 ${ARG_PREFIXES}
246                            EXTRA_TARGETS ${extra_targets}
247                                          ${test_targets}
248                                          ${SUB_COMPONENTS}
249                                          ${SUB_CHECK_TARGETS}
250                                          ${SUB_INSTALL_TARGETS}
251                            USE_TOOLCHAIN
252                            TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
253                            ${EXTRA_ARGS})
254 endfunction()
256 # runtime_register_target(target)
257 #   Utility function to register external runtime target.
258 function(runtime_register_target name target)
259   cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
260   include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
261   set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
263   check_apple_target(${target} runtime)
265   set(${name}_deps ${ARG_DEPENDS})
266   if(NOT name STREQUAL target)
267     list(APPEND ${name}_deps runtimes-${target})
268   endif()
270   foreach(runtime_name ${runtime_names})
271     set(${runtime_name}-${name} ${runtime_name})
272     set(install-${runtime_name}-${name} install-${runtime_name})
273     set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
274     list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
275     if(LLVM_INCLUDE_TESTS)
276       set(check-${runtime_name}-${name} check-${runtime_name} )
277       list(APPEND ${name}_test_targets check-${runtime_name}-${name})
278     endif()
279   endforeach()
281   foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
282     set(${target_name}-${name} ${target_name})
283     list(APPEND ${name}_extra_targets ${target_name}-${name})
284   endforeach()
286   foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
287     set(${component}-${name} ${component})
288     set(install-${component}-${name} install-${component})
289     set(install-${component}-${name}-stripped install-${component}-stripped)
290     list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name} install-${component}-${name}-stripped)
291   endforeach()
293   if(LLVM_INCLUDE_TESTS)
294     include(${LLVM_BINARY_DIR}/runtimes/${name}/Tests.cmake OPTIONAL RESULT_VARIABLE have_tests)
295     set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Tests.cmake)
296     if(have_tests)
297       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES ${SUB_LIT_TESTSUITES})
298       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_PARAMS ${SUB_LIT_PARAMS})
299       set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_EXTRA_ARGS ${SUB_LIT_EXTRA_ARGS})
300     endif()
301     set(runtimes-test-depends-${name} runtimes-test-depends)
302     set(check-runtimes-${name} check-runtimes)
303     list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
304     list(APPEND test_targets ${${name}_test_targets})
305     foreach(target_name IN LISTS SUB_CHECK_TARGETS)
306       set(${target_name}-${name} ${target_name})
307       list(APPEND ${name}_test_targets ${target_name}-${name})
308       list(APPEND test_targets ${target_name}-${name})
309     endforeach()
310     set(test_targets "${test_targets}" PARENT_SCOPE)
311   endif()
313   set(${name}_extra_args ${ARG_CMAKE_ARGS})
314   get_cmake_property(variableNames VARIABLES)
315   foreach(variableName ${variableNames})
316     string(FIND "${variableName}" "RUNTIMES_${target}_" out)
317     if("${out}" EQUAL 0)
318       string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
319       string(REPLACE ";" "|" new_value "${${variableName}}")
320       list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
321     endif()
322   endforeach()
323   if(NOT "${name}" STREQUAL "${target}")
324     foreach(variableName ${variableNames})
325       string(FIND "${variableName}" "RUNTIMES_${name}_" out)
326       if("${out}" EQUAL 0)
327         string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
328         string(REPLACE ";" "|" new_value "${${variableName}}")
329         list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
330       endif()
331     endforeach()
332   endif()
334   if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
335     string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
336     list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
337   endif()
339   if(NOT RUNTIMES_${name}_LLVM_USE_LINKER AND NOT RUNTIMES_${target}_LLVM_USE_LINKER)
340     list(APPEND ${name}_extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER})
341   endif()
343   llvm_ExternalProject_Add(runtimes-${name}
344                            ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
345                            DEPENDS ${${name}_deps}
346                            # Builtins were built separately above
347                            CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
348                                       -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
349                                       -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
350                                       -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
351                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
352                                       -DCMAKE_C_COMPILER_WORKS=ON
353                                       -DCMAKE_CXX_COMPILER_WORKS=ON
354                                       -DCMAKE_ASM_COMPILER_WORKS=ON
355                                       -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
356                                       -DLLVM_RUNTIMES_TARGET=${name}
357                                       ${COMMON_CMAKE_ARGS}
358                                       ${${name}_extra_args}
359                            EXTRA_TARGETS ${${name}_extra_targets}
360                                          ${${name}_test_targets}
361                            USE_TOOLCHAIN
362                            TARGET_TRIPLE ${target}
363                            ${EXTRA_ARGS})
364 endfunction()
366 if(runtimes)
367   # Create a runtimes target that uses this file as its top-level CMake file.
368   # The runtimes target is a configuration of all the runtime libraries
369   # together in a single CMake invocaiton.
370   set(extra_deps "")
371   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
372     if(TARGET opt)
373       list(APPEND extra_deps opt)
374     endif()
375     if(TARGET llvm-link)
376       list(APPEND extra_deps llvm-link)
377     endif()
378   endif()
379   if(NOT LLVM_RUNTIME_TARGETS)
380     runtime_default_target(
381       DEPENDS ${deps} ${extra_deps}
382       PREFIXES ${prefixes})
383     set(test_targets check-runtimes)
384   else()
385     if("default" IN_LIST LLVM_RUNTIME_TARGETS)
386       runtime_default_target(
387         DEPENDS ${deps} ${extra_deps}
388         PREFIXES ${prefixes})
389       list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
390     else()
391       add_custom_target(runtimes)
392       add_custom_target(runtimes-configure)
393       add_custom_target(install-runtimes)
394       add_custom_target(install-runtimes-stripped)
395       if(LLVM_INCLUDE_TESTS)
396         add_custom_target(check-runtimes)
397         add_custom_target(runtimes-test-depends)
398         set(test_targets "")
399       endif()
400       foreach(runtime_name ${runtime_names})
401         add_custom_target(${runtime_name})
402         add_custom_target(install-${runtime_name})
403         add_custom_target(install-${runtime_name}-stripped)
404       endforeach()
405       if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
406         foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
407           add_custom_target(${component})
408           add_custom_target(install-${component})
409           add_custom_target(install-${component}-stripped)
410         endforeach()
411       endif()
412     endif()
414     foreach(name ${LLVM_RUNTIME_TARGETS})
415       runtime_register_target(${name} ${name}
416         DEPENDS ${deps})
418       add_dependencies(runtimes runtimes-${name})
419       add_dependencies(runtimes-configure runtimes-${name}-configure)
420       add_dependencies(install-runtimes install-runtimes-${name})
421       add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
422       if(LLVM_INCLUDE_TESTS)
423         add_dependencies(check-runtimes check-runtimes-${name})
424         add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
425       endif()
426       foreach(runtime_name ${runtime_names})
427         add_dependencies(${runtime_name} ${runtime_name}-${name})
428         add_dependencies(install-${runtime_name} install-${runtime_name}-${name})
429         add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}-stripped)
430       endforeach()
431       foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
432         add_dependencies(${component} ${component}-${name})
433         add_dependencies(install-${component} install-${component}-${name})
434         add_dependencies(install-${component}-stripped install-${component}-${name}-stripped)
435       endforeach()
436     endforeach()
438     foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
439       foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
440         runtime_register_target(${name}+${multilib} ${name}
441           DEPENDS runtimes-${name}
442           CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
443                      -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
444         add_dependencies(runtimes runtimes-${name}+${multilib})
445         add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
446         add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
447         add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
448         foreach(runtime_name ${runtime_names})
449           add_dependencies(${runtime_name} ${runtime_name}-${name}+${multilib})
450           add_dependencies(install-${runtime_name} install-${runtime_name}-${name}+${multilib})
451           add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}+${multilib}-stripped)
452         endforeach()
453         foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
454           add_dependencies(${component} ${component}-${name}+${multilib})
455           add_dependencies(install-${component} install-${component}-${name}+${multilib})
456           add_dependencies(install-${component}-stripped install-${component}-${name}+${multilib}-stripped)
457         endforeach()
458       endforeach()
459     endforeach()
460   endif()
462   if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
463     # TODO: This is a hack needed because the libcxx headers are copied into the
464     # build directory during configuration. Without that step the clang in the
465     # build directory cannot find the C++ headers in certain configurations.
466     # I need to build a mechanism for runtime projects to provide CMake code
467     # that executes at LLVM configuration time to handle this case.
468     add_dependencies(clang-bootstrap-deps runtimes-configure)
469     # We need to add the runtimes as a dependency because compiler-rt can be
470     # built as part of runtimes and we need the profile runtime for PGO
471     add_dependencies(clang-bootstrap-deps runtimes)
472   endif()
474   if(LLVM_INCLUDE_TESTS)
475     set_property(GLOBAL APPEND PROPERTY LLVM_ALL_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
477     set(RUNTIMES_TEST_DEPENDS
478         FileCheck
479         count
480         llvm-nm
481         llvm-objdump
482         llvm-xray
483         not
484         obj2yaml
485         sancov
486         sanstats
487         llvm_gtest_main
488         llvm_gtest
489       )
490     foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
491       add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
492     endforeach()
493   endif()
494 endif()