From 4d786dfcfa5a9391b5ec5f41dd015c9c3d52c358 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 6 Apr 2021 08:13:55 -0400 Subject: BinUtils: Avoid clobbering a variable named without a private prefix Refactoring in commit b12aec6c8d (BinUtils: prefer bin utils matching the compiler version extension, 2020-12-11, v3.20.0-rc1~171^2) accidentally leaked a `TOOL` variable. Name temporary variables with a private prefix. Fixes: #22035 --- Modules/CMakeFindBinUtils.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index e87a16b..f32266f 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -123,19 +123,19 @@ else() list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) endif() -foreach(TOOL IN LISTS _CMAKE_TOOL_VARS) - foreach(NAME IN LISTS _CMAKE_${TOOL}_NAMES) +foreach(_tool IN LISTS _CMAKE_TOOL_VARS) + foreach(_name IN LISTS _CMAKE_${_tool}_NAMES) if(NOT _CMAKE_TOOLCHAIN_PREFIX STREQUAL "") if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") - list(PREPEND _CMAKE_${TOOL}_NAMES ${NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) + list(PREPEND _CMAKE_${_tool}_NAMES ${_name}${_CMAKE_TOOLCHAIN_SUFFIX}) endif() - list(PREPEND _CMAKE_${TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${NAME}) + list(PREPEND _CMAKE_${_tool}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${_name}) endif() if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") - list(PREPEND _CMAKE_${TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) + list(PREPEND _CMAKE_${_tool}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${_name}${_CMAKE_TOOLCHAIN_SUFFIX}) endif() endforeach() - find_program(CMAKE_${TOOL} NAMES ${_CMAKE_${TOOL}_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_${_tool} NAMES ${_CMAKE_${_tool}_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) endforeach() if(NOT CMAKE_RANLIB) @@ -154,12 +154,12 @@ if(CMAKE_PLATFORM_HAS_INSTALLNAME) endif() # Mark any tool cache entries as advanced. -foreach(var IN LISTS _CMAKE_TOOL_VARS) - get_property(_CMAKE_TOOL_CACHED CACHE CMAKE_${var} PROPERTY TYPE) +foreach(_tool IN LISTS _CMAKE_TOOL_VARS) + get_property(_CMAKE_TOOL_CACHED CACHE CMAKE_${_tool} PROPERTY TYPE) if(_CMAKE_TOOL_CACHED) - mark_as_advanced(CMAKE_${var}) + mark_as_advanced(CMAKE_${_tool}) endif() - unset(_CMAKE_${var}_NAMES) + unset(_CMAKE_${_tool}_NAMES) endforeach() unset(_CMAKE_TOOL_VARS) unset(_CMAKE_TOOL_CACHED) -- cgit v0.12