aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKumar Gala <kumar.gala@linaro.org>2020-04-16 16:29:49 -0500
committerAnton Komlev <Anton.Komlev@arm.com>2020-06-24 10:09:50 +0000
commit7946bdd345e7de4711b98dc21296b3d8149c49ba (patch)
tree3f49ffdad474691db664c84824881385bc5c8b1a
parent84aaeda0ec0633d436cad5d644e93fefe1e1702f (diff)
downloadtrusted-firmware-m-7946bdd345e7de4711b98dc21296b3d8149c49ba.tar.gz
Build: Add support for specifying GNUARM_PREFIX
Add support to allow for vendor specific GNU triplets that may not be arm-none-eabi, but something like arm-<VENDOR>-eabi. In cmake/Compiler/GNUARM.cmake we provide a means to extract the compiler prefix from CMAKE_C_COMPILER as it will not always be set. For example when mbed-crypto's CMake is invoked from tfm, we'll eventually source GNUARM.cmake and not have GNUARM_PREFIX set. This provides a means to handle such cases (otherwise we end up with NOTFOUND cache entries for CMAKE_LINKER & CMAKE_AR. Change-Id: I5b3f1a0ff1156b9eda6c540220aa99162b6fd813 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
-rw-r--r--cmake/Common/CompilerGNUARMCommon.cmake12
-rw-r--r--cmake/Common/FindGNUARM.cmake7
-rw-r--r--cmake/Compiler/GNUARM.cmake11
3 files changed, 20 insertions, 10 deletions
diff --git a/cmake/Common/CompilerGNUARMCommon.cmake b/cmake/Common/CompilerGNUARMCommon.cmake
index be1ac8faa..32e805bbe 100644
--- a/cmake/Common/CompilerGNUARMCommon.cmake
+++ b/cmake/Common/CompilerGNUARMCommon.cmake
@@ -32,13 +32,13 @@ message(STATUS "Using gcc compiler package v${GNUARM_VER} from ${GNUARM_PATH}")
#Tell cmake which compiler we use
if (EXISTS "c:/")
- set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-gcc.exe")
- set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-g++.exe")
- set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-gcc.exe")
+ set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc.exe")
+ set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-g++.exe")
+ set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc.exe")
else()
- set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-gcc")
- set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-g++")
- set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/arm-none-eabi-gcc")
+ set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc")
+ set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-g++")
+ set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc")
endif()
if("CXX" IN_LIST languages)
diff --git a/cmake/Common/FindGNUARM.cmake b/cmake/Common/FindGNUARM.cmake
index 5454c6881..d17871660 100644
--- a/cmake/Common/FindGNUARM.cmake
+++ b/cmake/Common/FindGNUARM.cmake
@@ -15,6 +15,8 @@
# the compiler on the PATH is used.
# GNUARM_VER - (optional)- version number. If set the module will validate
# the compiler version.
+# GNUARM_PREFIX (optional)- execute prefix for toolchain, allow for vendor
+# toolchains, default to arm-none-eabi
#
#outputs:
# GNUARM_PATH - will be set to the root directory of the compiler. Only set
@@ -28,7 +30,10 @@
#Include some dependencies
Include(Common/Utils)
-set(_GCC_BINARY_NAME "arm-none-eabi-gcc")
+if(NOT DEFINED GNUARM_PREFIX)
+ set(GNUARM_PREFIX "arm-none-eabi")
+endif()
+set(_GCC_BINARY_NAME "${GNUARM_PREFIX}-gcc")
#Get the version of armgcc.
#
diff --git a/cmake/Compiler/GNUARM.cmake b/cmake/Compiler/GNUARM.cmake
index ed05d9242..fc9db7a0d 100644
--- a/cmake/Compiler/GNUARM.cmake
+++ b/cmake/Compiler/GNUARM.cmake
@@ -15,9 +15,14 @@ get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PAT
set(CMAKE_EXECUTABLE_SUFFIX ".axf")
-find_program(CMAKE_GNUARM_LINKER arm-none-eabi-gcc HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
-find_program(CMAKE_GNUARM_AR arm-none-eabi-ar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
-find_program(CMAKE_GNUARM_OBJCOPY arm-none-eabi-objcopy HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+if(NOT DEFINED GNUARM_PREFIX)
+ get_filename_component(__c_bin ${CMAKE_C_COMPILER} NAME)
+ string(REPLACE "-gcc" "" GNUARM_PREFIX ${__c_bin})
+endif()
+
+find_program(CMAKE_GNUARM_LINKER ${GNUARM_PREFIX}-gcc HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+find_program(CMAKE_GNUARM_AR ${GNUARM_PREFIX}-ar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+find_program(CMAKE_GNUARM_OBJCOPY ${GNUARM_PREFIX}-objcopy HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
set(CMAKE_LINKER "${CMAKE_GNUARM_LINKER}" CACHE FILEPATH "The GNUARM linker" FORCE)
mark_as_advanced(CMAKE_GNUARM_LINKER)