ARMclang always includes --target=arm-arm-none-eabi option

I’m using CMake 3.21, and for policy CMP0123, I chose to use “NEW” in my CMakeLists.txt:

cmake_policy(SET CMP0123 NEW)

And this is my toolchain file:

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER armclang)
set(CMAKE_CXX_COMPILER armclang)
set(CMAKE_ASM_COMPILER armclang)
set(CMAKE_CROSSCOMPILING true)
add_compile_options(--target=aarch64-arm-none-eabi -mcpu=cortex-r82+nofp+nocrypto+nosimd -mno-unaligned-access)

set(CMAKE_C_FLAGS_DEBUG_INIT  "")       #For standard config DEBUG, cmake adds -g automatically
set(CMAKE_C_FLAGS_RELEASE_INIT  "-g")   # for standard config REELEASE, cmake adds -O3 -DNDEBUG automatically

set(CMAKE_CXX_FLAGS_DEBUG_INIT  "${CMAKE_C_FLAGS_DEBUG_INIT}")
set(CMAKE_CXX_FLAGS_RELEASE_INIT  "${CMAKE_C_FLAGS_RELEASE_INIT}")

set(CMAKE_ASM_FLAGS_DEBUG_INIT  "-g")
set(CMAKE_ASM_FLAGS_RELEASE_INIT  "-g")

You can see I used --target=aarch64-arm-none-eabi in my compile options.
But when compiling, I found --target=arm-arm-none-eabi is always there as the first command option:

armclang --target=arm-arm-none-eabi -DUNITY_INCLUDE_CONFIG_H -I/home/auto/data/git/sdk_ylr/test/interrupts/cmk_build -I/home/auto/data/git/sdk_ylr/test/interrupts/../../tools/unity -I/home/auto/data/git/sdk_ylr/test/interrupts/../../hal/inc -I/home/auto/data/git/sdk_ylr/test/interrupts/../../hal/inc/reg -I/home/auto/data/git/sdk_ylr/hal/inc -I/home/auto/data/git/sdk_ylr/hal/inc/reg -g --target=aarch64-arm-none-eabi -mcpu=cortex-r82+nofp+nocrypto+nosimd -mno-unaligned-access -o CMakeFiles/interrupts_ut.dir/home/auto/data/git/sdk_ylr/tools/unity/unity.o -c /home/auto/data/git/sdk_ylr/tools/unity/unity.c

Though the 2nd --target option will take effect, it is still confusing and annoying with --target=arm-arm-none-eabi being there. Is there a way to fix it?

Thanks
-Oscar

Did you try the CMAKE_C_ COMPILER_TARGET variable?

Ok, after I added it back, the problem was fixed. I misunderstood CMP0123. I thought it made CMAKE_C_COMPILER_TARGET unnecessary as well.

Thank you, Hendrik.