GNUARM.cmake: Support the CROSS_COMPILE setting
This is to support toolchains where the name is not arm-none-eabi-gcc,
such as arm-zephyr-eabi-gcc.
This is analogous to how it is solved in TFM.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
diff --git a/api-tests/CMakeLists.txt b/api-tests/CMakeLists.txt
index c243ebd..6181634 100644
--- a/api-tests/CMakeLists.txt
+++ b/api-tests/CMakeLists.txt
@@ -109,6 +109,11 @@
HOST_GCC
)
+# list of supported CROSS_COMPILE toolchains
+list(APPEND CROSS_COMPILE_TOOLCHAIN_SUPPORT
+ GNUARM
+)
+
# list of suported CPU arch
list(APPEND PSA_CPU_ARCH_SUPPORT
armv8m_ml
@@ -438,6 +443,9 @@
# Check for supported toolchain/s
if(${TOOLCHAIN} IN_LIST PSA_TOOLCHAIN_SUPPORT)
+ if(CROSS_COMPILE AND NOT (${TOOLCHAIN} IN_LIST CROSS_COMPILE_TOOLCHAIN_SUPPORT))
+ message(FATAL_ERROR "[PSA] : Error: CROSS_COMPILE not supported for this toolchain, supported toolchain are : ${CROSS_COMPILE_TOOLCHAIN_SUPPORT}")
+ endif()
include(${PSA_ROOT_DIR}/tools/cmake/compiler/${TOOLCHAIN}.cmake)
else()
message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTOOLCHAIN=${TOOLCHAIN}, supported toolchain are : ${PSA_TOOLCHAIN_SUPPORT}")
diff --git a/api-tests/tools/cmake/compiler/GNUARM.cmake b/api-tests/tools/cmake/compiler/GNUARM.cmake
index 20102e1..faf1755 100644
--- a/api-tests/tools/cmake/compiler/GNUARM.cmake
+++ b/api-tests/tools/cmake/compiler/GNUARM.cmake
@@ -18,7 +18,11 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMKE_SYSTEM_PROCESSOR ARM)
-set(_C_TOOLCHAIN_NAME arm-none-eabi-gcc)
+if (DEFINED CROSS_COMPILE)
+ set(_C_TOOLCHAIN_NAME ${CROSS_COMPILE}-gcc)
+else()
+ set(_C_TOOLCHAIN_NAME arm-none-eabi-gcc)
+endif()
if(WIN32)
if (NOT DEFINED GNUARM_PATH)
@@ -40,7 +44,7 @@
if(_C_TOOLCHAIN_PATH STREQUAL "_C_TOOLCHAIN_PATH-NOTFOUND")
message(FATAL_ERROR "[PSA] : Couldn't find ${_C_TOOLCHAIN_NAME}."
- " Either put ${_C_TOOLCHAIN_NAME} on the PATH or set GNUARM_PATH set properly.")
+ " Either put ${_C_TOOLCHAIN_NAME} on the PATH or set GNUARM_PATH or CROSS_COMPILE properly.")
endif()
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)