llvm.org GIT mirror llvm / 9b17d97
CMake: Establish dependencies among executables and libraries, using data manually extracted from llvm-config. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58484 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 10 years ago
1 changed file(s) with 123 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
66 endmacro(llvm_config executable link_components)
77
88
9 macro(msvc_llvm_config executable link_components)
9 function(msvc_llvm_config executable link_components)
1010 foreach(c ${link_components})
1111 if( c STREQUAL "jit" )
1212 set_target_properties(${executable}
1414 LINK_FLAGS "/INCLUDE:_X86TargetMachineModule")
1515 endif( c STREQUAL "jit" )
1616 endforeach(c)
17 target_link_libraries(${executable} ${llvm_libs})
18 endmacro(msvc_llvm_config executable link_components)
17 msvc_map_components_to_libraries(${link_components} LIBRARIES)
18 target_link_libraries(${executable} ${LIBRARIES})
19 endfunction(msvc_llvm_config executable link_components)
20
21
22 function(msvc_map_components_to_libraries link_components out_libs)
23 foreach(c ${link_components})
24 if( c STREQUAL "native" )
25 # TODO: we assume ARCH is X86. In this case, we must use nativecodegen
26 # component instead. Do nothing, as in llvm-config script.
27 elseif( c STREQUAL "nativecodegen" )
28 # TODO: we assume ARCH is X86.
29 list(APPEND expanded_components "LLVMX86CodeGen")
30 elseif( c STREQUAL "backend" )
31 # same case as in `native'.
32 elseif( c STREQUAL "engine" )
33 # TODO: as we assume we are on X86, this is `jit'.
34 list(APPEND expanded_components "LLVMJIT")
35 elseif( c STREQUAL "X86" )
36 # TODO: we assume we are on X86.
37 list(APPEND expanded_components "LLVMX86CodeGen")
38 list(APPEND expanded_components "LLVMX86AsmPrinter")
39 elseif( c STREQUAL "all" )
40 list(APPEND expanded_components ${llvm_libs})
41 else( c STREQUAL "native" )
42 list(APPEND expanded_components LLVM${c})
43 endif( c STREQUAL "native" )
44 endforeach(c)
45 # We must match capitalization.
46 string(TOUPPER "${llvm_libs}" capitalized_libs)
47 set(curr_idx 0)
48 list(LENGTH expanded_components lst_size)
49 while( ${curr_idx} LESS ${lst_size} )
50 list(GET expanded_components ${curr_idx} c)
51 string(TOUPPER "${c}" capitalized)
52 list(FIND capitalized_libs ${capitalized} idx)
53 if( idx LESS 0 )
54 message(FATAL_ERROR "Library ${c} not found in list of llvm libraries.")
55 endif( idx LESS 0 )
56 list(GET llvm_libs ${idx} canonical_lib)
57 list(APPEND result ${canonical_lib})
58 list(APPEND result ${MSVC_LIB_DEPS_${canonical_lib}})
59 list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
60 list(LENGTH expanded_components lst_size)
61 math(EXPR curr_idx "${curr_idx} + 1")
62 endwhile( ${curr_idx} LESS ${lst_size} )
63 list(REMOVE_DUPLICATES result)
64 set(${out_libs} ${result} PARENT_SCOPE)
65 endfunction(msvc_map_components_to_libraries)
1966
2067
2168 macro(nix_llvm_config executable link_components)
5299 endforeach(c)
53100 endif( NOT HAVE_LLVM_CONFIG )
54101 endmacro(nix_llvm_config executable link_components)
102
103
104 # This data is used on MSVC for stablishing executable/library
105 # dependencies. Comes from the llvm-config script, which is built and
106 # installed on the bin directory for MinGW or Linux. At the end of the
107 # script, you'll see lines like this:
108 #
109 # LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a
110 # libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
111 #
112 # This is translated to:
113 #
114 # set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter
115 # LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
116 #
117 # It is necessary to remove the `lib' prefix, the `.a' and `.o'
118 # suffixes. Watch out for this line:
119 #
120 # LLVMExecutionEngine.o LLVMJIT.o: libLLVMCodeGen.a libLLVMCore.a
121 # libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a
122 #
123 # See how there are two elements before the colon. This must be
124 # translated as if it were:
125 #
126 # LLVMExecutionEngine.o: libLLVMCodeGen.a libLLVMCore.a
127 # libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a LLVMJIT.o:
128 # libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a
129 # libLLVMTarget.a
130 #
131 # TODO: do this transformations on cmake.
132 #
133 # It is very important that the LLVM built for extracting this data
134 # must contain all targets, not just X86.
135
136
137 set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
138 set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
139 set(MSVC_LIB_DEPS_LLVMAlpha LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
140 set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
141 set(MSVC_LIB_DEPS_LLVMCBase LLVMSupport)
142 set(MSVC_LIB_DEPS_LLVMCellSPU LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
143 set(MSVC_LIB_DEPS_LLVMCppBackend LLVMCore LLVMSupport LLVMTarget)
144 set(MSVC_LIB_DEPS_LLVMExecutionEngine LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
145 set(MSVC_LIB_DEPS_LLVMJIT LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
146 set(MSVC_LIB_DEPS_LLVMIA64 LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
147 set(MSVC_LIB_DEPS_LLVMInterpreter LLVMExecutionEngine LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
148 set(MSVC_LIB_DEPS_LLVMMSIL LLVMAnalysis LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
149 set(MSVC_LIB_DEPS_LLVMMips LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
150 set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
151 set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMPowerPCCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
152 set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
153 set(MSVC_LIB_DEPS_LLVMSparc LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
154 set(MSVC_LIB_DEPS_LLVMX86AsmPrinter LLVMX86CodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
155 set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
156 set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget)
157 set(MSVC_LIB_DEPS_LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
158 set(MSVC_LIB_DEPS_LLVMAsmParser LLVMCore LLVMSupport)
159 set(MSVC_LIB_DEPS_LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
160 set(MSVC_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport)
161 set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport LLVMSystem)
162 set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils)
163 set(MSVC_LIB_DEPS_LLVMCore LLVMSupport LLVMSystem)
164 set(MSVC_LIB_DEPS_LLVMDebugger LLVMAnalysis LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
165 set(MSVC_LIB_DEPS_LLVMInstrumentation LLVMCore LLVMScalarOpts LLVMSupport LLVMTransformUtils)
166 set(MSVC_LIB_DEPS_LLVMLinker LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
167 set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMTransformUtils)
168 set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
169 set(MSVC_LIB_DEPS_LLVMSupport LLVMSystem)
170 set(MSVC_LIB_DEPS_LLVMSystem )
171 set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMSupport)
172 set(MSVC_LIB_DEPS_LLVMTransformUtils LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMipa)
173 set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport)
174 set(MSVC_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)