IAR-FindBinUtils.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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")
  14. string(TOLOWER "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" _archid_lower)
  15. # Find linker
  16. find_program(CMAKE_IAR_LINKER ilink${_archid_lower} HINTS ${__iar_hints}
  17. DOC "The IAR ILINK linker")
  18. find_program(CMAKE_IAR_ARCHIVE iarchive HINTS ${__iar_hints}
  19. DOC "The IAR archiver")
  20. # Find utility tools
  21. find_program(CMAKE_IAR_ELFTOOL ielftool HINTS ${__iar_hints}
  22. DOC "The IAR ELF Tool")
  23. find_program(CMAKE_IAR_ELFDUMP ielfdump${_archid_lower} HINTS ${__iar_hints}
  24. DOC "The IAR ELF Dumper")
  25. find_program(CMAKE_IAR_OBJMANIP iobjmanip HINTS ${__iar_hints}
  26. DOC "The IAR ELF Object Tool")
  27. find_program(CMAKE_IAR_SYMEXPORT isymexport HINTS ${__iar_hints}
  28. DOC "The IAR Absolute Symbol Exporter")
  29. mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT)
  30. set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
  31. "set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  32. set(CMAKE_IAR_ARCHIVE \"${CMAKE_IAR_ARCHIVE}\")
  33. set(CMAKE_IAR_ELFTOOL \"${CMAKE_IAR_ELFTOOL}\")
  34. set(CMAKE_IAR_ELFDUMP \"${CMAKE_IAR_ELFDUMP}\")
  35. set(CMAKE_IAR_OBJMANIP \"${CMAKE_IAR_OBJMANIP}\")
  36. set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  37. ")
  38. elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR" OR
  39. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430" OR
  40. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850" OR
  41. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
  42. # Find the "xlink" linker and "xar" archiver:
  43. find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints}
  44. DOC "The IAR XLINK linker")
  45. find_program(CMAKE_IAR_AR xar HINTS ${__iar_hints}
  46. DOC "The IAR archiver")
  47. mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR)
  48. set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
  49. "set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
  50. set(CMAKE_IAR_AR \"${CMAKE_IAR_AR}\")
  51. ")
  52. endif()