1# IAR C/C++ Compiler (https://www.iar.com)
2# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850
3#
4# IAR C/C++ Compiler for <arch> internal integer symbols used in CMake:
5#
6# __IAR_SYSTEMS_ICC__
7#           Provides the compiler internal platform version
8# __ICC<arch>__
9#           Provides 1 for the current <arch> in use
10# __VER__
11#           Provides the current version in use
12#            The semantic version of the compiler is architecture-dependent
13#            When <arch> is ARM:
14#               CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E6)
15#               CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ / 1E3) % 1E3
16#               CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__VER__ % 1E3)
17#            When <arch> is non-ARM:
18#               CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E2)
19#               CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ - ((__VER__/ 1E2) * 1E2))
20#               CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__SUBVERSION__)
21# __SUBVERSION__
22#           Provides the version's patch level for non-ARM <arch>
23#
24set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)")
25
26set(_compiler_id_version_compute "
27# if defined(__VER__) && defined(__ICCARM__)
28#  define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 1000000)
29#  define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000)
30#  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000)
31#  define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
32# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
33#  define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100)
34#  define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100))
35#  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__)
36#  define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
37# endif")
38