-
Notifications
You must be signed in to change notification settings - Fork 18
IAR Compiler options in a CMake project
The IAR C/C++ Compiler comes with a vast amount of options that are described in detail in its accompanying Development Guide. Below you will find a non-exhaustive compendium of frequently used options, alongside their respective meanings, where and how you can use them in your CMake projects.
Some compiler options are available regardless of the chosen target architecture. Below you will find relevant information.
-
-I <path>
specifies a directory that the compiler should search for header files. In CMake, this option can be specified intarget_include_directories()
where one or more directories can be specified for the target. -
-D <symbol>[=value]
defines a preprocessor symbol. An unspecifiedvalue
defaults to1
. In CMake, this option can be specified intarget_compile_definitions()
where one or more symbols can be specified for the target. -
-r
or--debug
compiles an object with debug information. That information is relevant for when debugging an executable target with the IAR C-SPY Debugger. In CMake, this option is generally handled by build configurations and its default build configurations for debugging (Debug
andRelWithDebInfo
) will include it by default. -
-O[n|l*|m|h|hs|hz]
controls the optimization level when compiling the code, from "none" to "high", where-Ol
(low) is the default and the same as "none" except for the lifespan of all non-static variables reduced to their scope. In CMake, this option is generally handled by build configurations and information specific to the IAR C/C++ Compiler is available here. -
-f <filename>.xcl
extends the command line with the contents of<filename>.xcl
. In CMake, this option is automatically used whenever the resulting command line would otherwise fail for exceeding the operating system's maximum command line length (e.g. when there are way too many long paths). -
--endian={little*|big}
specifies the endianess in the byte order. In CMake, this option can be specified intarget_compile_options()
. -
--no_wrap_diagnostics
will prevent line breaks in compiler diagnostic messages. In CMake, it is a recommended option for environments where these messages will be logged. It can be specified intarget_compile_options()
. -
--c++
enables C++ source code compilation. In CMake, this option is automatically handled when<LANG>
isCXX
. -
--libc++
enables C++ Runtime Library support for C++17. In CMake, this option can be used intarget_compile_options()
. -
--dlib_config[=gnu|extended|full]
is used to select the DLIB C/C++ Runtime Library configuration that the compiler should use. In CMake, this option can be specified intarget_compile_options()
and apply to C and/or C++ sources. The$<COMPILE_LANGUAGE>
generator expression can be used to limit this option to C and C++. Example:
target_compile_options(tgt PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:--dlib_config=full> # DLIB cannot be used with --libc++
# other options... )
-
--mfc
enables multi-file compilation for compiling multiple files at once. For using it with CMake, refer to Multi-file compilation.
Below you will find details about iccarm
's options available specifically for Arm targets.
-
--cpu=<core>
selects the target CPU (Central Processing Unit) core for which the IAR compiler should generate code. The commandiccarm --cpu=list
reveals a list of accepted<core>
parameters. The default<core>
iscortex-m3
. In CMake, this option can be specified intarget_compile_options()
. Example:
target_compile_options(tgt PRIVATE
--cpu=cortex-m7
# other options... )
-
--fpu=<type>
is used to select the target FPU (Floating Point Unit) for which the IAR compiler should generate code. The commandiccarm --fpu=list
reveals a list of accepted<type>
parameters. The default<type>
isnone
. In CMake, this option can be specified intarget_compile_options()
. Example:
target_compile_options(tgt PRIVATE
--fpu=VFPv5_SP # Single-precision variant 5 FPU
# other options... )
Below you will find details about iccriscv
's options available specifically for RISC-V targets.
-
--core=<core_spec>
selects the target CPU core specification, including its standard and vendor extensions (e.g. RV32IMFDCN), for which the IAR compiler should generate code. The default<core_spec>
isRV32IM
. In CMake, this option can be specified intarget_compile_options()
. Example:
target_compile_options(tgt PRIVATE
--core=RV32IMAC
# other options... )
Below you will find details about iccrl78
's options available specifically for Renesas RL78 targets.
-
--core=[s1|s2|s3*]
selects the target RL78 CPU core for which the IAR compiler should generate code. In CMake, this option can be specified intarget_compile_options()
.
Below you will find details about iccrx
's options available specifically for Renesas RX targets.
-
--core=[rxv1*|rxv2|rxv3]
selects the target RX CPU core for which the IAR compiler should generate code. In CMake, this option can be specified intarget_compile_options()
.
This is the cmake-tutorial wiki. Back to Wiki Home
- IAR Compiler options in a CMake project
- IAR ILINK options in a CMake project
- Language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities
- Use the IAR ELF Tool to convert executable targets to their binary formats