[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 75a0502fe0053c72b57b61143a55600814d931fd (D150884). Fixes Meson's test suite and an issue which manifested identically to #61436 but appears to have been a slightly different problem. Bug: https://github.com/mesonbuild/meson/issues/11642 Bug: https://github.com/llvm/llvm-project/issues/61436 Reviewed By: tstellar Differential Revision: https://reviews.llvm.org/D152121
This commit is contained in:
parent
ecf30c31fb
commit
ab8d4f5a12
@ -134,7 +134,7 @@ function(llvm_expand_pseudo_components out_components)
|
||||
endif()
|
||||
foreach(c ${link_components})
|
||||
# add codegen, asmprinter, asmparser, disassembler
|
||||
if(${c} IN_LIST LLVM_TARGETS_TO_BUILD)
|
||||
if("${c}" IN_LIST LLVM_TARGETS_TO_BUILD)
|
||||
if(LLVM${c}CodeGen IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${c}CodeGen")
|
||||
else()
|
||||
@ -149,48 +149,48 @@ function(llvm_expand_pseudo_components out_components)
|
||||
list(APPEND expanded_components "${c}${subcomponent}")
|
||||
endif()
|
||||
endforeach()
|
||||
elseif( c STREQUAL "nativecodegen" )
|
||||
elseif("${c}" STREQUAL "nativecodegen" )
|
||||
foreach(subcomponent IN ITEMS CodeGen Desc Info)
|
||||
if(LLVM${LLVM_NATIVE_ARCH}${subcomponent} IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}${subcomponent}")
|
||||
endif()
|
||||
endforeach()
|
||||
elseif( c STREQUAL "AllTargetsCodeGens" )
|
||||
elseif("${c}" STREQUAL "AllTargetsCodeGens" )
|
||||
# Link all the codegens from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if( TARGET LLVM${t}CodeGen)
|
||||
list(APPEND expanded_components "${t}CodeGen")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif( c STREQUAL "AllTargetsAsmParsers" )
|
||||
elseif("${c}" STREQUAL "AllTargetsAsmParsers" )
|
||||
# Link all the asm parsers from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if(LLVM${t}AsmParser IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${t}AsmParser")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif( c STREQUAL "AllTargetsDescs" )
|
||||
elseif( "${c}" STREQUAL "AllTargetsDescs" )
|
||||
# Link all the descs from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if(LLVM${t}Desc IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${t}Desc")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif( c STREQUAL "AllTargetsDisassemblers" )
|
||||
elseif("${c}" STREQUAL "AllTargetsDisassemblers" )
|
||||
# Link all the disassemblers from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if(LLVM${t}Disassembler IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${t}Disassembler")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif( c STREQUAL "AllTargetsInfos" )
|
||||
elseif("${c}" STREQUAL "AllTargetsInfos" )
|
||||
# Link all the infos from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if(LLVM${t}Info IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
list(APPEND expanded_components "${t}Info")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif( c STREQUAL "AllTargetsMCAs" )
|
||||
elseif("${c}" STREQUAL "AllTargetsMCAs" )
|
||||
# Link all the TargetMCAs from all the targets
|
||||
foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
if( TARGET LLVM${t}TargetMCA )
|
||||
@ -222,7 +222,7 @@ function(llvm_map_components_to_libnames out_libs)
|
||||
# process target dependencies.
|
||||
if(NOT LLVM_TARGETS_CONFIGURED)
|
||||
foreach(c ${link_components})
|
||||
is_llvm_target_specifier(${c} iltl_result ALL_TARGETS)
|
||||
is_llvm_target_specifier("${c}" iltl_result ALL_TARGETS)
|
||||
if(iltl_result)
|
||||
message(FATAL_ERROR "Specified target library before target registration is complete.")
|
||||
endif()
|
||||
@ -250,13 +250,13 @@ function(llvm_map_components_to_libnames out_libs)
|
||||
if(c_rename)
|
||||
set(c ${c_rename})
|
||||
endif()
|
||||
if( c STREQUAL "native" )
|
||||
if("${c}" STREQUAL "native" )
|
||||
# already processed
|
||||
elseif( c STREQUAL "backend" )
|
||||
elseif("${c}" STREQUAL "backend" )
|
||||
# same case as in `native'.
|
||||
elseif( c STREQUAL "engine" )
|
||||
elseif("${c}" STREQUAL "engine" )
|
||||
# already processed
|
||||
elseif( c STREQUAL "all" )
|
||||
elseif("${c}" STREQUAL "all" )
|
||||
get_property(all_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS)
|
||||
list(APPEND expanded_components ${all_components})
|
||||
else()
|
||||
@ -265,7 +265,7 @@ function(llvm_map_components_to_libnames out_libs)
|
||||
list(FIND capitalized_libs LLVM${capitalized} lib_idx)
|
||||
if( lib_idx LESS 0 )
|
||||
# The component is unknown. Maybe is an omitted target?
|
||||
is_llvm_target_library(${c} iltl_result OMITTED_TARGETS)
|
||||
is_llvm_target_library("${c}" iltl_result OMITTED_TARGETS)
|
||||
if(iltl_result)
|
||||
# A missing library to a directly referenced omitted target would be bad.
|
||||
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)
|
||||
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
|
||||
list(APPEND expanded_components ${canonical_lib})
|
||||
endif( lib_idx LESS 0 )
|
||||
endif( c STREQUAL "native" )
|
||||
endif("${c}" STREQUAL "native" )
|
||||
endforeach(c)
|
||||
|
||||
set(${out_libs} ${expanded_components} PARENT_SCOPE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user