alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 |
| 18 | set(CMAKE_C_COMPILER armclang) |
| 19 | set(CMAKE_CXX_COMPILER armclang) |
| 20 | set(CMAKE_C_LINKER_PREFERENCE armlink) |
| 21 | set(CMAKE_ASM_LINKER_PREFERENCE armlink) |
| 22 | set(CMAKE_ASM_COMPILER armasm) |
| 23 | set(CMAKE_ASM_COMPILER_AR armar) |
| 24 | |
| 25 | set(CMAKE_CROSSCOMPILING true) |
| 26 | set(CMAKE_SYSTEM_NAME Generic) |
| 27 | |
| 28 | set(MIN_ARM_CLANG_VERSION 6.14) |
| 29 | |
| 30 | if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR) |
| 31 | set(CMAKE_SYSTEM_PROCESSOR cortex-m55) |
| 32 | endif() |
| 33 | |
| 34 | # Skip compiler test execution |
| 35 | set(CMAKE_C_COMPILER_WORKS 1) |
| 36 | set(CMAKE_CXX_COMPILER_WORKS 1) |
| 37 | |
| 38 | set(PLATFORM_HAL 1) |
| 39 | |
| 40 | set(WARNING_OPTS "-Wall -Wextra -Wvla") |
| 41 | set(SPECIAL_OPTS "-fno-rtti -funsigned-char -fno-function-sections -fno-exceptions") |
| 42 | set(PLATFORM_FLAGS "-mthumb --target=arm-arm-non-eabi -mlittle-endian -DPLATFORM_HAL=${PLATFORM_HAL}") |
| 43 | |
| 44 | set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O0") |
| 45 | set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3") |
| 46 | |
| 47 | set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O0") |
| 48 | set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3") |
| 49 | |
| 50 | if (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") |
| 55 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m33) |
| 56 | # Flags for cortex-m33 to go here |
| 57 | endif() |
| 58 | |
| 59 | set(ALL_COMMON_FLAGS "${CPU_CC} ${WARNING_OPTS} ${SPECIAL_OPTS} ${PLATFORM_FLAGS}") |
| 60 | |
| 61 | function(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() |
| 65 | endfunction() |