Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Sverteczky, Marcell | d332119 | 2019-06-03 14:13:36 +0200 | [diff] [blame^] | 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #This file contains settings to specify how ARMCLANG shall be used |
| 9 | |
| 10 | #Include some dependencies |
| 11 | Include(Common/CompilerArmClangCommon) |
| 12 | Include(Common/Utils) |
| 13 | |
| 14 | check_armclang_input_vars("6.10") |
| 15 | |
| 16 | if(NOT DEFINED ARM_CPU_ARCHITECTURE) |
| 17 | set(_NO_ARM_CPU_ARCHITECTURE true) |
| 18 | elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.BASE") |
| 19 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 20 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") |
| 21 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 22 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") |
| 23 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") |
| 24 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") |
| 25 | elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") |
| 26 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 27 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") |
| 28 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 29 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") |
| 30 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") |
| 31 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") |
| 32 | elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") |
| 33 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
Sverteczky, Marcell | d332119 | 2019-06-03 14:13:36 +0200 | [diff] [blame^] | 34 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 35 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 36 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") |
| 37 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") |
| 38 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") |
| 39 | else() |
| 40 | message(FATAL_ERROR "Unknown or unsupported ARM cpu architecture setting.") |
| 41 | endif() |
| 42 | |
| 43 | #Prefer architecture definition over cpu type. |
| 44 | if(NOT DEFINED ARM_CPU_ARCHITECTURE) |
| 45 | if(NOT DEFINED ARM_CPU_TYPE) |
| 46 | string_append_unique_item(_NO_ARM_CPU_TYPE true) |
| 47 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M3") |
Sverteczky, Marcell | d332119 | 2019-06-03 14:13:36 +0200 | [diff] [blame^] | 48 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 49 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") |
| 50 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 51 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") |
| 52 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") |
| 53 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 54 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") |
Sverteczky, Marcell | d332119 | 2019-06-03 14:13:36 +0200 | [diff] [blame^] | 55 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 56 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") |
| 57 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 58 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") |
| 59 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") |
| 60 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 61 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") |
Sverteczky, Marcell | d332119 | 2019-06-03 14:13:36 +0200 | [diff] [blame^] | 62 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 63 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") |
| 64 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 65 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") |
| 66 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M23") |
| 67 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M23") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame] | 68 | else() |
| 69 | message(FATAL_ERROR "Unknown ARM cpu setting.") |
| 70 | endif() |
| 71 | endif() |
| 72 | |
| 73 | if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) |
| 74 | message(FATAL_ERROR "Can not set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") |
| 75 | endif() |