mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
IAR: changes for the upcoming compiler version
Significant changes on the next major version of the IAR compiler required some changes in CMake: - __IAR_COMPILERBASE__ offers a fine grained versioning option in comparisom with __IAR_SYSTEMS_ICC__, which only referred to the IAR internal platform version. - C++20 Language support added for Arm (v10.10.1+), where libc++ is used by default.
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
# This file is processed when the IAR C Compiler is used
|
||||
#
|
||||
# C Language Specification support
|
||||
# - Newer versions of the IAR C Compiler require the --c89 flag to build a file under the C90 standard.
|
||||
# - Earlier versions of the compiler had C90 by default, not requiring the backward-compatibility flag.
|
||||
#
|
||||
# The IAR Language Extensions
|
||||
# - The IAR Language Extensions can be enabled by -e flag
|
||||
#
|
||||
# This file is processed when the IAR C Compiler is used.
|
||||
|
||||
include(Compiler/IAR)
|
||||
include(Compiler/CMakeCommonCompilerMacros)
|
||||
|
||||
@@ -17,16 +10,35 @@ endif()
|
||||
# Unused after CMP0128
|
||||
set(CMAKE_C_EXTENSION_COMPILE_OPTION -e)
|
||||
|
||||
if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7)
|
||||
# Stubs for standard/extended compile options
|
||||
if((NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT EQUAL 99) AND
|
||||
(NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT EQUAL 90))
|
||||
if(CMAKE_C_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 17)
|
||||
set(CMAKE_C17_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C17_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
if(CMAKE_C_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 11)
|
||||
set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e)
|
||||
elseif(CMAKE_C_STANDARD_COMPUTED_DEFAULT EQUAL 99)
|
||||
set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
|
||||
# C90 Mode
|
||||
# - IAR Compilers with *internal* version >= v8.0.0 require the --c89 flag.
|
||||
# - IAR Compilers with *internal* version < v8.0.0 has C90 mode by default.
|
||||
if(CMAKE_C_COMPILER_VERSION_INTERNAL GREATER_EQUAL 0x00080000)
|
||||
set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89)
|
||||
set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e)
|
||||
else()
|
||||
elseif(CMAKE_C_COMPILER_VERSION_INTERNAL LESS 0x00080000)
|
||||
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e)
|
||||
|
||||
# Architecture specific
|
||||
if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
|
||||
|
||||
@@ -14,23 +14,48 @@ if(NOT CMAKE_CXX_COMPILER_VERSION)
|
||||
message(FATAL_ERROR "Could not detect CMAKE_CXX_COMPILER_VERSION. This should be automatic. Check your product license.\n")
|
||||
endif()
|
||||
|
||||
# Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file.
|
||||
# The CMAKE_IAR_CXX_FLAG variable can be used in your toolchain file
|
||||
# for overriding the default flag for compiling C++ source files.
|
||||
if(NOT CMAKE_IAR_CXX_FLAG)
|
||||
set(_CMAKE_IAR_MODERNCXX_LIST 14 17)
|
||||
if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR
|
||||
("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98))
|
||||
if((NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT EQUAL 98) OR
|
||||
("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM"))
|
||||
set(CMAKE_IAR_CXX_FLAG --c++)
|
||||
else()
|
||||
set(CMAKE_IAR_CXX_FLAG --eec++)
|
||||
endif()
|
||||
unset(_CMAKE_IAR_MODERNCXX_LIST)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) # Unused after CMP0128
|
||||
|
||||
set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e)
|
||||
# Stubs for standard/extended compiler options
|
||||
if(NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT EQUAL 98)
|
||||
if(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 20)
|
||||
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION --libc++)
|
||||
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION --libc++ -e)
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 17)
|
||||
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 14)
|
||||
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT GREATER_EQUAL 11)
|
||||
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT EQUAL 03)
|
||||
set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e)
|
||||
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e)
|
||||
endif()
|
||||
|
||||
# Architecture specific
|
||||
if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
|
||||
@@ -39,7 +64,7 @@ if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
|
||||
message(FATAL_ERROR "IAR C++ Compiler for Arm version ${CMAKE_CXX_COMPILER_VERSION} not supported by CMake.")
|
||||
endif()
|
||||
__compiler_iar_ilink(CXX)
|
||||
__compiler_check_default_language_standard(CXX 5.10 98 8.10 14 8.40 17)
|
||||
__compiler_check_default_language_standard(CXX 5.10 98 8.10 14 8.40 17 10.10 20)
|
||||
|
||||
elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX")
|
||||
__compiler_iar_ilink(CXX)
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
# IAR C/C++ Compiler (https://www.iar.com)
|
||||
# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850
|
||||
#
|
||||
# IAR C/C++ Compiler for <arch> internal integer symbols used in CMake:
|
||||
# CPU target architectures (<arch>) supported in CMake:
|
||||
# 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX, STM8 and V850
|
||||
#
|
||||
# IAR C/C++ Compiler for <arch> internal macros used by CMake:
|
||||
#
|
||||
# __IAR_COMPILERBASE__
|
||||
# Provides a fine-grained compiler internal version,
|
||||
# available as integer, and preferred for detection.
|
||||
# Format:
|
||||
# <__IAR_SYSTEMS_ICC__+1> & 0x00FF0000
|
||||
# <major_version> & 0x0000FF00
|
||||
# <minor_version> & 0x000000FF
|
||||
#
|
||||
# __IAR_SYSTEMS_ICC__
|
||||
# Provides the compiler internal platform version
|
||||
# __ICC<arch>__
|
||||
# Provides 1 for the current <arch> in use
|
||||
# __VER__
|
||||
# Provides the current version in use
|
||||
# The semantic version of the compiler is architecture-dependent
|
||||
# When <arch> is ARM:
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E6)
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ / 1E3) % 1E3
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__VER__ % 1E3)
|
||||
# When <arch> is non-ARM:
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E2)
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ - ((__VER__/ 1E2) * 1E2))
|
||||
# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__SUBVERSION__)
|
||||
# __SUBVERSION__
|
||||
# Provides the version's patch level for non-ARM <arch>
|
||||
# Provides the compiler internal platform version.
|
||||
# In CMake, it is used as a fallback detection option for legacy compilers,
|
||||
# when __IAR_COMPILERBASE__ is not available.
|
||||
# Format:
|
||||
# <iar_platform_version> & 0x000000FF
|
||||
# In use:
|
||||
# (<iar_platform_version> << 16) & 0x00FF0000
|
||||
#
|
||||
# __ICC<arch>__
|
||||
# Provides 1 for the current <arch> in use.
|
||||
#
|
||||
# __VER__
|
||||
# Provides the compiler version, which is composed differently
|
||||
# between Arm and non-Arm target architectures.
|
||||
#
|
||||
# __SUBVERSION__
|
||||
# Provides the compiler patchlevel version for non-Arm target architectures.
|
||||
#
|
||||
|
||||
set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)")
|
||||
|
||||
set(_compiler_id_version_compute "
|
||||
@@ -28,10 +40,13 @@ set(_compiler_id_version_compute "
|
||||
# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 1000000)
|
||||
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000)
|
||||
# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000)
|
||||
# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
|
||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
|
||||
# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100)
|
||||
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100))
|
||||
# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__)
|
||||
# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
|
||||
# endif
|
||||
# if defined(__IAR_COMPILERBASE__)
|
||||
# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_COMPILERBASE__)
|
||||
# else
|
||||
# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@((__IAR_SYSTEMS_ICC__ << 16))
|
||||
# endif")
|
||||
|
||||
Reference in New Issue
Block a user