4 function(get_system_libs return_var)
5 # Returns in `return_var' a list of system libraries used by LLVM.
8 set(system_libs ${system_libs} imagehlp psapi)
9 elseif( CMAKE_HOST_UNIX )
11 set(system_libs ${system_libs} dl)
13 if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
14 set(system_libs ${system_libs} pthread)
18 set(${return_var} ${system_libs} PARENT_SCOPE)
19 endfunction(get_system_libs)
22 macro(llvm_config executable)
23 explicit_llvm_config(${executable} ${ARGN})
27 function(explicit_llvm_config executable)
28 set( link_components ${ARGN} )
30 explicit_map_components_to_libraries(LIBRARIES ${link_components})
31 target_link_libraries(${executable} ${LIBRARIES})
32 endfunction(explicit_llvm_config)
35 function(explicit_map_components_to_libraries out_libs)
36 set( link_components ${ARGN} )
37 foreach(c ${link_components})
38 # add codegen, asmprinter, asmparser
39 list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
41 list(FIND llvm_libs "LLVM${c}CodeGen" idx)
43 list(APPEND expanded_components "LLVM${c}CodeGen")
45 list(FIND llvm_libs "LLVM${c}" idx)
47 list(APPEND expanded_components "LLVM${c}")
49 message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
52 list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
53 if( NOT asmidx LESS 0 )
54 list(APPEND expanded_components "LLVM${c}AsmPrinter")
56 list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
57 if( NOT asmidx LESS 0 )
58 list(APPEND expanded_components "LLVM${c}AsmParser")
60 list(FIND llvm_libs "LLVM${c}Info" asmidx)
61 if( NOT asmidx LESS 0 )
62 list(APPEND expanded_components "LLVM${c}Info")
64 elseif( c STREQUAL "native" )
65 # TODO: we assume ARCH is X86. In this case, we must use nativecodegen
66 # component instead. Do nothing, as in llvm-config script.
67 elseif( c STREQUAL "nativecodegen" )
68 # TODO: we assume ARCH is X86.
69 list(APPEND expanded_components "LLVMX86CodeGen")
70 elseif( c STREQUAL "backend" )
71 # same case as in `native'.
72 elseif( c STREQUAL "engine" )
73 # TODO: as we assume we are on X86, this is `jit'.
74 list(APPEND expanded_components "LLVMJIT")
75 elseif( c STREQUAL "all" )
76 list(APPEND expanded_components ${llvm_libs})
77 else( NOT idx LESS 0 )
78 list(APPEND expanded_components LLVM${c})
79 endif( NOT idx LESS 0 )
81 # We must match capitalization.
82 string(TOUPPER "${llvm_libs}" capitalized_libs)
83 list(REMOVE_DUPLICATES expanded_components)
84 list(LENGTH expanded_components lst_size)
86 while( 0 LESS ${lst_size} )
87 list(GET expanded_components 0 c)
88 string(TOUPPER "${c}" capitalized)
89 list(FIND capitalized_libs ${capitalized} idx)
91 message(FATAL_ERROR "Library ${c} not found in list of llvm libraries.")
93 list(GET llvm_libs ${idx} canonical_lib)
94 list(REMOVE_ITEM result ${canonical_lib})
95 list(APPEND result ${canonical_lib})
96 foreach(c ${MSVC_LIB_DEPS_${canonical_lib}})
97 list(REMOVE_ITEM expanded_components ${c})
99 list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
100 list(REMOVE_AT expanded_components 0)
101 list(LENGTH expanded_components lst_size)
102 endwhile( 0 LESS ${lst_size} )
103 set(${out_libs} ${result} PARENT_SCOPE)
104 endfunction(explicit_map_components_to_libraries)