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
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}Info" asmidx)
57 if( NOT asmidx LESS 0 )
58 list(APPEND expanded_components "LLVM${c}Info")
60 elseif( c STREQUAL "native" )
61 # TODO: we assume ARCH is X86. In this case, we must use nativecodegen
62 # component instead. Do nothing, as in llvm-config script.
63 elseif( c STREQUAL "nativecodegen" )
64 # TODO: we assume ARCH is X86.
65 list(APPEND expanded_components "LLVMX86CodeGen")
66 elseif( c STREQUAL "backend" )
67 # same case as in `native'.
68 elseif( c STREQUAL "engine" )
69 # TODO: as we assume we are on X86, this is `jit'.
70 list(APPEND expanded_components "LLVMJIT")
71 elseif( c STREQUAL "all" )
72 list(APPEND expanded_components ${llvm_libs})
73 else( NOT idx LESS 0 )
74 list(APPEND expanded_components LLVM${c})
75 endif( NOT idx LESS 0 )
77 # We must match capitalization.
78 string(TOUPPER "${llvm_libs}" capitalized_libs)
79 list(REMOVE_DUPLICATES expanded_components)
81 list(LENGTH expanded_components lst_size)
82 while( ${curr_idx} LESS ${lst_size} )
83 list(GET expanded_components ${curr_idx} c)
84 string(TOUPPER "${c}" capitalized)
85 list(FIND capitalized_libs ${capitalized} idx)
87 message(FATAL_ERROR "Library ${c} not found in list of llvm libraries.")
89 list(GET llvm_libs ${idx} canonical_lib)
90 list(APPEND result ${canonical_lib})
91 list(APPEND result ${MSVC_LIB_DEPS_${canonical_lib}})
92 list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
93 list(REMOVE_DUPLICATES expanded_components)
94 list(LENGTH expanded_components lst_size)
95 math(EXPR curr_idx "${curr_idx} + 1")
96 endwhile( ${curr_idx} LESS ${lst_size} )
97 list(REMOVE_DUPLICATES result)
98 set(${out_libs} ${result} PARENT_SCOPE)
99 endfunction(explicit_map_components_to_libraries)
101 # This data is used to establish executable/library
102 # dependencies. Comes from the llvm-config script, which is built and
103 # installed on the bin directory for MinGW or Linux. At the end of the
104 # script, you'll see lines like this:
106 # LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
108 # This is translated to:
110 # set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
112 # It is necessary to remove the `lib' prefix and the `.a'.
114 # This 'sed' script should do the trick:
115 # sed -e s'#\.a##g' -e 's#libLLVM#LLVM#g' -e 's#: ##' -e 's#\(.*\)#set(MSVC_LIB_DEPS_\1)#' ~/llvm/tools/llvm-config/LibDeps.txt
118 # TODO: do this transformations on cmake.
120 # It is very important that the LLVM built for extracting this data
121 # must contain all targets, not just X86.
124 set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
125 set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMARMInfo LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
126 set(MSVC_LIB_DEPS_LLVMARMInfo LLVMCore LLVMSupport)
127 set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
128 set(MSVC_LIB_DEPS_LLVMAlphaCodeGen LLVMAlphaInfo LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
129 set(MSVC_LIB_DEPS_LLVMAlphaInfo LLVMCore LLVMSupport)
130 set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget)
131 set(MSVC_LIB_DEPS_LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
132 set(MSVC_LIB_DEPS_LLVMAsmParser LLVMCore LLVMSupport LLVMSystem)
133 set(MSVC_LIB_DEPS_LLVMAsmPrinter LLVMAnalysis LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
134 set(MSVC_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
135 set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport LLVMSystem)
136 set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCBackendInfo LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa)
137 set(MSVC_LIB_DEPS_LLVMCBackendInfo LLVMSupport)
138 set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
139 set(MSVC_LIB_DEPS_LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
140 set(MSVC_LIB_DEPS_LLVMCellSPUInfo LLVMSupport)
141 set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils)
142 set(MSVC_LIB_DEPS_LLVMCore LLVMSupport LLVMSystem)
143 set(MSVC_LIB_DEPS_LLVMCppBackend LLVMCore LLVMCppBackendInfo LLVMSupport LLVMSystem LLVMTarget)
144 set(MSVC_LIB_DEPS_LLVMCppBackendInfo LLVMSupport)
145 set(MSVC_LIB_DEPS_LLVMDebugger LLVMAnalysis LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
146 set(MSVC_LIB_DEPS_LLVMExecutionEngine LLVMCore LLVMSupport LLVMSystem LLVMTarget)
147 set(MSVC_LIB_DEPS_LLVMIA64AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMIA64Info LLVMSupport LLVMSystem LLVMTarget)
148 set(MSVC_LIB_DEPS_LLVMIA64CodeGen LLVMCodeGen LLVMCore LLVMIA64Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
149 set(MSVC_LIB_DEPS_LLVMIA64Info LLVMSupport)
150 set(MSVC_LIB_DEPS_LLVMInstrumentation LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTransformUtils)
151 set(MSVC_LIB_DEPS_LLVMInterpreter LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMSupport LLVMSystem LLVMTarget)
152 set(MSVC_LIB_DEPS_LLVMJIT LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMSupport LLVMSystem LLVMTarget)
153 set(MSVC_LIB_DEPS_LLVMLinker LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
154 set(MSVC_LIB_DEPS_LLVMMC LLVMSupport)
155 set(MSVC_LIB_DEPS_LLVMMSIL LLVMAnalysis LLVMCodeGen LLVMCore LLVMMSILInfo LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa)
156 set(MSVC_LIB_DEPS_LLVMMSILInfo LLVMSupport)
157 set(MSVC_LIB_DEPS_LLVMMSP430 LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
158 set(MSVC_LIB_DEPS_LLVMMSP430Info LLVMSupport)
159 set(MSVC_LIB_DEPS_LLVMMipsAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMipsCodeGen LLVMMipsInfo LLVMSupport LLVMSystem LLVMTarget)
160 set(MSVC_LIB_DEPS_LLVMMipsCodeGen LLVMCodeGen LLVMCore LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
161 set(MSVC_LIB_DEPS_LLVMMipsInfo LLVMSupport)
162 set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
163 set(MSVC_LIB_DEPS_LLVMPIC16Info LLVMSupport)
164 set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMPowerPCInfo LLVMSupport LLVMSystem LLVMTarget)
165 set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMCodeGen LLVMCore LLVMPowerPCInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
166 set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMCore LLVMSupport)
167 set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils)
168 set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
169 set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget)
170 set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget)
171 set(MSVC_LIB_DEPS_LLVMSparcInfo LLVMCore LLVMSupport)
172 set(MSVC_LIB_DEPS_LLVMSupport LLVMSystem)
173 set(MSVC_LIB_DEPS_LLVMSystem)
174 set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMSupport LLVMSystem)
175 set(MSVC_LIB_DEPS_LLVMTransformUtils LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget LLVMipa)
176 set(MSVC_LIB_DEPS_LLVMX86AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget LLVMX86CodeGen LLVMX86Info)
177 set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMX86Info)
178 set(MSVC_LIB_DEPS_LLVMX86Info LLVMCore LLVMSupport)
179 set(MSVC_LIB_DEPS_LLVMXCore LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMXCoreInfo)
180 set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMSupport)
181 set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport LLVMSystem)
182 set(MSVC_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa)