IAR for AVR support
I am trying to create a CMake project using the IAR compiler for AVR. There seems to be a lot of recent changes to the IAR-ARM code but not much work being done on the AVR side of things. I have found two issues:
-
CMAKE_C_COMPILER_ARCHITECTURE_ID
andCMAKE_CXX_COMPILER_ARCHITECTURE_ID
are not set. As a quick fix I have added two lines to the files CMakeDetermineCCompiler.cmake and CMakeDetermineCXXCompiler.cmake at lie 174 to show me what the logic is actually setting the variable to before forcing it to be AVR
message("MESSAGE: CMAKE_C_COMPILER_ARCHITECTURE_ID is set as \"${CMAKE_C_COMPILER_ARCHITECTURE_ID}\", forcing to AVR")
set(CMAKE_C_COMPILER_ARCHITECTURE_ID AVR)
this results in the output:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=toolchain-iaravr.cmake -G "CodeBlocks - MinGW Makefiles" C:\Users\ethan\working\minipat
-- The C compiler identification is IAR
MESSAGE: CMAKE_C_COMPILER_ARCHITECTURE_ID is set as "", forcing to AVR
-- The CXX compiler identification is IAR
MESSAGE: CMAKE_CXX_COMPILER_ARCHITECTURE_ID is set as "", forcing to AVR
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe" "cmTC_300d0/fast"
C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe -f CMakeFiles\cmTC_300d0.dir\build.make CMakeFiles/cmTC_300d0.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_300d0.dir/testCCompiler.c.r90
C:\PROGRA~2\IARSYS~1\EMBEDD~1.0\avr\bin\iccavr.exe -IC:\PROGRA~2\IARSYS~1\EMBEDD~1.0\avr\inc -o CMakeFiles\cmTC_300d0.dir\testCCompiler.c.r90 -c C:\Users\ethan\working\minipat\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c
IAR C/C++ Compiler V7.10.6.1378 for Atmel AVR
Copyright 1996-2018 IAR Systems AB.
Standalone license - IAR Embedded Workbench for Atmel AVR 7.10
Command line error: Unexpected command line arguments:
-c
CMakeFiles\cmTC_300d0.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_300d0.dir/testCCompiler.c.r90' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_300d0.dir/testCCompiler.c.r90] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_300d0/fast' failed
mingw32-make.exe: *** [cmTC_300d0/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeError.log".
[Finished]
- As shown in the output above the second problem is that the AVR lacks specific compile commands. Looking in the file
IAR.cmake
the ARM section is 18 lines but the AVR section is only 4 lines. I added the lines (copied from the ARM section minus the silent flag):
set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
set(CMAKE_${lang}_LINK_EXECUTABLE "\"xlink.exe\" <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
which changed the output to:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=toolchain-iaravr.cmake -G "CodeBlocks - MinGW Makefiles" C:\Users\ethan\working\minipat
-- The C compiler identification is IAR
MESSAGE: CMAKE_C_COMPILER_ARCHITECTURE_ID is set as "", forcing to AVR
-- The CXX compiler identification is IAR
MESSAGE: CMAKE_CXX_COMPILER_ARCHITECTURE_ID is set as "", forcing to AVR
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe
-- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/bin/iccavr.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe" "cmTC_76c71/fast"
C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe -f CMakeFiles\cmTC_76c71.dir\build.make CMakeFiles/cmTC_76c71.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_76c71.dir/testCCompiler.c.r90
C:\PROGRA~2\IARSYS~1\EMBEDD~1.0\avr\bin\iccavr.exe C:\Users\ethan\working\minipat\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c -IC:\PROGRA~2\IARSYS~1\EMBEDD~1.0\avr\inc -o CMakeFiles\cmTC_76c71.dir\testCCompiler.c.r90
IAR C/C++ Compiler V7.10.6.1378 for Atmel AVR
Copyright 1996-2018 IAR Systems AB.
Standalone license - IAR Embedded Workbench for Atmel AVR 7.10
6 bytes of CODE memory
Errors: none
Warnings: none
Linking C executable cmTC_76c71.bin
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_76c71.dir\link.txt --verbose=1
"" CMakeFiles/cmTC_76c71.dir/testCCompiler.c.r90 -f C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/avr/config/lnkm2561s.xcl -o cmTC_76c71.bin
Error running link command: The parameter is incorrect
CMakeFiles\cmTC_76c71.dir\build.make:85: recipe for target 'cmTC_76c71.bin' failed
mingw32-make.exe[1]: *** [cmTC_76c71.bin] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_76c71/fast' failed
mingw32-make.exe: *** [cmTC_76c71/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/ethan/working/minipat/cmake-build-debug/CMakeFiles/CMakeError.log".
[Finished]
so it seems that the compiler seems to work now, but I need to figure out how to get the ARCHITECTURE_ID
to actually detect AVR and also get the linker to work.