-
Notifications
You must be signed in to change notification settings - Fork 18
IAR Environment Variables in CMake
The IAR Embedded Workbench IDE classic project format (*.ewp) provides internal environment variables such as for "Project directory" ($PROJ_DIR$) or for "Product directory" ($TOOLKIT_DIR$). These are called "Argument Variables" and they are not automatically propagated to CMake projects.
In your CMakeLists.txt use the following CMake commands after project() to get the corresponding IAR IDE Argument Variables counterparts, assuming that the project is using the C language:
# Get the IAR IDE Argument Variables in CMake
cmake_path(GET CMAKE_C_COMPILER PARENT_PATH COMPILER_DIR)
cmake_path(GET COMPILER_DIR PARENT_PATH TOOLKIT_DIR)
cmake_path(GET TOOLKIT_DIR PARENT_PATH EW_DIR)
set(PROJ_DIR "${PROJECT_SOURCE_DIR}")
set(PROJ_FNAME ${PROJECT_NAME})Note
Referencing CMake Variables differs syntactically from referencing IAR Argument Variables:
| IAR Argument Variable | CMake Variable |
|---|---|
$VARIABLE_NAME$ |
${VARIABLE_NAME} |
- Now you can use these variables to reference those paths and resources in your CMake project. For example:
project(MyProject C ASM)
# ...
# Get the IAR IDE Argument Variables in CMake
# ...
target_link_options(MyTarget1 PRIVATE --semihosting --config ${TOOLKIT_DIR}/config/generic.icf)
# ...
target_link_options(MyTarget2 PRIVATE --semihosting --config ${PROJ_DIR}/${PROJ_FNAME}.icf)It is possible to render almost any desired IAR Argument Variables in a CMake project so that its environment becomes more familiar.
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
- Using IAR Build Tools with CMake Presets