blob: 0f6000f3ed0f5ba80042c59387ca34ad90acf788 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
2# Copyright (c) 2017, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#Built in compiler identification does not work for embedded targets, so
9#override it here.
10
11#Stop built in CMakeDetermine<lang>.cmake scripts to run.
12set (CMAKE_C_COMPILER_ID_RUN 1)
13#Stop cmake run compiler tests.
14set (CMAKE_C_COMPILER_FORCED true)
15
16if(NOT DEFINED CMAKE_C_COMPILER)
17 message(FATAL_ERROR "Please set CMAKE_C_COMPILER to hold the full path of \
18your compiler executable")
19endif(NOT DEFINED CMAKE_C_COMPILER)
20
21get_filename_component(_C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
22
23#Based on the name of the compiler executable select which tool we use.
24if (_C_COMPILER_NAME MATCHES "^.*armclang(\\.exe)?$")
25 set(CMAKE_C_COMPILER_ID "ARMCLANG" CACHE INTERNAL "C compiler ID" FORCE)
26 set(ARM_TOOLCHAIN_FILE "Compiler/ARMClang-C")
27elseif (_C_COMPILER_NAME MATCHES "^.*gcc(\\.exe)?$")
28 set(CMAKE_C_COMPILER_ID "GNU" CACHE INTERNAL "C compiler ID" FORCE)
29 set(ARM_TOOLCHAIN_FILE "Compiler/GNU-C")
30elseif (_C_COMPILER_NAME MATCHES "^.*iccarm(\\.exe)?$")
31 set(CMAKE_C_COMPILER_ID "IAR" CACHE INTERNAL "C compiler ID" FORCE)
32 set(ARM_TOOLCHAIN_FILE "Compiler/IAR-C")
33else()
34 message(FATAL_ERROR "C Compiler executable ${_C_COMPILER_NAME} is unknown.\
35Please add needed settings to ${CMAKE_CURRENT_LIST_FILE}")
36endif ()
37
38include(${ARM_TOOLCHAIN_FILE})