IAR compiler feature detection regression in CMake 3.21 -- Unable to find executable
In CMake 3.21 and later, IAR feature detection fails, as follows:
-- Found IAR: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm
-- The C compiler identification is IAR ARM 9.10.2
-- The CXX compiler identification is IAR ARM 9.10.2
-- The ASM compiler identification is IAR ARM 9.10.2
-- Found assembler: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm/bin/iasmarm.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm/bin/iccarm.exe
-- Check for working C compiler: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm/bin/iccarm.exe - works
-- Detecting C compile features
-- Detecting C compile features - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm/bin/iccarm.exe
-- Check for working CXX compiler: C:/Program Files/IAR Systems/Embedded Workbench 9.0/arm/bin/iccarm.exe - works
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Workspaces/IAR/build
CMakeError.log contains the following errors:
Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is Clang using "--version" did not match "(clang version)":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is AppleClang using "--version" did not match "(Apple LLVM version)":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is ARMClang using "--version" did not match "armclang":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is HP using "-V" did not match "HP C":
Error in command line option '-V': No such option
Checking whether the ASM compiler is Intel using "--version" did not match "(ICC)":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is IntelLLVM using "--version" did not match "(Intel[^
]+oneAPI)":
IAR Assembler V9.10.2.313/W64 for ARM
Checking whether the ASM compiler is SunPro using "-V" did not match "Sun C":
Error in command line option '-V': No such option
Checking whether the ASM compiler is XL using "-qversion" did not match "XL C":
Error in command line option '-qversion': No such option
Checking whether the ASM compiler is MSVC using "-?" did not match "Microsoft":
Error in command line option '-?': No such option
Checking whether the ASM compiler is TI using "-h" did not match "Texas Instruments":
Error in command line option '-h': No such option
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/Ninja/ninja.exe cmTC_be0a2 && [1/2] Building C object CMakeFiles\cmTC_be0a2.dir\CMakeCCompilerABI.c.o
[2/2] Linking C executable cmTC_be0a2.elf
Cannot copy output executable
''
to destination specified by COPY_FILE:
'C:/Workspaces/IAR/build/CMakeFiles/3.21.3/CMakeDetermineCompilerABI_C.bin'
Unable to find the executable at any of:
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/cmTC_be0a2
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Debug/cmTC_be0a2
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Development/cmTC_be0a2
Detecting C [] compiler features failed to compile with the following output:
Change Dir: C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/Ninja/ninja.exe cmTC_1d348 && [1/2] Building C object CMakeFiles\cmTC_1d348.dir\feature_tests.c.o
[2/2] Linking C executable cmTC_1d348.elf
Cannot copy output executable
''
to destination specified by COPY_FILE:
'C:/Workspaces/IAR/build/CMakeFiles/feature_tests.bin'
Unable to find the executable at any of:
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/cmTC_1d348
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Debug/cmTC_1d348
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Development/cmTC_1d348
Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/Ninja/ninja.exe cmTC_dde76 && [1/2] Building CXX object CMakeFiles\cmTC_dde76.dir\CMakeCXXCompilerABI.cpp.o
[2/2] Linking CXX executable cmTC_dde76.elf
Cannot copy output executable
''
to destination specified by COPY_FILE:
'C:/Workspaces/IAR/build/CMakeFiles/3.21.3/CMakeDetermineCompilerABI_CXX.bin'
Unable to find the executable at any of:
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/cmTC_dde76
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Debug/cmTC_dde76
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Development/cmTC_dde76
Detecting CXX [] compiler features failed to compile with the following output:
Change Dir: C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/Ninja/ninja.exe cmTC_3913b && [1/2] Building CXX object CMakeFiles\cmTC_3913b.dir\feature_tests.cxx.o
[2/2] Linking CXX executable cmTC_3913b.elf
Cannot copy output executable
''
to destination specified by COPY_FILE:
'C:/Workspaces/IAR/build/CMakeFiles/feature_tests.bin'
Unable to find the executable at any of:
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/cmTC_3913b
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Debug/cmTC_3913b
C:/Workspaces/IAR/build/CMakeFiles/CMakeTmp/Development/cmTC_3913b
The referenced executables are present when configured with --debug-trycompile as .elf files. Perhaps CMake is using the wrong executable extension here?
A project to reproduce this is attached: IAR.zip
This simply needs to be run with cmake <path_to_source> -DCMAKE_TOOLCHAIN_DIR=<path_to_source>\cmake\IAR.cmake -G Ninja
Edited by Brad King