OlivierP
OlivierP

Reputation: 41

IAR iccarm Cmake

I have some trouble doing a migration from IAR IDE to Cmake/IAR compiler for arm:

According to my understanding, with a correct CMakeList.txt, I try:

/c/CMake/bin/cmake.exe -G"MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE="C:\CMake\bin\Modules\Compiler\iar.cmake" -DCMAKE_C_COMPILER="C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iccarm.exe" -DCMAKE_ASM_COMPILER="C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iasmarm.exe" ..

I get:

-- The C compiler identification is IAR
-- The ASM compiler identification is IAR
-- Found assembler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iasmarm.exe
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iccarm.exe
CMake Error at C:/CMake/bin/Modules/Compiler/IAR.cmake:41 (message):
  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.
Call Stack (most recent call first):
  C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/3.7.2/CMakeSystem.cmake:6 (include)
  C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (project)


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Configuring incomplete, errors occurred!
See also "C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeOutput.log".
See also "C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeError.log".

This sounds strange because if I read the IAR.cmake, the case where this fatal error rises is when the compiler does not match "arm" neither avr. So I put a message output with the CMAKE_C_COMPILER argument and I get:

-- CMAKE_C_COMPILER={C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iccarm.exe}
-- The C compiler identification is IAR
-- The ASM compiler identification is IAR
-- Found assembler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iasmarm.exe
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/bin/iccarm.exe
CMake Error at C:/CMake/bin/Modules/Compiler/IAR.cmake:41 (message):
  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.
Call Stack (most recent call first):
  C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/3.7.2/CMakeSystem.cmake:6 (include)
  C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (project)


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Configuring incomplete, errors occurred!
See also "C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeOutput.log".
See also "C:/Projects/LabPadIntegration/lpd_firmware/LABPAD_IAR/FIRMWARE/build/CMakeFiles/CMakeError.log".

So I get the trace with CMAKE_C_COMPILER which matches well the value I entered, but the MATCH tells it does not match "arm"...

Any idea ?

Upvotes: 4

Views: 2438

Answers (2)

felipe-iar
felipe-iar

Reputation: 45

I've been successfully using CMake to build with the IAR C/C++ Compilers.

The CMake's find_program() function worked nicely for finding CMAKE_<LANG>_COMPILER when installed in the usual locations.

As one example, the CMake toolchain file from this IAR tutorial worked for me on both Windows and Linux compilers.

However, it is also possible to set environment variables CC, CXX and ASM. CMake will use such environment variables to set the full path to the compiler. For example:

  • On Windows, using the IAR Embedded Workbench:
set CC="%PROGRAMFILES%/IAR Systems/Embedded Workbench 9.1/arm/bin/iccarm.exe"
set CXX="%PROGRAMFILES%/IAR Systems/Embedded Workbench 9.1/arm/bin/iccarm.exe"
set ASM="%PROGRAMFILES%/IAR Systems/Embedded Workbench 9.1/arm/bin/iasmarm.exe"
  • On Linux, using the IAR Build Tools:
export CC=/opt/iarsystems/bxarm/arm/bin/iccarm
export CXX=/opt/iarsystems/bxarm/arm/bin/iccarm
export ASM=/opt/iarsystems/bxarm/arm/bin/iasmarm

Upvotes: 2

OlivierP
OlivierP

Reputation: 41

I just got some support from the Cmake issue tracker: My misunderstanding, this is because the file i give as an arg is not a toolchain file

Upvotes: 0

Related Questions