IAR.cmake 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # This file is processed when the IAR compiler is used for a C or C++ file
  2. # Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/
  3. # The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/issues/10176
  4. # It also contains additional links and information.
  5. # See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for:
  6. # version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html
  7. # version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html
  8. # version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html
  9. # C/C++ Standard versions
  10. #
  11. # IAR typically only supports one C and C++ Standard version,
  12. # the exception is C89 which is always supported and can be selected
  13. # if its not the default
  14. #
  15. # C++ is trickier, there were historically 3 switches,
  16. # and some IAR versions support multiple of those.
  17. # they are --eec++, --ec++ and --c++ and where used to
  18. # enable various language features like exceptions
  19. #
  20. # recent versions only have --c++ for full support
  21. # but can choose to disable features with further arguments
  22. #
  23. # C/C++ Standard compliance
  24. #
  25. # IAR has 3 modes: default, strict and extended
  26. # the extended mode is needed for popular libraries like CMSIS
  27. #
  28. # "Silent" Operation
  29. #
  30. # this really is different to most programs I know.
  31. # nothing meaningful from the operation is lost, just some redundant
  32. # code and data size printouts (that can be inspected with common tools).
  33. # This module is shared by multiple languages; use include blocker.
  34. if(_IARARM_CMAKE_LOADED)
  35. return()
  36. endif()
  37. set(_IARARM_CMAKE_LOADED 1)
  38. macro(__compiler_iar_ARM lang)
  39. set(CMAKE_EXECUTABLE_SUFFIX ".elf")
  40. if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX")
  41. set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
  42. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
  43. set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
  44. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
  45. set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
  46. string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
  47. string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r")
  48. string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ohz -DNDEBUG")
  49. string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Oh -DNDEBUG")
  50. string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG")
  51. endif()
  52. set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKARM}\" --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
  53. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
  54. set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
  55. set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --replace <LINK_FLAGS> <OBJECTS>")
  56. set(CMAKE_${lang}_ARCHIVE_FINISH "")
  57. set(CMAKE_LINKER "${CMAKE_IAR_LINKARM}" CACHE FILEPATH "The IAR linker" FORCE)
  58. set(CMAKE_AR "${CMAKE_IAR_ARCHIVE}" CACHE FILEPATH "The IAR archiver" FORCE)
  59. endmacro()
  60. macro(__compiler_iar_AVR lang)
  61. set(CMAKE_EXECUTABLE_SUFFIX ".bin")
  62. set(CMAKE_LIBRARY_PATH_FLAG "-I")
  63. set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
  64. set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
  65. endmacro()