Cross Compiling toolchain not taken into account

Hi,

I’m new to CMAke and trying to set up a cross compile project for ARM using the Armcc tools (from Keil) . I saw the toolchain files are part of the Cmake distribution , so I’m trying to use it … without any success. I set up a simple test project with this CMakeLists.txt :
cmake_minimum_required(VERSION 3.10)
project(Tutorial)
# add the executable
add_executable(test.c)

When I launch:
cmake D:\Tmp\Test -D CMAKE_TOOLCHAIN_FILE=“D:\Dev\CMake\share\cmake-3.18\Modules\Compiler\ARMCC.cmake” -D CMAKE_C_COMPILER_ID=ARMCC -D CMAKE_CXX_COMPILER_ID=ARMCC -GNinja

It’s seems it’s not using the compiler defined in the toolchain but trying to use gcc installed on my desktop.

So I’m not sure to understand how to use the provided compilers from the armcc toolchain ?

Hi,

It’s because Modules\Compiler\ARMCC.cmake is not a toolchain file.

Have you got a chance to look into documentation?

Another example can be found here.

Ok, thx
But then, what are the armcc*.cmake files for ?

From cmake-toolchains(7):
In normal builds, CMake automatically determines the toolchain for host builds based on system introspection and defaults. In cross-compiling scenarios, a toolchain file may be specified with information about compiler and utility paths.

What you are looking at are files that support compilers / toolchains that CMake already knows how to use. As already mentioned they are not toolchain files as used by CMAKE_TOOLCHAIN_FILE.