IAR-FindBinUtils.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "")
  2. message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set")
  3. endif()
  4. # Try to find tools in the same directory as the compiler itself
  5. get_filename_component(__iar_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" REALPATH)
  6. get_filename_component(__iar_hint_1 "${__iar_hint_1}" DIRECTORY)
  7. get_filename_component(__iar_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
  8. set(__iar_hints "${__iar_hint_1}" "${__iar_hint_2}")
  9. if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" OR
  10. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX" OR
  11. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850" OR
  12. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78" OR
  13. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV" OR
  14. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "STM8")
  15. string(TOLOWER "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" _archid_lower)
  16. # Find linker
  17. find_program(CMAKE_IAR_LINKER ilink${_archid_lower} HINTS ${__iar_hints}
  18. DOC "The IAR ILINK linker")
  19. find_program(CMAKE_IAR_ARCHIVE iarchive HINTS ${__iar_hints}
  20. DOC "The IAR archiver")
  21. # Find utility tools
  22. find_program(CMAKE_IAR_ELFTOOL ielftool HINTS ${__iar_hints}
  23. DOC "The IAR ELF Tool")
  24. find_program(CMAKE_IAR_ELFDUMP ielfdump${_archid_lower} HINTS ${__iar_hints}
  25. DOC "The IAR ELF Dumper")
  26. find_program(CMAKE_IAR_OBJMANIP iobjmanip HINTS ${__iar_hints}
  27. DOC "The IAR ELF Object Tool")
  28. find_program(CMAKE_IAR_SYMEXPORT isymexport HINTS ${__iar_hints}
  29. DOC "The IAR Absolute Symbol Exporter")
  30. mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT)
  31. set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
  32. "set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  33. set(CMAKE_IAR_ARCHIVE \"${CMAKE_IAR_ARCHIVE}\")
  34. set(CMAKE_IAR_ELFTOOL \"${CMAKE_IAR_ELFTOOL}\")
  35. set(CMAKE_IAR_ELFDUMP \"${CMAKE_IAR_ELFDUMP}\")
  36. set(CMAKE_IAR_OBJMANIP \"${CMAKE_IAR_OBJMANIP}\")
  37. set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  38. ")
  39. elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR" OR
  40. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430" OR
  41. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850" OR
  42. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
  43. # Find the "xlink" linker and "xar" archiver:
  44. find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints}
  45. DOC "The IAR XLINK linker")
  46. find_program(CMAKE_IAR_AR xar HINTS ${__iar_hints}
  47. DOC "The IAR archiver")
  48. mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR)
  49. set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
  50. "set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  51. set(CMAKE_IAR_AR \"${CMAKE_IAR_AR}\")
  52. ")
  53. endif()