blob: 4b792b30c5865bec33356efdf7e1914e5b8e2a8a [file] [log] [blame]
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +05301#/** @file
Dávid Házi330c4b12023-05-03 11:20:02 +02002# * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved.
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +05303# * SPDX-License-Identifier : Apache-2.0
4# *
5# * Licensed under the Apache License, Version 2.0 (the "License");
6# * you may not use this file except in compliance with the License.
7# * You may obtain a copy of the License at
8# *
9# * http://www.apache.org/licenses/LICENSE-2.0
10# *
11# * Unless required by applicable law or agreed to in writing, software
12# * distributed under the License is distributed on an "AS IS" BASIS,
13# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# * See the License for the specific language governing permissions and
15# * limitations under the License.
16#**/
17
18set(CMAKE_SYSTEM_NAME Generic)
jothikumar mani4a274162023-07-18 00:31:22 +080019set(CMAKE_SYSTEM_PROCESSOR ARM)
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +053020
21set(_C_TOOLCHAIN_NAME armclang)
22
23if(WIN32)
24 if (NOT DEFINED ARMCLANG_PATH)
25 set(ARMCLANG_PATH "C:" CACHE PATH "Install directory for ARMCLANG Compiler")
26 endif()
27else(WIN32)
28 if (NOT DEFINED ARMCLANG_PATH)
29 set(ARMCLANG_PATH "/" CACHE PATH "Install directory for ARMCLANG Compiler")
30 endif()
31endif(WIN32)
32
33find_program(
34 _C_TOOLCHAIN_PATH
35 ${_C_TOOLCHAIN_NAME}
36 PATHS env PATH
37 HINTS ${ARMCLANG_PATH}
38 HINTS bin
39)
40
41if(_C_TOOLCHAIN_PATH STREQUAL "_C_TOOLCHAIN_PATH-NOTFOUND")
42 message(FATAL_ERROR "[PSA] : Couldn't find ${_C_TOOLCHAIN_NAME}."
43 " Either put ${_C_TOOLCHAIN_NAME} on the PATH or set ARMCLANG_PATH set properly.")
44endif()
45
46set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
47
48foreach(_LNG IN ITEMS "C" "ASM")
49 set(CMAKE_${_LNG}_COMPILER ${_C_TOOLCHAIN_PATH})
50 message(STATUS "[PSA] : ${_LNG} compiler used '${CMAKE_${_LNG}_COMPILER}'")
51endforeach()
52
53if(${CPU_ARCH} STREQUAL armv7m)
Dávid Házi330c4b12023-05-03 11:20:02 +020054 set(TARGET_SWITCH "-march=armv7-m")
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +053055elseif(${CPU_ARCH} STREQUAL armv8m_ml)
Dávid Házi330c4b12023-05-03 11:20:02 +020056 set(TARGET_SWITCH "-march=armv8-m.main -mcmse")
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +053057elseif(${CPU_ARCH} STREQUAL armv8m_bl)
Dávid Házi330c4b12023-05-03 11:20:02 +020058 set(TARGET_SWITCH "-march=armv8-m.base -mcmse")
59elseif(${CPU_ARCH} STREQUAL armv81m_ml)
60 set(TARGET_SWITCH "-march=armv8.1-m.main -mcmse")
jothikumar mani4a274162023-07-18 00:31:22 +080061elseif(${CPU_ARCH} STREQUAL armv7a)
62 set(TARGET_SWITCH "-march=armv7-a")
63elseif(${CPU_ARCH} STREQUAL armv8a)
64 set(TARGET_SWITCH "-march=armv8-a")
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +053065endif()
66
Vinay Kumar Kotegowder52bbfc92020-07-03 17:23:59 +053067set(CMAKE_C_FLAGS "--target=arm-arm-none-eabi ${TARGET_SWITCH} -g -Wall -Werror -Wextra -fshort-enums -fshort-wchar -funsigned-char -fdata-sections -ffunction-sections -mno-unaligned-access -mfpu=none")
Vinay Kumar Kotegowder9982f902019-07-15 09:13:54 +053068set(CMAKE_ASM_FLAGS "${TARGET_SWITCH} -mthumb")
69set(CMAKE_EXE_LINKER_FLAGS "--strict --map --symbols --xref --info=summarysizes,sizes,totals,unused,veneers --diag_warning=L6204")