Commit 1ff7cd1f authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'iar_improved'

d8e6cd9e IAR: Improve support for IAR ARM Compiler
0b1a2876 Add a CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID variable
fea7d69d Store CMAKE_ASM_COMPILER_VERSION persistently
d2a8b5ce CMakeDetermineASMCompiler: Fix small copy-paste mistake
a2112257 Add infrastructure to use language extensions without any standard
8cd28bb0 cmLocalGenerator: Switch order of <LANG>_{EXTENSIONS,STANDARD} check
0fc2d78e cmLocalGenerator: Simplify logic for language standard or extension flag
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !991
parents d2617a28 d8e6cd9e
......@@ -387,6 +387,7 @@ Variables for Languages
/variable/CMAKE_LANG_ARCHIVE_FINISH
/variable/CMAKE_LANG_COMPILER
/variable/CMAKE_LANG_COMPILER_ABI
/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID
/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN
/variable/CMAKE_LANG_COMPILER_ID
/variable/CMAKE_LANG_COMPILER_LOADED
......
iar
---
* Support for the IAR ARM Compiler was improved.
CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID
-------------------------------------
An internal variable subject to change.
This is used to identify the variant of a compiler based on its target
architecture. For some compilers this is needed to determine the correct
usage.
......@@ -20,6 +20,7 @@ include:
G95 = G95 Fortran (g95.org)
GNU = GNU Compiler Collection (gcc.gnu.org)
HP = Hewlett-Packard Compiler (hp.com)
IAR = IAR Systems (iar.com)
Intel = Intel Compiler (intel.com)
MIPSpro = SGI MIPSpro (sgi.com)
MSVC = Microsoft Visual Studio (microsoft.com)
......
......@@ -7,8 +7,11 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_RANLIB "@_CMAKE_ASM_COMPILER_RANLIB@")
set(CMAKE_LINKER "@CMAKE_LINKER@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1)
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_VERSION "@_CMAKE_ASM_COMPILER_VERSION@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@")
@_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID@
set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0)
@CMAKE_ASM_COMPILER_CUSTOM_CODE@
......@@ -12,6 +12,7 @@ set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@")
set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
@_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_C_ARCHITECTURE_ID@
@SET_CMAKE_XCODE_CURRENT_ARCH@
set(CMAKE_AR "@CMAKE_AR@")
......
......@@ -13,6 +13,7 @@ set(CMAKE_CXX17_COMPILE_FEATURES "@CMAKE_CXX17_COMPILE_FEATURES@")
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_CXX_ARCHITECTURE_ID@
@SET_CMAKE_XCODE_CURRENT_ARCH@
set(CMAKE_AR "@CMAKE_AR@")
......
......@@ -84,7 +84,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI "-h")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI "Texas Instruments")
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU IAR)
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS IAR)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_IAR )
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_IAR "IAR Assembler")
......@@ -103,10 +103,31 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
include(CMakeDetermineCompilerId)
set(userflags)
CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT} "${userflags}")
if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "IAR")
# primary necessary to detect architecture, so the right archiver and linker can be picked
# eg. IAR Assembler V8.10.1.12857/W32 for ARM
# Cut out identification first, newline handling is a pain
string(REGEX MATCH "IAR Assembler[^\r\n]*" _compileid "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT}")
if("${_compileid}" MATCHES "V([0-9]+\\.[0-9]+\\.[0-9]+)")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION ${CMAKE_MATCH_1})
endif()
if("${_compileid}" MATCHES "for[ ]+([A-Za-z0-9]+)")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID ${CMAKE_MATCH_1})
endif()
endif()
unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT)
unset(_compileid)
endif()
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION)
set(_version " ${CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION}")
else()
set(_version "")
endif()
message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_version}")
unset(_version)
else()
message(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown")
endif()
......@@ -143,6 +164,9 @@ endif ()
include(CMakeFindBinUtils)
set(_CMAKE_PROCESSING_LANGUAGE "ASM")
include(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM${ASM_DIALECT}")
......@@ -152,20 +176,37 @@ else()
message(STATUS "Didn't find assembler")
endif()
set(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
set(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
set(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}")
set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}")
set(_CMAKE_ASM_COMPILER_AR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_AR}")
set(_CMAKE_ASM_COMPILER_RANLIB "${CMAKE_ASM${ASM_DIALECT}_COMPILER_RANLIB}")
foreach(_var
COMPILER
COMPILER_ID
COMPILER_ARG1
COMPILER_ENV_VAR
COMPILER_AR
COMPILER_RANLIB
COMPILER_VERSION
)
set(_CMAKE_ASM_${_var} "${CMAKE_ASM${ASM_DIALECT}_${_var}}")
endforeach()
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID
"set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID})")
else()
set(_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID "")
endif()
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake @ONLY)
set(_CMAKE_ASM_COMPILER)
set(_CMAKE_ASM_COMPILER_ARG1)
set(_CMAKE_ASM_COMPILER_ENV_VAR)
set(_CMAKE_ASM_COMPILER_AR)
set(_CMAKE_ASM_COMPILER_RANLIB)
foreach(_var
COMPILER
COMPILER_ID
COMPILER_ARG1
COMPILER_ENV_VAR
COMPILER_AR
COMPILER_RANLIB
COMPILER_VERSION
)
unset(_CMAKE_ASM_${_var})
endforeach()
......@@ -170,6 +170,13 @@ set(_CMAKE_PROCESSING_LANGUAGE "C")
include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
if(CMAKE_C_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID
"set(CMAKE_C_COMPILER_ARCHITECTURE_ID ${CMAKE_C_COMPILER_ARCHITECTURE_ID})")
else()
set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID "")
endif()
if(MSVC_C_ARCHITECTURE_ID)
set(SET_MSVC_C_ARCHITECTURE_ID
"set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})")
......
......@@ -73,6 +73,9 @@ else()
set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS
# Try compiling to an object file only.
"-c"
# IAR does not detect language automatically
"--c++"
"--ec++"
)
endif()
......@@ -165,6 +168,13 @@ set(_CMAKE_PROCESSING_LANGUAGE "CXX")
include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID
"set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})")
else()
set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID "")
endif()
if(MSVC_CXX_ARCHITECTURE_ID)
set(SET_MSVC_CXX_ARCHITECTURE_ID
"set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})")
......
......@@ -102,6 +102,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_${lang}_XCODE_CURRENT_ARCH}" PARENT_SCOPE)
......@@ -576,6 +577,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")
set(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}")
set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}")
set(CMAKE_${lang}_SIMULATE_ID "${SIMULATE_ID}")
......@@ -625,6 +627,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
# Return the information extracted.
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
......@@ -675,6 +678,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
"matched \"${regex}\":\n${output}")
set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_ID_OUTPUT "${output}" PARENT_SCOPE)
break()
else()
if("${result}" MATCHES "timeout")
......
......@@ -261,6 +261,13 @@ set(_CMAKE_PROCESSING_LANGUAGE "Fortran")
include(Compiler/${CMAKE_Fortran_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
if(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID
"set(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID ${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID})")
else()
set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID "")
endif()
if(MSVC_Fortran_ARCHITECTURE_ID)
set(SET_MSVC_Fortran_ARCHITECTURE_ID
"set(MSVC_Fortran_ARCHITECTURE_ID ${MSVC_Fortran_ARCHITECTURE_ID})")
......
......@@ -6,6 +6,7 @@ set(CMAKE_Fortran_COMPILER_WRAPPER "@CMAKE_Fortran_COMPILER_WRAPPER@")
set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@")
set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@")
set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@")
@_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_Fortran_ARCHITECTURE_ID@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@")
......
......@@ -144,6 +144,16 @@
# define ARCHITECTURE_ID ""
# endif
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
# if defined(__ICCARM__)
# define ARCHITECTURE_ID "ARM"
# elif defined(__ICCAVR__)
# define ARCHITECTURE_ID "AVR"
# else /* unknown architecture */
# define ARCHITECTURE_ID ""
# endif
#else
# define ARCHITECTURE_ID
#endif
......
......@@ -2,13 +2,20 @@
include(Compiler/IAR)
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
__compiler_iar_ARM(ASM)
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
endif()
string(APPEND CMAKE_ASM_FLAGS_INIT " ")
string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r")
string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG")
string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG")
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
__compiler_iar_AVR(ASM)
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa)
endif()
# This file is processed when the IAR compiler is used for a C file
include(Compiler/IAR)
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "-f ")
set(CMAKE_DEPFILE_FLAGS_C "--dependencies=ns <DEPFILE>")
include(Compiler/CMakeCommonCompilerMacros)
# The toolchains for ARM and AVR are quite different:
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ")
endif()
if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.10)
set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.10)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e)
endif()
__compiler_iar_ARM(C)
__compiler_check_default_language_standard(C 1.10 90 6.10 99 8.10 11)
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
__compiler_iar_AVR(C)
set(CMAKE_C_OUTPUT_EXTENSION ".r90")
if(NOT CMAKE_C_LINK_FLAGS)
......@@ -29,9 +33,8 @@ if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ")
# add the target specific include directory:
get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
get_filename_component(_compilerDir "${_compilerDir}" PATH)
include_directories("${_compilerDir}/inc" )
endif()
# add the target specific include directory:
get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
get_filename_component(_compilerDir "${_compilerDir}" PATH)
include_directories("${_compilerDir}/inc" )
# This file is processed when the IAR compiler is used for a C++ file
include(Compiler/IAR)
include(Compiler/CMakeCommonCompilerMacros)
if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
# "(extended) embedded C++" Mode
# old version: --ec++ or --eec++
# since 8.10: --c++ --no_exceptions --no_rtti
#
# --c++ is full C++ and supported since 6.10
if(NOT CMAKE_IAR_CXX_FLAG)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.10)
set(CMAKE_IAR_CXX_FLAG --c++)
else()
set(CMAKE_IAR_CXX_FLAG --eec++)
endif()
endif()
set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "-f ")
set(CMAKE_DEPFILE_FLAGS_CXX "--dependencies=ns <DEPFILE>")
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e)
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ")
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.10)
set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e)
endif()
__compiler_iar_ARM(CXX)
__compiler_check_default_language_standard(CXX 6.10 98 8.10 14)
if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
__compiler_iar_AVR(CXX)
set(CMAKE_CXX_OUTPUT_EXTENSION ".r90")
if(NOT CMAKE_CXX_LINK_FLAGS)
set(CMAKE_CXX_LINK_FLAGS "-Fmotorola")
......@@ -27,9 +42,8 @@ if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ")
# add the target specific include directory:
get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
get_filename_component(_compilerDir "${_compilerDir}" PATH)
include_directories("${_compilerDir}/inc")
endif()
# add the target specific include directory:
get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
get_filename_component(_compilerDir "${_compilerDir}" PATH)
include_directories("${_compilerDir}/inc")
# IAR Systems compiler for embedded systems.
# http://www.iar.com
set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)")
# http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf
#
# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform. The current value is 8. Note that
# the number could be higher in a future version of the product
# __ICCARM__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for ARM
# __VER__ An integer that identifies the version number of the IAR compiler in use. For example,
# version 5.11.3 is returned as 5011003.
set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)")
set(_compiler_id_version_compute "
# if defined(__VER__)
# 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)
# endif")
if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "")
message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set")
endif()
# Try to find tools in the same directory as Clang itself
get_filename_component(__iar_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" REALPATH)
get_filename_component(__iar_hint_1 "${__iar_hint_1}" DIRECTORY)
get_filename_component(__iar_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
set(__iar_hints "${__iar_hint_1}" "${__iar_hint_2}")
if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
# could allow using normal binutils ar, since objects are normal ELF files?
find_program(CMAKE_IAR_LINKARM ilinkarm.exe HINTS ${__iar_hints}
DOC "The IAR ARM linker")
find_program(CMAKE_IAR_ARCHIVE iarchive.exe HINTS ${__iar_hints}
DOC "The IAR archiver")
# find auxillary tools
find_program(CMAKE_IAR_ELFTOOL ielftool.exe HINTS ${__iar_hints}
DOC "The IAR ELF Tool")
find_program(CMAKE_IAR_ELFDUMP ielfdumparm.exe HINTS ${__iar_hints}
DOC "The IAR ELF Dumper")
find_program(CMAKE_IAR_OBJMANIP iobjmanip.exe HINTS ${__iar_hints}
DOC "The IAR ELF Object Tool")
find_program(CMAKE_IAR_SYMEXPORT isymexport.exe HINTS ${__iar_hints}
DOC "The IAR Absolute Symbol Exporter")
mark_as_advanced(CMAKE_IAR_LINKARM CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT)
set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
"set(CMAKE_IAR_LINKARM \"${CMAKE_IAR_LINKARM}\")
set(CMAKE_IAR_ARCHIVE \"${CMAKE_IAR_ARCHIVE}\")
set(CMAKE_IAR_ELFTOOL \"${CMAKE_IAR_ELFTOOL}\")
set(CMAKE_IAR_ELFDUMP \"${CMAKE_IAR_ELFDUMP}\")
set(CMAKE_IAR_OBJMANIP \"${CMAKE_IAR_OBJMANIP}\")
set(CMAKE_IAR_LINKARM \"${CMAKE_IAR_LINKARM}\")
")
elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
# For AVR and AVR32, IAR uses the "xlink" linker and the "xar" archiver:
find_program(CMAKE_IAR_LINKER xlink.exe HINTS ${__iar_hints}
DOC "The IAR AVR linker")
find_program(CMAKE_IAR_AR xar.exe HINTS ${__iar_hints}
DOC "The IAR archiver")
mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR)
set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
"set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
set(CMAKE_IAR_AR \"${CMAKE_IAR_AR}\")
")
endif()
......@@ -2,46 +2,75 @@
# Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/
# The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/issues/10176
# It also contains additional links and information.
# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for:
# version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html
# version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html
# version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html
if(_IAR_CMAKE_LOADED)
# C/C++ Standard versions
#
# IAR typically only supports one C and C++ Standard version,
# the exception is C89 which is always supported and can be selected
# if its not the default
#
# C++ is trickier, there were historically 3 switches,
# and some IAR versions support multiple of those.
# they are --eec++, --ec++ and --c++ and where used to
# enable various language features like exceptions
#
# recent versions only have --c++ for full support
# but can choose to disable features with further arguments
#
# C/C++ Standard compliance
#
# IAR has 3 modes: default, strict and extended
# the extended mode is needed for popular libraries like CMSIS
#
# "Silent" Operation
#
# this really is different to most programs I know.
# nothing meaningfull from the operation is lost, just some redundant
# code and data size printouts (that can be inspected with common tools).
# This module is shared by multiple languages; use include blocker.
if(_IARARM_CMAKE_LOADED)
return()
endif()
set(_IAR_CMAKE_LOADED TRUE)
set(_IARARM_CMAKE_LOADED 1)
macro(__compiler_iar_ARM lang)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX")
get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
get_filename_component(_CMAKE_ASM_TOOLCHAIN_LOCATION "${CMAKE_ASM_COMPILER}" PATH)
set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
if("${CMAKE_C_COMPILER}" MATCHES "arm" OR "${CMAKE_CXX_COMPILER}" MATCHES "arm" OR "${CMAKE_ASM_COMPILER}" MATCHES "arm")
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ohz -DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Oh -DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG")
endif()
# For arm, IAR uses the "ilinkarm" linker and "iarchive" archiver:
find_program(CMAKE_IAR_LINKER ilinkarm HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}")
find_program(CMAKE_IAR_AR iarchive HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKARM}\" --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --replace <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_FINISH "")
set(IAR_TARGET_ARCHITECTURE "ARM" CACHE STRING "IAR compiler target architecture")
endif()
set(CMAKE_LINKER "${CMAKE_IAR_LINKARM}" CACHE FILEPATH "The IAR linker" FORCE)
set(CMAKE_AR "${CMAKE_IAR_ARCHIVE}" CACHE FILEPATH "The IAR archiver" FORCE)
endmacro()
if("${CMAKE_C_COMPILER}" MATCHES "avr" OR "${CMAKE_CXX_COMPILER}" MATCHES "avr" OR "${CMAKE_ASM_COMPILER}" MATCHES "avr")
macro(__compiler_iar_AVR lang)
set(CMAKE_EXECUTABLE_SUFFIX ".bin")
# For AVR and AVR32, IAR uses the "xlink" linker and the "xar" archiver:
find_program(CMAKE_IAR_LINKER xlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
find_program(CMAKE_IAR_AR xar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
set(IAR_TARGET_ARCHITECTURE "AVR" CACHE STRING "IAR compiler target architecture")
set(CMAKE_LIBRARY_PATH_FLAG "-I")
endif()
if(NOT IAR_TARGET_ARCHITECTURE)
message(FATAL_ERROR "The IAR compiler for this architecture is not yet supported "
"by CMake. Please go to https://gitlab.kitware.com/cmake/cmake/issues "
"and enter a feature request there.")
endif()
set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
endmacro()
......@@ -1501,20 +1501,30 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
// This compiler has no notion of language standard levels.
return;
}
std::string stdProp = lang + "_STANDARD";
const char* standardProp = target->GetProperty(stdProp);
if (!standardProp) {
return;
}
std::string extProp = lang + "_EXTENSIONS";
std::string type = "EXTENSION";
bool ext = true;
if (const char* extPropValue = target->GetProperty(extProp)) {
if (cmSystemTools::IsOff(extPropValue)) {
ext = false;
type = "STANDARD";
}
}
std::string stdProp = lang + "_STANDARD";
const char* standardProp = target->GetProperty(stdProp);
if (!standardProp) {
if (ext) {
// No language standard is specified and extensions are not disabled.
// Check if this compiler needs a flag to enable extensions.
std::string const option_flag =
"CMAKE_" + lang + "_EXTENSION_COMPILE_OPTION";
if (const char* opt =
target->Target->GetMakefile()->GetDefinition(option_flag)) {
this->AppendFlagEscape(flags, opt);
}
}
return;
}
std::string const type = ext ? "EXTENSION" : "STANDARD";
if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) {
std::string option_flag =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment