106f32e7eSjoergfunction(get_system_libs return_var)
206f32e7eSjoerg  message(AUTHOR_WARNING "get_system_libs no longer needed")
306f32e7eSjoerg  set(${return_var} "" PARENT_SCOPE)
406f32e7eSjoergendfunction()
506f32e7eSjoerg
606f32e7eSjoerg
706f32e7eSjoergfunction(link_system_libs target)
806f32e7eSjoerg  message(AUTHOR_WARNING "link_system_libs no longer needed")
906f32e7eSjoergendfunction()
1006f32e7eSjoerg
1106f32e7eSjoerg# is_llvm_target_library(
1206f32e7eSjoerg#   library
1306f32e7eSjoerg#     Name of the LLVM library to check
1406f32e7eSjoerg#   return_var
1506f32e7eSjoerg#     Output variable name
1606f32e7eSjoerg#   ALL_TARGETS;INCLUDED_TARGETS;OMITTED_TARGETS
1706f32e7eSjoerg#     ALL_TARGETS - default looks at the full list of known targets
1806f32e7eSjoerg#     INCLUDED_TARGETS - looks only at targets being configured
1906f32e7eSjoerg#     OMITTED_TARGETS - looks only at targets that are not being configured
2006f32e7eSjoerg# )
2106f32e7eSjoergfunction(is_llvm_target_library library return_var)
2206f32e7eSjoerg  cmake_parse_arguments(ARG "ALL_TARGETS;INCLUDED_TARGETS;OMITTED_TARGETS" "" "" ${ARGN})
2306f32e7eSjoerg  # Sets variable `return_var' to ON if `library' corresponds to a
2406f32e7eSjoerg  # LLVM supported target. To OFF if it doesn't.
2506f32e7eSjoerg  set(${return_var} OFF PARENT_SCOPE)
2606f32e7eSjoerg  string(TOUPPER "${library}" capitalized_lib)
2706f32e7eSjoerg  if(ARG_INCLUDED_TARGETS)
2806f32e7eSjoerg    string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" targets)
2906f32e7eSjoerg  elseif(ARG_OMITTED_TARGETS)
3006f32e7eSjoerg    set(omitted_targets ${LLVM_ALL_TARGETS})
31*da58b97aSjoerg    if (LLVM_TARGETS_TO_BUILD)
3206f32e7eSjoerg      list(REMOVE_ITEM omitted_targets ${LLVM_TARGETS_TO_BUILD})
33*da58b97aSjoerg    endif()
3406f32e7eSjoerg    string(TOUPPER "${omitted_targets}" targets)
3506f32e7eSjoerg  else()
3606f32e7eSjoerg    string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
3706f32e7eSjoerg  endif()
3806f32e7eSjoerg  foreach(t ${targets})
3906f32e7eSjoerg    if( capitalized_lib STREQUAL t OR
4006f32e7eSjoerg        capitalized_lib STREQUAL "${t}" OR
4106f32e7eSjoerg        capitalized_lib STREQUAL "${t}DESC" OR
4206f32e7eSjoerg        capitalized_lib STREQUAL "${t}CODEGEN" OR
4306f32e7eSjoerg        capitalized_lib STREQUAL "${t}ASMPARSER" OR
4406f32e7eSjoerg        capitalized_lib STREQUAL "${t}ASMPRINTER" OR
4506f32e7eSjoerg        capitalized_lib STREQUAL "${t}DISASSEMBLER" OR
4606f32e7eSjoerg        capitalized_lib STREQUAL "${t}INFO" OR
4706f32e7eSjoerg        capitalized_lib STREQUAL "${t}UTILS" )
4806f32e7eSjoerg      set(${return_var} ON PARENT_SCOPE)
4906f32e7eSjoerg      break()
5006f32e7eSjoerg    endif()
5106f32e7eSjoerg  endforeach()
5206f32e7eSjoergendfunction(is_llvm_target_library)
5306f32e7eSjoerg
5406f32e7eSjoergfunction(is_llvm_target_specifier library return_var)
5506f32e7eSjoerg  is_llvm_target_library(${library} ${return_var} ${ARGN})
5606f32e7eSjoerg  string(TOUPPER "${library}" capitalized_lib)
5706f32e7eSjoerg  if(NOT ${return_var})
5806f32e7eSjoerg    if( capitalized_lib STREQUAL "ALLTARGETSASMPARSERS" OR
5906f32e7eSjoerg        capitalized_lib STREQUAL "ALLTARGETSDESCS" OR
6006f32e7eSjoerg        capitalized_lib STREQUAL "ALLTARGETSDISASSEMBLERS" OR
6106f32e7eSjoerg        capitalized_lib STREQUAL "ALLTARGETSINFOS" OR
6206f32e7eSjoerg        capitalized_lib STREQUAL "NATIVE" OR
6306f32e7eSjoerg        capitalized_lib STREQUAL "NATIVECODEGEN" )
6406f32e7eSjoerg      set(${return_var} ON PARENT_SCOPE)
6506f32e7eSjoerg    endif()
6606f32e7eSjoerg  endif()
6706f32e7eSjoergendfunction()
6806f32e7eSjoerg
6906f32e7eSjoergmacro(llvm_config executable)
7006f32e7eSjoerg  cmake_parse_arguments(ARG "USE_SHARED" "" "" ${ARGN})
7106f32e7eSjoerg  set(link_components ${ARG_UNPARSED_ARGUMENTS})
7206f32e7eSjoerg
7306f32e7eSjoerg  if(ARG_USE_SHARED)
7406f32e7eSjoerg    # If USE_SHARED is specified, then we link against libLLVM,
7506f32e7eSjoerg    # but also against the component libraries below. This is
7606f32e7eSjoerg    # done in case libLLVM does not contain all of the components
7706f32e7eSjoerg    # the target requires.
7806f32e7eSjoerg    #
7906f32e7eSjoerg    # Strip LLVM_DYLIB_COMPONENTS out of link_components.
8006f32e7eSjoerg    # To do this, we need special handling for "all", since that
8106f32e7eSjoerg    # may imply linking to libraries that are not included in
8206f32e7eSjoerg    # libLLVM.
8306f32e7eSjoerg
8406f32e7eSjoerg    if (DEFINED link_components AND DEFINED LLVM_DYLIB_COMPONENTS)
8506f32e7eSjoerg      if("${LLVM_DYLIB_COMPONENTS}" STREQUAL "all")
8606f32e7eSjoerg        set(link_components "")
8706f32e7eSjoerg      else()
8806f32e7eSjoerg        list(REMOVE_ITEM link_components ${LLVM_DYLIB_COMPONENTS})
8906f32e7eSjoerg      endif()
9006f32e7eSjoerg    endif()
9106f32e7eSjoerg
9206f32e7eSjoerg    target_link_libraries(${executable} PRIVATE LLVM)
9306f32e7eSjoerg  endif()
9406f32e7eSjoerg
9506f32e7eSjoerg  explicit_llvm_config(${executable} ${link_components})
9606f32e7eSjoergendmacro(llvm_config)
9706f32e7eSjoerg
9806f32e7eSjoerg
9906f32e7eSjoergfunction(explicit_llvm_config executable)
10006f32e7eSjoerg  set( link_components ${ARGN} )
10106f32e7eSjoerg
10206f32e7eSjoerg  llvm_map_components_to_libnames(LIBRARIES ${link_components})
10306f32e7eSjoerg  get_target_property(t ${executable} TYPE)
10406f32e7eSjoerg  if(t STREQUAL "STATIC_LIBRARY")
10506f32e7eSjoerg    target_link_libraries(${executable} INTERFACE ${LIBRARIES})
10606f32e7eSjoerg  elseif(t STREQUAL "EXECUTABLE" OR t STREQUAL "SHARED_LIBRARY" OR t STREQUAL "MODULE_LIBRARY")
10706f32e7eSjoerg    target_link_libraries(${executable} PRIVATE ${LIBRARIES})
10806f32e7eSjoerg  else()
10906f32e7eSjoerg    # Use plain form for legacy user.
11006f32e7eSjoerg    target_link_libraries(${executable} ${LIBRARIES})
11106f32e7eSjoerg  endif()
11206f32e7eSjoergendfunction(explicit_llvm_config)
11306f32e7eSjoerg
11406f32e7eSjoerg
11506f32e7eSjoerg# This is Deprecated
11606f32e7eSjoergfunction(llvm_map_components_to_libraries OUT_VAR)
11706f32e7eSjoerg  message(AUTHOR_WARNING "Using llvm_map_components_to_libraries() is deprecated. Use llvm_map_components_to_libnames() instead")
11806f32e7eSjoerg  explicit_map_components_to_libraries(result ${ARGN})
11906f32e7eSjoerg  set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
12006f32e7eSjoergendfunction(llvm_map_components_to_libraries)
12106f32e7eSjoerg
12206f32e7eSjoerg# Expand pseudo-components into real components.
12306f32e7eSjoerg# Does not cover 'native', 'backend', or 'engine' as these require special
12406f32e7eSjoerg# handling. Also does not cover 'all' as we only have a list of the libnames
12506f32e7eSjoerg# available and not a list of the components.
12606f32e7eSjoergfunction(llvm_expand_pseudo_components out_components)
12706f32e7eSjoerg  set( link_components ${ARGN} )
12806f32e7eSjoerg  foreach(c ${link_components})
12906f32e7eSjoerg    # add codegen, asmprinter, asmparser, disassembler
13006f32e7eSjoerg    list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
13106f32e7eSjoerg    if( NOT idx LESS 0 )
13206f32e7eSjoerg      if( TARGET LLVM${c}CodeGen )
13306f32e7eSjoerg        list(APPEND expanded_components "${c}CodeGen")
13406f32e7eSjoerg      else()
13506f32e7eSjoerg        if( TARGET LLVM${c} )
13606f32e7eSjoerg          list(APPEND expanded_components "${c}")
13706f32e7eSjoerg        else()
13806f32e7eSjoerg          message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
13906f32e7eSjoerg        endif()
14006f32e7eSjoerg      endif()
14106f32e7eSjoerg      if( TARGET LLVM${c}AsmPrinter )
14206f32e7eSjoerg        list(APPEND expanded_components "${c}AsmPrinter")
14306f32e7eSjoerg      endif()
14406f32e7eSjoerg      if( TARGET LLVM${c}AsmParser )
14506f32e7eSjoerg        list(APPEND expanded_components "${c}AsmParser")
14606f32e7eSjoerg      endif()
14706f32e7eSjoerg      if( TARGET LLVM${c}Desc )
14806f32e7eSjoerg        list(APPEND expanded_components "${c}Desc")
14906f32e7eSjoerg      endif()
15006f32e7eSjoerg      if( TARGET LLVM${c}Disassembler )
15106f32e7eSjoerg        list(APPEND expanded_components "${c}Disassembler")
15206f32e7eSjoerg      endif()
15306f32e7eSjoerg      if( TARGET LLVM${c}Info )
15406f32e7eSjoerg        list(APPEND expanded_components "${c}Info")
15506f32e7eSjoerg      endif()
15606f32e7eSjoerg      if( TARGET LLVM${c}Utils )
15706f32e7eSjoerg        list(APPEND expanded_components "${c}Utils")
15806f32e7eSjoerg      endif()
15906f32e7eSjoerg    elseif( c STREQUAL "nativecodegen" )
16006f32e7eSjoerg      if( TARGET LLVM${LLVM_NATIVE_ARCH}CodeGen )
16106f32e7eSjoerg        list(APPEND expanded_components "${LLVM_NATIVE_ARCH}CodeGen")
16206f32e7eSjoerg      endif()
16306f32e7eSjoerg      if( TARGET LLVM${LLVM_NATIVE_ARCH}Desc )
16406f32e7eSjoerg        list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Desc")
16506f32e7eSjoerg      endif()
16606f32e7eSjoerg      if( TARGET LLVM${LLVM_NATIVE_ARCH}Info )
16706f32e7eSjoerg        list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Info")
16806f32e7eSjoerg      endif()
16906f32e7eSjoerg    elseif( c STREQUAL "AllTargetsCodeGens" )
17006f32e7eSjoerg      # Link all the codegens from all the targets
17106f32e7eSjoerg      foreach(t ${LLVM_TARGETS_TO_BUILD})
17206f32e7eSjoerg        if( TARGET LLVM${t}CodeGen)
17306f32e7eSjoerg          list(APPEND expanded_components "${t}CodeGen")
17406f32e7eSjoerg        endif()
17506f32e7eSjoerg      endforeach(t)
17606f32e7eSjoerg    elseif( c STREQUAL "AllTargetsAsmParsers" )
17706f32e7eSjoerg      # Link all the asm parsers from all the targets
17806f32e7eSjoerg      foreach(t ${LLVM_TARGETS_TO_BUILD})
17906f32e7eSjoerg        if( TARGET LLVM${t}AsmParser )
18006f32e7eSjoerg          list(APPEND expanded_components "${t}AsmParser")
18106f32e7eSjoerg        endif()
18206f32e7eSjoerg      endforeach(t)
18306f32e7eSjoerg    elseif( c STREQUAL "AllTargetsDescs" )
18406f32e7eSjoerg      # Link all the descs from all the targets
18506f32e7eSjoerg      foreach(t ${LLVM_TARGETS_TO_BUILD})
18606f32e7eSjoerg        if( TARGET LLVM${t}Desc )
18706f32e7eSjoerg          list(APPEND expanded_components "${t}Desc")
18806f32e7eSjoerg        endif()
18906f32e7eSjoerg      endforeach(t)
19006f32e7eSjoerg    elseif( c STREQUAL "AllTargetsDisassemblers" )
19106f32e7eSjoerg      # Link all the disassemblers from all the targets
19206f32e7eSjoerg      foreach(t ${LLVM_TARGETS_TO_BUILD})
19306f32e7eSjoerg        if( TARGET LLVM${t}Disassembler )
19406f32e7eSjoerg          list(APPEND expanded_components "${t}Disassembler")
19506f32e7eSjoerg        endif()
19606f32e7eSjoerg      endforeach(t)
19706f32e7eSjoerg    elseif( c STREQUAL "AllTargetsInfos" )
19806f32e7eSjoerg      # Link all the infos from all the targets
19906f32e7eSjoerg      foreach(t ${LLVM_TARGETS_TO_BUILD})
20006f32e7eSjoerg        if( TARGET LLVM${t}Info )
20106f32e7eSjoerg          list(APPEND expanded_components "${t}Info")
20206f32e7eSjoerg        endif()
20306f32e7eSjoerg      endforeach(t)
20406f32e7eSjoerg    else()
20506f32e7eSjoerg      list(APPEND expanded_components "${c}")
20606f32e7eSjoerg    endif()
20706f32e7eSjoerg  endforeach()
20806f32e7eSjoerg  set(${out_components} ${expanded_components} PARENT_SCOPE)
20906f32e7eSjoergendfunction(llvm_expand_pseudo_components out_components)
21006f32e7eSjoerg
21106f32e7eSjoerg# This is a variant intended for the final user:
21206f32e7eSjoerg# Map LINK_COMPONENTS to actual libnames.
21306f32e7eSjoergfunction(llvm_map_components_to_libnames out_libs)
21406f32e7eSjoerg  set( link_components ${ARGN} )
21506f32e7eSjoerg  if(NOT LLVM_AVAILABLE_LIBS)
21606f32e7eSjoerg    # Inside LLVM itself available libs are in a global property.
21706f32e7eSjoerg    get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
21806f32e7eSjoerg  endif()
21906f32e7eSjoerg  string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
22006f32e7eSjoerg
22106f32e7eSjoerg  get_property(LLVM_TARGETS_CONFIGURED GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED)
22206f32e7eSjoerg
22306f32e7eSjoerg  # Generally in our build system we avoid order-dependence. Unfortunately since
22406f32e7eSjoerg  # not all targets create the same set of libraries we actually need to ensure
22506f32e7eSjoerg  # that all build targets associated with a target are added before we can
22606f32e7eSjoerg  # process target dependencies.
22706f32e7eSjoerg  if(NOT LLVM_TARGETS_CONFIGURED)
22806f32e7eSjoerg    foreach(c ${link_components})
22906f32e7eSjoerg      is_llvm_target_specifier(${c} iltl_result ALL_TARGETS)
23006f32e7eSjoerg      if(iltl_result)
23106f32e7eSjoerg        message(FATAL_ERROR "Specified target library before target registration is complete.")
23206f32e7eSjoerg      endif()
23306f32e7eSjoerg    endforeach()
23406f32e7eSjoerg  endif()
23506f32e7eSjoerg
23606f32e7eSjoerg  # Expand some keywords:
23706f32e7eSjoerg  list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
23806f32e7eSjoerg  list(FIND link_components "engine" engine_required)
23906f32e7eSjoerg  if( NOT engine_required EQUAL -1 )
24006f32e7eSjoerg    list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
24106f32e7eSjoerg    if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
24206f32e7eSjoerg      list(APPEND link_components "jit")
24306f32e7eSjoerg      list(APPEND link_components "native")
24406f32e7eSjoerg    else()
24506f32e7eSjoerg      list(APPEND link_components "interpreter")
24606f32e7eSjoerg    endif()
24706f32e7eSjoerg  endif()
24806f32e7eSjoerg  list(FIND link_components "native" native_required)
24906f32e7eSjoerg  if( NOT native_required EQUAL -1 )
25006f32e7eSjoerg    if( NOT have_native_backend EQUAL -1 )
25106f32e7eSjoerg      list(APPEND link_components ${LLVM_NATIVE_ARCH})
25206f32e7eSjoerg    endif()
25306f32e7eSjoerg  endif()
25406f32e7eSjoerg
25506f32e7eSjoerg  # Translate symbolic component names to real libraries:
25606f32e7eSjoerg  llvm_expand_pseudo_components(link_components ${link_components})
25706f32e7eSjoerg  foreach(c ${link_components})
258*da58b97aSjoerg    get_property(c_rename GLOBAL PROPERTY LLVM_COMPONENT_NAME_${c})
259*da58b97aSjoerg    if(c_rename)
260*da58b97aSjoerg        set(c ${c_rename})
261*da58b97aSjoerg    endif()
26206f32e7eSjoerg    if( c STREQUAL "native" )
26306f32e7eSjoerg      # already processed
26406f32e7eSjoerg    elseif( c STREQUAL "backend" )
26506f32e7eSjoerg      # same case as in `native'.
26606f32e7eSjoerg    elseif( c STREQUAL "engine" )
26706f32e7eSjoerg      # already processed
26806f32e7eSjoerg    elseif( c STREQUAL "all" )
269*da58b97aSjoerg      get_property(all_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS)
270*da58b97aSjoerg      list(APPEND expanded_components ${all_components})
271*da58b97aSjoerg    else()
27206f32e7eSjoerg      # Canonize the component name:
27306f32e7eSjoerg      string(TOUPPER "${c}" capitalized)
27406f32e7eSjoerg      list(FIND capitalized_libs LLVM${capitalized} lib_idx)
27506f32e7eSjoerg      if( lib_idx LESS 0 )
27606f32e7eSjoerg        # The component is unknown. Maybe is an omitted target?
27706f32e7eSjoerg        is_llvm_target_library(${c} iltl_result OMITTED_TARGETS)
27806f32e7eSjoerg        if(iltl_result)
27906f32e7eSjoerg          # A missing library to a directly referenced omitted target would be bad.
28006f32e7eSjoerg          message(FATAL_ERROR "Library '${c}' is a direct reference to a target library for an omitted target.")
28106f32e7eSjoerg        else()
28206f32e7eSjoerg          # If it is not an omitted target we should assume it is a component
28306f32e7eSjoerg          # that hasn't yet been processed by CMake. Missing components will
28406f32e7eSjoerg          # cause errors later in the configuration, so we can safely assume
28506f32e7eSjoerg          # that this is valid here.
28606f32e7eSjoerg          list(APPEND expanded_components LLVM${c})
28706f32e7eSjoerg        endif()
28806f32e7eSjoerg      else( lib_idx LESS 0 )
28906f32e7eSjoerg        list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
29006f32e7eSjoerg        list(APPEND expanded_components ${canonical_lib})
29106f32e7eSjoerg      endif( lib_idx LESS 0 )
29206f32e7eSjoerg    endif( c STREQUAL "native" )
29306f32e7eSjoerg  endforeach(c)
29406f32e7eSjoerg
29506f32e7eSjoerg  set(${out_libs} ${expanded_components} PARENT_SCOPE)
29606f32e7eSjoergendfunction()
29706f32e7eSjoerg
29806f32e7eSjoerg# Perform a post-order traversal of the dependency graph.
29906f32e7eSjoerg# This duplicates the algorithm used by llvm-config, originally
30006f32e7eSjoerg# in tools/llvm-config/llvm-config.cpp, function ComputeLibsForComponents.
30106f32e7eSjoergfunction(expand_topologically name required_libs visited_libs)
30206f32e7eSjoerg  list(FIND visited_libs ${name} found)
30306f32e7eSjoerg  if( found LESS 0 )
30406f32e7eSjoerg    list(APPEND visited_libs ${name})
30506f32e7eSjoerg    set(visited_libs ${visited_libs} PARENT_SCOPE)
30606f32e7eSjoerg
307*da58b97aSjoerg    #
308*da58b97aSjoerg    get_property(libname GLOBAL PROPERTY LLVM_COMPONENT_NAME_${name})
309*da58b97aSjoerg    if(libname)
310*da58b97aSjoerg      set(cname LLVM${libname})
311*da58b97aSjoerg    elseif(TARGET ${name})
312*da58b97aSjoerg      set(cname ${name})
313*da58b97aSjoerg    elseif(TARGET LLVM${name})
314*da58b97aSjoerg      set(cname LLVM${name})
315*da58b97aSjoerg    else()
316*da58b97aSjoerg      message(FATAL_ERROR "unknown component ${name}")
317*da58b97aSjoerg    endif()
318*da58b97aSjoerg
319*da58b97aSjoerg    get_property(lib_deps TARGET ${cname} PROPERTY LLVM_LINK_COMPONENTS)
32006f32e7eSjoerg    foreach( lib_dep ${lib_deps} )
32106f32e7eSjoerg      expand_topologically(${lib_dep} "${required_libs}" "${visited_libs}")
32206f32e7eSjoerg      set(required_libs ${required_libs} PARENT_SCOPE)
32306f32e7eSjoerg      set(visited_libs ${visited_libs} PARENT_SCOPE)
32406f32e7eSjoerg    endforeach()
32506f32e7eSjoerg
326*da58b97aSjoerg    list(APPEND required_libs ${cname})
32706f32e7eSjoerg    set(required_libs ${required_libs} PARENT_SCOPE)
32806f32e7eSjoerg  endif()
32906f32e7eSjoergendfunction()
33006f32e7eSjoerg
33106f32e7eSjoerg# Expand dependencies while topologically sorting the list of libraries:
33206f32e7eSjoergfunction(llvm_expand_dependencies out_libs)
33306f32e7eSjoerg  set(expanded_components ${ARGN})
33406f32e7eSjoerg
33506f32e7eSjoerg  set(required_libs)
33606f32e7eSjoerg  set(visited_libs)
33706f32e7eSjoerg  foreach( lib ${expanded_components} )
33806f32e7eSjoerg    expand_topologically(${lib} "${required_libs}" "${visited_libs}")
33906f32e7eSjoerg  endforeach()
34006f32e7eSjoerg
34106f32e7eSjoerg  if(required_libs)
34206f32e7eSjoerg    list(REVERSE required_libs)
34306f32e7eSjoerg  endif()
34406f32e7eSjoerg  set(${out_libs} ${required_libs} PARENT_SCOPE)
34506f32e7eSjoergendfunction()
34606f32e7eSjoerg
34706f32e7eSjoergfunction(explicit_map_components_to_libraries out_libs)
34806f32e7eSjoerg  llvm_map_components_to_libnames(link_libs ${ARGN})
34906f32e7eSjoerg  llvm_expand_dependencies(expanded_components ${link_libs})
35006f32e7eSjoerg  # Return just the libraries included in this build:
35106f32e7eSjoerg  set(result)
35206f32e7eSjoerg  foreach(c ${expanded_components})
35306f32e7eSjoerg    if( TARGET ${c} )
35406f32e7eSjoerg      set(result ${result} ${c})
35506f32e7eSjoerg    endif()
35606f32e7eSjoerg  endforeach(c)
35706f32e7eSjoerg  set(${out_libs} ${result} PARENT_SCOPE)
35806f32e7eSjoergendfunction(explicit_map_components_to_libraries)
359