llvm.org GIT mirror llvm / 83782f2
Teach LLVM-Config to use logical target names (1/2) LLVM library names are now available as logical CMake targets both to our own build and to application CMake code. Replace use of 'list(FIND)' with a simple 'if(TARGET)' to determine whether a library is available. Contributed by Brad King. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201852 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 5 years ago
1 changed file(s) with 7 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
103103 # add codegen, asmprinter, asmparser, disassembler
104104 list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
105105 if( NOT idx LESS 0 )
106 list(FIND llvm_libs "LLVM${c}CodeGen" idx)
107 if( NOT idx LESS 0 )
106 if( TARGET LLVM${c}CodeGen )
108107 list(APPEND expanded_components "LLVM${c}CodeGen")
109108 else()
110 list(FIND llvm_libs "LLVM${c}" idx)
111 if( NOT idx LESS 0 )
109 if( TARGET LLVM${c} )
112110 list(APPEND expanded_components "LLVM${c}")
113111 else()
114112 message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
115113 endif()
116114 endif()
117 list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
118 if( NOT asmidx LESS 0 )
115 if( TARGET LLVM${c}AsmPrinter )
119116 list(APPEND expanded_components "LLVM${c}AsmPrinter")
120117 endif()
121 list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
122 if( NOT asmidx LESS 0 )
118 if( TARGET LLVM${c}AsmParser )
123119 list(APPEND expanded_components "LLVM${c}AsmParser")
124120 endif()
125 list(FIND llvm_libs "LLVM${c}Info" asmidx)
126 if( NOT asmidx LESS 0 )
121 if( TARGET LLVM${c}Info )
127122 list(APPEND expanded_components "LLVM${c}Info")
128123 endif()
129 list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
130 if( NOT asmidx LESS 0 )
124 if( TARGET LLVM${c}Disassembler )
131125 list(APPEND expanded_components "LLVM${c}Disassembler")
132126 endif()
133127 elseif( c STREQUAL "native" )
188182 function(explicit_map_components_to_libraries out_libs)
189183 llvm_map_components_to_libnames(link_libs ${ARGN})
190184 llvm_expand_dependencies(expanded_components ${link_libs})
191 get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
192185 # Return just the libraries included in this build:
193186 set(result)
194187 foreach(c ${expanded_components})
195 list(FIND llvm_libs ${c} lib_idx)
196 if( NOT lib_idx LESS 0 )
188 if( TARGET ${c} )
197189 set(result ${result} ${c})
198190 endif()
199191 endforeach(c)