Browse Source

IAR: decouple linker location from toolkit's bin dir

The implementation in commit 564d527c04 (IAR: Improve error message for
missing license, 2024-08-12, v3.31.0-rc1~234^2) failed for corner cases
in which symlinks were used from a location different from the one in
which the toolkit is shipped with (`<target>/bin`).

In this new implementation, the `<target>` architecture is taken solely
from the compiler NAME itself for all the supported languages and
forwarded to its respective BinUtils executable names
(e.g., `icc<target>`, `iasm<target>`, `a<target>`). This decouples the
location from the subdirectory in which they should be found.

Fixes: #26610
pull/376/head
Felipe Torrezan 6 months ago
parent
commit
cd9dd4cf8e
  1. 12
      Modules/CMakeFindBinUtils.cmake

12
Modules/CMakeFindBinUtils.cmake

@ -111,10 +111,11 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^x(Open)?W
list(APPEND _CMAKE_TOOL_VARS LINKER AR)
elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$")
# Get the architecture from the IAR compiler parent directory
get_filename_component(__iar_bin_dir "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
get_filename_component(__iar_toolkit_dir "${__iar_bin_dir}" DIRECTORY)
get_filename_component(__iar_arch_id "${__iar_toolkit_dir}" NAME)
# Detect the `<lang>` compiler name
get_filename_component(__iar_selected_compiler "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" NAME)
# Strip out the `icc`,`iasm`,`a` prefixes and other `_suffixes leaving only the `<target>`
string(TOLOWER "${__iar_selected_compiler}" __iar_arch_id)
string(REGEX REPLACE "^x(icc|iasm|a)|(_.*)$" "" __iar_arch_id "x${__iar_arch_id}")
# IAR Archive Tool
set(_CMAKE_AR_NAMES
"iarchive" "iarchive.exe"
@ -147,8 +148,7 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$")
"isymexport" "isymexport.exe"
)
list(APPEND _CMAKE_TOOL_VARS AR LINKER IAR_ELFDUMP IAR_ELFTOOL IAR_EXE2OBJ IAR_OBJMANIP IAR_SYMEXPORT)
unset(__iar_bin_dir)
unset(__iar_toolkit_dir)
unset(__iar_selected_compiler)
unset(__iar_arch_id)
# in all other cases search for ar, ranlib, etc.

Loading…
Cancel
Save