Skip to content

Commit ab8d4f5

Browse files
committed
[CMake] Quote variables where "TARGET" may be a value
In CMake, "TARGET" is a special keyword. But it's also an LLVM component, which means downstreams may request "target" or "TARGET" from CMake. Quote such input so "TARGET" is interpreted as a string rather than a keyword. This is a followup to 75a0502 (D150884). Fixes Meson's test suite and an issue which manifested identically to #61436 but appears to have been a slightly different problem. Bug: mesonbuild/meson#11642 Bug: #61436 Reviewed By: tstellar Differential Revision: https://reviews.llvm.org/D152121
1 parent ecf30c3 commit ab8d4f5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

llvm/cmake/modules/LLVM-Config.cmake

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function(llvm_expand_pseudo_components out_components)
134134
endif()
135135
foreach(c ${link_components})
136136
# add codegen, asmprinter, asmparser, disassembler
137-
if(${c} IN_LIST LLVM_TARGETS_TO_BUILD)
137+
if("${c}" IN_LIST LLVM_TARGETS_TO_BUILD)
138138
if(LLVM${c}CodeGen IN_LIST LLVM_AVAILABLE_LIBS)
139139
list(APPEND expanded_components "${c}CodeGen")
140140
else()
@@ -149,48 +149,48 @@ function(llvm_expand_pseudo_components out_components)
149149
list(APPEND expanded_components "${c}${subcomponent}")
150150
endif()
151151
endforeach()
152-
elseif( c STREQUAL "nativecodegen" )
152+
elseif("${c}" STREQUAL "nativecodegen" )
153153
foreach(subcomponent IN ITEMS CodeGen Desc Info)
154154
if(LLVM${LLVM_NATIVE_ARCH}${subcomponent} IN_LIST LLVM_AVAILABLE_LIBS)
155155
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}${subcomponent}")
156156
endif()
157157
endforeach()
158-
elseif( c STREQUAL "AllTargetsCodeGens" )
158+
elseif("${c}" STREQUAL "AllTargetsCodeGens" )
159159
# Link all the codegens from all the targets
160160
foreach(t ${LLVM_TARGETS_TO_BUILD})
161161
if( TARGET LLVM${t}CodeGen)
162162
list(APPEND expanded_components "${t}CodeGen")
163163
endif()
164164
endforeach(t)
165-
elseif( c STREQUAL "AllTargetsAsmParsers" )
165+
elseif("${c}" STREQUAL "AllTargetsAsmParsers" )
166166
# Link all the asm parsers from all the targets
167167
foreach(t ${LLVM_TARGETS_TO_BUILD})
168168
if(LLVM${t}AsmParser IN_LIST LLVM_AVAILABLE_LIBS)
169169
list(APPEND expanded_components "${t}AsmParser")
170170
endif()
171171
endforeach(t)
172-
elseif( c STREQUAL "AllTargetsDescs" )
172+
elseif( "${c}" STREQUAL "AllTargetsDescs" )
173173
# Link all the descs from all the targets
174174
foreach(t ${LLVM_TARGETS_TO_BUILD})
175175
if(LLVM${t}Desc IN_LIST LLVM_AVAILABLE_LIBS)
176176
list(APPEND expanded_components "${t}Desc")
177177
endif()
178178
endforeach(t)
179-
elseif( c STREQUAL "AllTargetsDisassemblers" )
179+
elseif("${c}" STREQUAL "AllTargetsDisassemblers" )
180180
# Link all the disassemblers from all the targets
181181
foreach(t ${LLVM_TARGETS_TO_BUILD})
182182
if(LLVM${t}Disassembler IN_LIST LLVM_AVAILABLE_LIBS)
183183
list(APPEND expanded_components "${t}Disassembler")
184184
endif()
185185
endforeach(t)
186-
elseif( c STREQUAL "AllTargetsInfos" )
186+
elseif("${c}" STREQUAL "AllTargetsInfos" )
187187
# Link all the infos from all the targets
188188
foreach(t ${LLVM_TARGETS_TO_BUILD})
189189
if(LLVM${t}Info IN_LIST LLVM_AVAILABLE_LIBS)
190190
list(APPEND expanded_components "${t}Info")
191191
endif()
192192
endforeach(t)
193-
elseif( c STREQUAL "AllTargetsMCAs" )
193+
elseif("${c}" STREQUAL "AllTargetsMCAs" )
194194
# Link all the TargetMCAs from all the targets
195195
foreach(t ${LLVM_TARGETS_TO_BUILD})
196196
if( TARGET LLVM${t}TargetMCA )
@@ -222,7 +222,7 @@ function(llvm_map_components_to_libnames out_libs)
222222
# process target dependencies.
223223
if(NOT LLVM_TARGETS_CONFIGURED)
224224
foreach(c ${link_components})
225-
is_llvm_target_specifier(${c} iltl_result ALL_TARGETS)
225+
is_llvm_target_specifier("${c}" iltl_result ALL_TARGETS)
226226
if(iltl_result)
227227
message(FATAL_ERROR "Specified target library before target registration is complete.")
228228
endif()
@@ -250,13 +250,13 @@ function(llvm_map_components_to_libnames out_libs)
250250
if(c_rename)
251251
set(c ${c_rename})
252252
endif()
253-
if( c STREQUAL "native" )
253+
if("${c}" STREQUAL "native" )
254254
# already processed
255-
elseif( c STREQUAL "backend" )
255+
elseif("${c}" STREQUAL "backend" )
256256
# same case as in `native'.
257-
elseif( c STREQUAL "engine" )
257+
elseif("${c}" STREQUAL "engine" )
258258
# already processed
259-
elseif( c STREQUAL "all" )
259+
elseif("${c}" STREQUAL "all" )
260260
get_property(all_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS)
261261
list(APPEND expanded_components ${all_components})
262262
else()
@@ -265,7 +265,7 @@ function(llvm_map_components_to_libnames out_libs)
265265
list(FIND capitalized_libs LLVM${capitalized} lib_idx)
266266
if( lib_idx LESS 0 )
267267
# The component is unknown. Maybe is an omitted target?
268-
is_llvm_target_library(${c} iltl_result OMITTED_TARGETS)
268+
is_llvm_target_library("${c}" iltl_result OMITTED_TARGETS)
269269
if(iltl_result)
270270
# A missing library to a directly referenced omitted target would be bad.
271271
message(FATAL_ERROR "Library '${c}' is a direct reference to a target library for an omitted target.")
@@ -280,7 +280,7 @@ function(llvm_map_components_to_libnames out_libs)
280280
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
281281
list(APPEND expanded_components ${canonical_lib})
282282
endif( lib_idx LESS 0 )
283-
endif( c STREQUAL "native" )
283+
endif("${c}" STREQUAL "native" )
284284
endforeach(c)
285285

286286
set(${out_libs} ${expanded_components} PARENT_SCOPE)

0 commit comments

Comments
 (0)