blob: 5d91b987e2e3475cf86e849a151353471b246581 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2021 Arm Limited. All rights reserved.
3# 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# specify the cross compiler
18set(CMAKE_C_COMPILER armclang)
19set(CMAKE_CXX_COMPILER armclang)
20set(CMAKE_C_LINKER_PREFERENCE armlink)
21set(CMAKE_ASM_LINKER_PREFERENCE armlink)
22set(CMAKE_ASM_COMPILER armasm)
23set(CMAKE_ASM_COMPILER_AR armar)
24
25set(CMAKE_CROSSCOMPILING true)
26set(CMAKE_SYSTEM_NAME Generic)
27
28set(MIN_ARM_CLANG_VERSION 6.14)
29
30if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
31 set(CMAKE_SYSTEM_PROCESSOR cortex-m55)
32endif()
33
34# Skip compiler test execution
35set(CMAKE_C_COMPILER_WORKS 1)
36set(CMAKE_CXX_COMPILER_WORKS 1)
37
38set(PLATFORM_HAL 1)
39
40set(WARNING_OPTS "-Wall -Wextra -Wvla")
41set(SPECIAL_OPTS "-fno-rtti -funsigned-char -fno-function-sections -fno-exceptions")
42set(PLATFORM_FLAGS "-mthumb --target=arm-arm-non-eabi -mlittle-endian -DPLATFORM_HAL=${PLATFORM_HAL}")
43
44set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0")
45set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3")
46
47set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0")
48set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
49
50if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m55)
51 # Flags for cortex-m55
52 set(CPU_CORTEX_M55 1)
53 set(CPU_CC "-mcpu=cortex-m55 -mfloat-abi=hard -MD -DCPU_CORTEX_M55=1 -DARM_MATH_DSP -DARM_MATH_LOOPUNROLL -D__FPU_USED=1")
54 set(CPU_LD "--cpu=8.1-M.Main.dsp")
55elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m33)
56 # Flags for cortex-m33 to go here
57endif()
58
59set(ALL_COMMON_FLAGS "${CPU_CC} ${WARNING_OPTS} ${SPECIAL_OPTS} ${PLATFORM_FLAGS}")
60
61function(enforce_compiler_version)
62 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_ARM_CLANG_VERSION})
63 message( FATAL_ERROR "Arm compiler version must be ${MIN_ARM_CLANG_VERSION} or greater to support ${CMAKE_SYSTEM_PROCESSOR} architecture." )
64 endif()
65endfunction()