Hello everyone,
I am quite new to CMake, and vscode.
I would like to use CMake to build a projet with armcc (Keil 5).
I saw that the way to do is to call a toolchain file, and mine is called armcc.cmake and look like this :
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION "5")
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(TOOLCHAIN_PATH C:/Keil_v5/ARM/ARMCC)
set(TOOLCHAIN_PATH_BIN ${TOOLCHAIN_PATH}/bin)
set(CMAKE_C_COMPILER "${TOOLCHAIN_PATH_BIN}/armcc.exe")
set(CMAKE_C_COMPILER_ID "ARMCC")
set(CMAKE_CXX_COMPILER_ID "ARMCC")
set(CMAKE_ASM_COMPILER "${TOOLCHAIN_PATH_BIN}/armasm.exe")
set(CMAKE_ASM_COMPILER_ID "ARMCC")
set(CMAKE_LINKER "${TOOLCHAIN_PATH_BIN}/armlink.exe")
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PATH})
set(CMAKE_MAKE_PROGRAM="make.exe")
It was inspired by CMake toolchain file for ARM Compiler 6 ? - Usage - CMake Discourse
My command is : cmake -S . -B _build\ -G "MinGW Makefiles"
In my CMakeLists.txt, I have the line message(STATUS "compiler id: ${CMAKE_C_COMPILER_ID}")
to verify the compiler ID
and the output is :
-- compiler id: ARMCC
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Keil_v5/ARM/ARMCC/bin/armcc.exe
-- Check for working C compiler: C:/Keil_v5/ARM/ARMCC/bin/armcc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"C:/Keil_v5/ARM/ARMCC/bin/armcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: 'C:/Users/Dev/BTM/_build/CMakeFiles/CMakeScratch/TryCompile-sc1eym'
Run Build Command(s): "C:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 make.exe -f Makefile cmTC_de0a0/fast
make.exe -f CMakeFiles\cmTC_de0a0.dir\build.make CMakeFiles/cmTC_de0a0.dir/build
make.exe[1]: entrant dans le rÚpertoire ½ C:/Users/Dev/BTM/_build/CMakeFiles/CMakeScratch/TryCompile-sc1eym ╗
Building C object CMakeFiles/cmTC_de0a0.dir/testCCompiler.c.obj
C:\Keil_v5\ARM\ARMCC\bin\armcc.exe -o CMakeFiles\cmTC_de0a0.dir\testCCompiler.c.obj -c C:\Users\b.bousquet\Dev\BTM\_build\CMakeFiles\CMakeScratch\TryCompile-sc1eym\testCCompiler.c
Error: C9912E: No --cpu selected
make.exe[1]: quittant le rÚpertoire ½ C:/Users/Dev/BTM/_build/CMakeFiles/CMakeScratch/TryCompile-sc1eym ╗
make.exe: *** [cmTC_de0a0/fast] Erreur 2
First question : I know I have to specify the cpu as the error say, but… where? In the toolchain file ? CMakeLists.txt? With which instruction ? target_compile_options ? set(CMAKE_C_FLAGS … ? What are the good practices here?
Second question : In the thread mentionned above, there are following logs :
[main] Configuring folder: BuildSystem
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DNDEBUG:STRING=1 -DEX1_ARCH:STRING=M4 -DEX1_SYSTEM:STRING=LoMa -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../CMake/toolchain/arm-keil.cmake -Hd:/Projects/Misc/BuildSystem/Source -Bd:/Projects/Misc/BuildSystem/Build -G "Ninja Multi-Config"
[cmake] Beginning of D:/Projects/Misc/BuildSystem/Source/CMakeLists.txt.
[cmake] Processing arm-keil.cmake...
[cmake] Processed arm-keil.cmake.
[cmake] Processing arm-keil.cmake...
[cmake] Processed arm-keil.cmake.
[cmake] -- The C compiler identification is ARMCC 5.6.960
[cmake] -- The CXX compiler identification is ARMCC 5.6.960
[cmake] -- The ASM compiler identification is ARMCC
[cmake] -- Found assembler: C:/Keil_v5/ARM/ARMCC/bin/armasm.exe
[cmake] -- Detecting C compiler ABI info
[cmake] Processing arm-keil.cmake...
[cmake] Processed arm-keil.cmake.
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Keil_v5/ARM/ARMCC/bin/armcc.exe - skipped
[cmake] -- Detecting CXX compiler ABI info [cmake] Processing arm-keil.cmake...
[cmake] Processed arm-keil.cmake.
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Keil_v5/ARM/ARMCC/bin/armcc.exe - skipped
[cmake] Cortex-M4 set. [cmake] Beginning of D:/Projects/Misc/BuildSystem/Source/HC-Q/CMakeLists.txt.
[...]
[cmake] -- Configuring done [cmake] -- Generating done
[...]
Why are my logs so differents? CMake doesn’t seems to recognize ARMCC compiler ID, and how do I skip the "Check for working C compiler?
Third question: I couldn’t find any complete tutorial on how to integrate armcc with CMake (toolchain file + a basic CMakeLists.txt). Does such a tutorial exists?
Thank you a lot for your help